Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,6 +32,7 @@ class State(TypedDict):
|
|
| 32 |
input : str
|
| 33 |
code : str
|
| 34 |
explanation:str
|
|
|
|
| 35 |
|
| 36 |
# LLM
|
| 37 |
# llm = ChatGroq(model="deepseek-r1-distill-llama-70b")
|
|
@@ -143,7 +144,7 @@ def explain_code(state):
|
|
| 143 |
full_prompt = system_prompt + prompt
|
| 144 |
explanation = code_generator.invoke(full_prompt)
|
| 145 |
|
| 146 |
-
return {
|
| 147 |
|
| 148 |
|
| 149 |
|
|
@@ -154,6 +155,7 @@ def router(state):
|
|
| 154 |
return "Generate_Code"
|
| 155 |
else:
|
| 156 |
return "AI_Assistance"
|
|
|
|
| 157 |
def execute_code(state: State) -> State:
|
| 158 |
code = state.get("code", "")
|
| 159 |
buffer = io.StringIO()
|
|
@@ -248,6 +250,11 @@ if "latest_explanation" in st.session_state:
|
|
| 248 |
with st.expander("π Show Code Explanation"):
|
| 249 |
st.markdown(f"<div class='stChatMessage bot'>**π Code Explanation:**<br><br>{st.session_state.latest_explanation}</div>", unsafe_allow_html=True)
|
| 250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
# Custom Chat Input Box UI
|
| 252 |
with st.container():
|
| 253 |
with st.form("chat_form", clear_on_submit=True):
|
|
|
|
| 32 |
input : str
|
| 33 |
code : str
|
| 34 |
explanation:str
|
| 35 |
+
execution_result=str
|
| 36 |
|
| 37 |
# LLM
|
| 38 |
# llm = ChatGroq(model="deepseek-r1-distill-llama-70b")
|
|
|
|
| 144 |
full_prompt = system_prompt + prompt
|
| 145 |
explanation = code_generator.invoke(full_prompt)
|
| 146 |
|
| 147 |
+
return {**state, "explanation": explanation}
|
| 148 |
|
| 149 |
|
| 150 |
|
|
|
|
| 155 |
return "Generate_Code"
|
| 156 |
else:
|
| 157 |
return "AI_Assistance"
|
| 158 |
+
|
| 159 |
def execute_code(state: State) -> State:
|
| 160 |
code = state.get("code", "")
|
| 161 |
buffer = io.StringIO()
|
|
|
|
| 250 |
with st.expander("π Show Code Explanation"):
|
| 251 |
st.markdown(f"<div class='stChatMessage bot'>**π Code Explanation:**<br><br>{st.session_state.latest_explanation}</div>", unsafe_allow_html=True)
|
| 252 |
|
| 253 |
+
if "latest_code" in st.session_state:
|
| 254 |
+
with st.expander("π» Show Generated Code"):
|
| 255 |
+
st.code(st.session_state.latest_code, language="python")
|
| 256 |
+
|
| 257 |
+
|
| 258 |
# Custom Chat Input Box UI
|
| 259 |
with st.container():
|
| 260 |
with st.form("chat_form", clear_on_submit=True):
|