Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- README.md +7 -7
- streamlit_app.py +4 -12
README.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
---
|
2 |
title: Code Explainer π‘
|
3 |
emoji: π§
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
sdk_version: "1.35.0"
|
8 |
app_file: streamlit_app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
# π§ Code Explainer (
|
13 |
|
14 |
-
This app uses `
|
15 |
|
16 |
-
##
|
17 |
-
1. Paste Python code
|
18 |
2. Click "Explain"
|
19 |
-
3. Get
|
|
|
1 |
---
|
2 |
title: Code Explainer π‘
|
3 |
emoji: π§
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: blue
|
6 |
sdk: streamlit
|
7 |
sdk_version: "1.35.0"
|
8 |
app_file: streamlit_app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
# π§ Code Explainer (CodeBERT Version)
|
13 |
|
14 |
+
This app uses `mrm8488/codebert-base-finetuned-stackoverflow` to analyze and classify Python code.
|
15 |
|
16 |
+
## How to Use
|
17 |
+
1. Paste Python code
|
18 |
2. Click "Explain"
|
19 |
+
3. Get an AI-generated summary or label
|
streamlit_app.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
from model.model_utils import load_model, generate_explanation
|
3 |
-
from prompt_utils import build_prompt
|
4 |
|
5 |
st.set_page_config(page_title="Code Explainer", layout="centered")
|
6 |
|
7 |
-
st.title("π§ Code Explainer")
|
8 |
-
st.write("Paste your Python code below and get a
|
9 |
|
10 |
code_input = st.text_area("Paste Python Code", height=200)
|
11 |
|
@@ -13,15 +12,8 @@ if st.button("Explain"):
|
|
13 |
if code_input.strip():
|
14 |
with st.spinner("Generating explanation..."):
|
15 |
tokenizer, model, device = load_model()
|
16 |
-
|
17 |
-
st.subheader("
|
18 |
-
st.code(prompt)
|
19 |
-
|
20 |
-
explanation = generate_explanation(prompt, tokenizer, model, device)
|
21 |
-
st.subheader("π Raw Output from Model")
|
22 |
-
st.code(explanation)
|
23 |
-
|
24 |
-
st.subheader("β
Final Explanation")
|
25 |
st.write(explanation)
|
26 |
else:
|
27 |
st.warning("Please paste some code to explain.")
|
|
|
1 |
import streamlit as st
|
2 |
from model.model_utils import load_model, generate_explanation
|
|
|
3 |
|
4 |
st.set_page_config(page_title="Code Explainer", layout="centered")
|
5 |
|
6 |
+
st.title("π§ Code Explainer (CodeBERT)")
|
7 |
+
st.write("Paste your Python code below and get a natural language explanation:")
|
8 |
|
9 |
code_input = st.text_area("Paste Python Code", height=200)
|
10 |
|
|
|
12 |
if code_input.strip():
|
13 |
with st.spinner("Generating explanation..."):
|
14 |
tokenizer, model, device = load_model()
|
15 |
+
explanation = generate_explanation(code_input, tokenizer, model, device)
|
16 |
+
st.subheader("β
Explanation")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
st.write(explanation)
|
18 |
else:
|
19 |
st.warning("Please paste some code to explain.")
|