Update app.py
Browse files
app.py
CHANGED
@@ -87,23 +87,19 @@ if prompt := st.chat_input("Ask Palm 2 anything..."):
|
|
87 |
exec(current_code)
|
88 |
break # If successful, break out of the loop
|
89 |
except Exception as e:
|
90 |
-
st.write(f"ERROR {e}...")
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
with st.chat_message("assistant", avatar='🌴'):
|
98 |
st.markdown(new_response['content'])
|
99 |
|
100 |
-
st.session_state.messages.append({"role": "assistant", "content": new_response['content']})
|
101 |
-
|
102 |
-
# Update the current code with the new response and increment the attempt counter
|
103 |
current_code = new_response['code']
|
104 |
current_attempt += 1
|
105 |
|
106 |
if current_attempt == MAX_ATTEMPTS:
|
107 |
-
st.
|
108 |
|
109 |
st.session_state.messages.append({"role": "assistant", "content": response['content']})
|
|
|
87 |
exec(current_code)
|
88 |
break # If successful, break out of the loop
|
89 |
except Exception as e:
|
|
|
90 |
|
91 |
+
st.error("Error running code...")
|
92 |
+
new_prompt = f"{prompt} . There was an error executing the code: {e}. The last code you provided was: ```{current_code}```. Can you provide a corrected version?"
|
93 |
+
new_response = predict(new_prompt)
|
94 |
+
st.success('Code run succesfully!', icon="✅")
|
95 |
|
96 |
with st.chat_message("assistant", avatar='🌴'):
|
97 |
st.markdown(new_response['content'])
|
98 |
|
|
|
|
|
|
|
99 |
current_code = new_response['code']
|
100 |
current_attempt += 1
|
101 |
|
102 |
if current_attempt == MAX_ATTEMPTS:
|
103 |
+
st.warning("Reached maximum attempts. Unable to execute the code successfully.")
|
104 |
|
105 |
st.session_state.messages.append({"role": "assistant", "content": response['content']})
|