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="centered") | |
| st.title("🤖 Code Review Agent (Hugging Face Edition)") | |
| st.subheader("1️⃣ Paste code or diff manually:") | |
| code = st.text_area("Paste your code diff or snippet here 👇", height=300) | |
| st.subheader("2️⃣ Or fetch from a GitHub Pull Request:") | |
| repo_owner = st.text_input("GitHub Repo Owner", placeholder="e.g. openai") | |
| repo_name = st.text_input("GitHub Repo Name", placeholder="e.g. gpt-code-review") | |
| pr_number = st.number_input("PR Number", min_value=1, step=1) | |
| github_token = st.text_input("GitHub Token (optional if public repo)", type="password") | |
| if st.button("Fetch from GitHub 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("Fetched PR diff successfully!") | |
| code = diff_text # Fill into the text area | |
| st.code(diff_text, language="diff") | |
| if st.button("Review Code"): | |
| if code.strip(): | |
| with st.spinner("Analyzing with Hugging Face model..."): | |
| feedback = review_code(code) | |
| st.success("Code Review:") | |
| st.markdown(feedback) | |
| else: | |
| st.warning("Please enter or fetch some code first.") | |