Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from code_reviewer import review_code | |
| from pr_fetcher import fetch_pr_diff | |
| st.set_page_config(page_title="Code Review Agent", layout="wide") | |
| st.title("π€ Code Review Agent (Hugging Face Edition)") | |
| st.caption("Fetch a Pull Request from GitHub and get AI-powered review + improved code") | |
| # Sidebar for inputs | |
| st.sidebar.header("π GitHub PR Details") | |
| repo_owner = st.sidebar.text_input("GitHub Repo Owner", placeholder="e.g. openai") | |
| repo_name = st.sidebar.text_input("GitHub Repo Name", placeholder="e.g. gpt-code-review") | |
| pr_number = st.sidebar.number_input("PR Number", min_value=1, step=1) | |
| github_token = st.sidebar.text_input("GitHub Token (optional if public repo)", type="password") | |
| if st.sidebar.button("π Fetch & Review PR"): | |
| with st.spinner("Fetching PR diff..."): | |
| diff_text = fetch_pr_diff(repo_owner, repo_name, pr_number, github_token) | |
| if diff_text.startswith("Error"): | |
| st.error(diff_text) | |
| else: | |
| st.success("β PR diff fetched successfully!") | |
| # Display the diff for reference | |
| with st.expander("π View Raw PR Diff"): | |
| st.code(diff_text, language="diff") | |
| # Review with LLM | |
| with st.spinner("Analyzing code with Hugging Face model..."): | |
| feedback, improved_code = review_code(diff_text) | |
| # Show results | |
| st.subheader("π‘ Review Feedback") | |
| st.markdown(feedback) | |
| st.subheader("β¨ Suggested Improved Code") | |
| st.code(improved_code, language="python") | |