Spaces:
Sleeping
Sleeping
File size: 1,534 Bytes
72ae69a cf44d65 26c9196 8d95c8b 72ae69a 8d95c8b 72ae69a 8d95c8b 72ae69a 8d95c8b 03c85eb 8d95c8b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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")
|