SandeepU commited on
Commit
782b268
Β·
verified Β·
1 Parent(s): 9ca2989

Upload 3 files

Browse files
Files changed (2) hide show
  1. README.md +7 -7
  2. streamlit_app.py +4 -12
README.md CHANGED
@@ -1,19 +1,19 @@
1
  ---
2
  title: Code Explainer πŸ’‘
3
  emoji: 🧠
4
- colorFrom: indigo
5
- colorTo: purple
6
  sdk: streamlit
7
  sdk_version: "1.35.0"
8
  app_file: streamlit_app.py
9
  pinned: false
10
  ---
11
 
12
- # 🧠 Code Explainer (Codet5 Version – Prompt Fixed)
13
 
14
- This app uses `Salesforce/codet5-base` to explain Python code snippets in plain English using task prompts.
15
 
16
- ## βœ… How to Use
17
- 1. Paste Python code in the box
18
  2. Click "Explain"
19
- 3. Get step-by-step plain English explanation
 
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 plain English explanation:")
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
- prompt = build_prompt(code_input)
17
- st.subheader("πŸ” Prompt Sent to Model")
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.")