-
Notifications
You must be signed in to change notification settings - Fork 1
/
streamlit.py
28 lines (25 loc) · 965 Bytes
/
streamlit.py
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
import time
import streamlit as st
from app import CodeAnalyzer
import json
code_handler = CodeAnalyzer()
st.title("AI-Powered Code Style Guide with Gemini")
code_input = st.text_area("Paste your code here:", height=250)
if st.button("Analyze"):
if code_input:
with st.spinner("Analyzing..."):
code_handler._input_code = code_input
response = code_handler.analyze_code()
data = json.loads(response)
st.subheader("Style Guide and Suggestions:")
# Expanders
for items in data["issues"]:
with st.expander(f"Line `{items['line']}`"):
st.write(items["message"])
# JSON output
st.subheader("Raw API response : ")
with st.expander("Expand"):
st.json(response) # Display the Gemini-generated style guide
time.sleep(5)
else:
st.warning("Please paste your code to analyze.")