Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from code_reviewer import review_code | |
| from pr_fetcher import fetch_pr_diff | |
| # ----------------------------- | |
| # Streamlit Page Config | |
| # ----------------------------- | |
| st.set_page_config(page_title="Code Review Agent", page_icon="π€", layout="wide") | |
| st.title("π€ Code Review Agent (Hugging Face Edition)") | |
| st.write("Fetch a Pull Request from GitHub and get **AI-powered review + improved code**") | |
| # ----------------------------- | |
| # Sidebar Inputs | |
| # ----------------------------- | |
| with st.sidebar: | |
| st.header("π GitHub PR Details") | |
| owner = st.text_input("GitHub Repo Owner", "kumar1905") | |
| repo = st.text_input("GitHub Repo Name", "TEMPERATURE-CONVERTOR") | |
| pr_number = st.number_input("PR Number", min_value=1, value=1, step=1) | |
| token = st.text_input("GitHub Token (optional if public repo)", type="password") | |
| fetch_btn = st.button("π Fetch & Review PR") | |
| # ----------------------------- | |
| # Fetch + Review | |
| # ----------------------------- | |
| if fetch_btn: | |
| with st.spinner("Fetching PR diff..."): | |
| diff = fetch_pr_diff(owner, repo, pr_number, token) | |
| if diff.startswith("Error"): | |
| st.error(diff) | |
| else: | |
| st.success("β PR diff fetched successfully!") | |
| with st.expander("π View Raw PR Diff"): | |
| st.code(diff, language="diff") | |
| with st.spinner("Analyzing code with Hugging Face model..."): | |
| feedback, code = review_code(diff) | |
| # Feedback Section | |
| st.subheader("π‘ Review Feedback") | |
| if feedback: | |
| st.write(feedback) | |
| else: | |
| st.warning("No feedback generated.") | |
| # Improved Code Section | |
| st.subheader("β¨ Suggested Improved Code") | |
| if code: | |
| st.code(code, language="python") | |
| else: | |
| st.warning("No improved code generated.") | |
| # ----------------------------- | |
| # Footer | |
| # ----------------------------- | |
| st.markdown("---") | |
| st.markdown("Built with β€οΈ using [Streamlit](https://streamlit.io/) & [Hugging Face Transformers](https://huggingface.co/)") | |