Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,34 +2,37 @@ import streamlit as st
|
|
| 2 |
from code_reviewer import review_code
|
| 3 |
from pr_fetcher import fetch_pr_diff
|
| 4 |
|
| 5 |
-
st.set_page_config(page_title="Code Review Agent", layout="
|
| 6 |
st.title("π€ Code Review Agent (Hugging Face Edition)")
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
st.
|
| 12 |
-
repo_owner = st.text_input("GitHub Repo Owner", placeholder="e.g. openai")
|
| 13 |
-
repo_name = st.text_input("GitHub Repo Name", placeholder="e.g. gpt-code-review")
|
| 14 |
-
pr_number = st.number_input("PR Number", min_value=1, step=1)
|
| 15 |
-
github_token = st.text_input("GitHub Token (optional if public repo)", type="password")
|
| 16 |
-
|
| 17 |
-
if st.button("Fetch from GitHub PR"):
|
| 18 |
with st.spinner("Fetching PR diff..."):
|
| 19 |
diff_text = fetch_pr_diff(repo_owner, repo_name, pr_number, github_token)
|
| 20 |
|
| 21 |
if diff_text.startswith("Error"):
|
| 22 |
st.error(diff_text)
|
| 23 |
else:
|
| 24 |
-
st.success("
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
| 2 |
from code_reviewer import review_code
|
| 3 |
from pr_fetcher import fetch_pr_diff
|
| 4 |
|
| 5 |
+
st.set_page_config(page_title="Code Review Agent", layout="wide")
|
| 6 |
st.title("π€ Code Review Agent (Hugging Face Edition)")
|
| 7 |
+
st.caption("Fetch a Pull Request from GitHub and get AI-powered review + improved code")
|
| 8 |
|
| 9 |
+
# Sidebar for inputs
|
| 10 |
+
st.sidebar.header("π GitHub PR Details")
|
| 11 |
+
repo_owner = st.sidebar.text_input("GitHub Repo Owner", placeholder="e.g. openai")
|
| 12 |
+
repo_name = st.sidebar.text_input("GitHub Repo Name", placeholder="e.g. gpt-code-review")
|
| 13 |
+
pr_number = st.sidebar.number_input("PR Number", min_value=1, step=1)
|
| 14 |
+
github_token = st.sidebar.text_input("GitHub Token (optional if public repo)", type="password")
|
| 15 |
|
| 16 |
+
if st.sidebar.button("π Fetch & Review PR"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
with st.spinner("Fetching PR diff..."):
|
| 18 |
diff_text = fetch_pr_diff(repo_owner, repo_name, pr_number, github_token)
|
| 19 |
|
| 20 |
if diff_text.startswith("Error"):
|
| 21 |
st.error(diff_text)
|
| 22 |
else:
|
| 23 |
+
st.success("β
PR diff fetched successfully!")
|
| 24 |
+
|
| 25 |
+
# Display the diff for reference
|
| 26 |
+
with st.expander("π View Raw PR Diff"):
|
| 27 |
+
st.code(diff_text, language="diff")
|
| 28 |
|
| 29 |
+
# Review with LLM
|
| 30 |
+
with st.spinner("Analyzing code with Hugging Face model..."):
|
| 31 |
+
feedback, improved_code = review_code(diff_text)
|
| 32 |
+
|
| 33 |
+
# Show results
|
| 34 |
+
st.subheader("π‘ Review Feedback")
|
| 35 |
+
st.markdown(feedback)
|
| 36 |
+
|
| 37 |
+
st.subheader("β¨ Suggested Improved Code")
|
| 38 |
+
st.code(improved_code, language="python")
|