Spaces:
Build error
Build error
Commit
·
4e33c9b
1
Parent(s):
403a26d
update: add sidebar and markdowm format
Browse files
app.py
CHANGED
|
@@ -12,19 +12,21 @@ client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
|
| 12 |
|
| 13 |
st.title("Code Analysis with LLMs")
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
code_text = ""
|
| 18 |
if code_input_method == "Paste Code":
|
| 19 |
-
code_text = st.text_area("Paste your code here:")
|
| 20 |
elif code_input_method == "Upload Code File":
|
| 21 |
-
uploaded_file = st.file_uploader("Upload your code file", type=["py", "txt"])
|
| 22 |
if uploaded_file is not None:
|
| 23 |
code_text = uploaded_file.read().decode("utf-8")
|
| 24 |
|
| 25 |
-
model_choice = st.selectbox("Select LLM Model", ["
|
| 26 |
|
| 27 |
-
if st.button("Analyze Code") and code_text:
|
| 28 |
llm_obj = LLMClient(client)
|
| 29 |
processor = CodeProcessor(llm_obj)
|
| 30 |
|
|
|
|
| 12 |
|
| 13 |
st.title("Code Analysis with LLMs")
|
| 14 |
|
| 15 |
+
st.sidebar.title("Input Options")
|
| 16 |
+
|
| 17 |
+
code_input_method = st.sidebar.radio("How would you like to provide your code?", ("Paste Code", "Upload Code File"))
|
| 18 |
|
| 19 |
code_text = ""
|
| 20 |
if code_input_method == "Paste Code":
|
| 21 |
+
code_text = st.sidebar.text_area("Paste your code here:")
|
| 22 |
elif code_input_method == "Upload Code File":
|
| 23 |
+
uploaded_file = st.sidebar.file_uploader("Upload your code file", type=["py", "txt"])
|
| 24 |
if uploaded_file is not None:
|
| 25 |
code_text = uploaded_file.read().decode("utf-8")
|
| 26 |
|
| 27 |
+
model_choice = st.sidebar.selectbox("Select LLM Model", ["llama-3.2-90b-text-preview", "llama-3.2-90b-text-preview", "llama3-8b-8192"])
|
| 28 |
|
| 29 |
+
if st.sidebar.button("Analyze Code") and code_text:
|
| 30 |
llm_obj = LLMClient(client)
|
| 31 |
processor = CodeProcessor(llm_obj)
|
| 32 |
|
logic.py
CHANGED
|
@@ -69,18 +69,18 @@ class CodeProcessor:
|
|
| 69 |
|
| 70 |
**{summary_response}**
|
| 71 |
|
| 72 |
-
|
| 73 |
|
| 74 |
# Detailed Code Explanation for Snippet
|
| 75 |
|
| 76 |
{detail_generation_response}
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
# Similar Code Generation Prompt for Code Snippets
|
| 81 |
|
| 82 |
{prompt_for_generating_similar_code_response}
|
| 83 |
|
| 84 |
-
|
| 85 |
"""
|
| 86 |
return markdown_output
|
|
|
|
| 69 |
|
| 70 |
**{summary_response}**
|
| 71 |
|
| 72 |
+
|
| 73 |
|
| 74 |
# Detailed Code Explanation for Snippet
|
| 75 |
|
| 76 |
{detail_generation_response}
|
| 77 |
|
| 78 |
+
|
| 79 |
|
| 80 |
# Similar Code Generation Prompt for Code Snippets
|
| 81 |
|
| 82 |
{prompt_for_generating_similar_code_response}
|
| 83 |
|
| 84 |
+
|
| 85 |
"""
|
| 86 |
return markdown_output
|