Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,30 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from code_reviewer import review_code
|
|
|
|
| 3 |
|
|
|
|
| 4 |
st.title("🤖 Code Review Agent (Hugging Face Edition)")
|
| 5 |
|
| 6 |
-
|
| 7 |
code = st.text_area("Paste your code diff or snippet here 👇", height=300)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
if st.button("Review Code"):
|
| 10 |
if code.strip():
|
| 11 |
with st.spinner("Analyzing with Hugging Face model..."):
|
|
@@ -13,4 +32,4 @@ if st.button("Review Code"):
|
|
| 13 |
st.success("Code Review:")
|
| 14 |
st.markdown(feedback)
|
| 15 |
else:
|
| 16 |
-
st.warning("Please enter some code first.")
|
|
|
|
| 1 |
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="centered")
|
| 6 |
st.title("🤖 Code Review Agent (Hugging Face Edition)")
|
| 7 |
|
| 8 |
+
st.subheader("1️⃣ Paste code or diff manually:")
|
| 9 |
code = st.text_area("Paste your code diff or snippet here 👇", height=300)
|
| 10 |
|
| 11 |
+
st.subheader("2️⃣ Or fetch from a GitHub Pull Request:")
|
| 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("Fetched PR diff successfully!")
|
| 25 |
+
code = diff_text # Fill into the text area
|
| 26 |
+
st.code(diff_text, language="diff")
|
| 27 |
+
|
| 28 |
if st.button("Review Code"):
|
| 29 |
if code.strip():
|
| 30 |
with st.spinner("Analyzing with Hugging Face model..."):
|
|
|
|
| 32 |
st.success("Code Review:")
|
| 33 |
st.markdown(feedback)
|
| 34 |
else:
|
| 35 |
+
st.warning("Please enter or fetch some code first.")
|