Spaces:
Sleeping
Sleeping
import streamlit as st | |
from model.model_utils import load_model, generate_explanation | |
from prompt_utils import build_prompt | |
st.set_page_config(page_title="Code Explainer", layout="centered") | |
st.title("π§ Code Explainer") | |
st.write("Paste your Python code below and get a plain English explanation:") | |
code_input = st.text_area("Paste Python Code", height=200) | |
if st.button("Explain"): | |
if code_input.strip(): | |
with st.spinner("Generating explanation..."): | |
tokenizer, model, device = load_model() | |
prompt = build_prompt(code_input) | |
st.subheader("π Prompt Sent to Model") | |
st.code(prompt) | |
explanation = generate_explanation(prompt, tokenizer, model, device) | |
st.subheader("π Raw Output from Model") | |
st.code(explanation) | |
st.subheader("β Final Explanation") | |
st.write(explanation.split("Explanation:")[-1].strip()) | |
else: | |
st.warning("Please paste some code to explain.") | |