Illia56 commited on
Commit
182e542
·
1 Parent(s): 6038be0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -33,9 +33,8 @@ def predict(message):
33
  st.write("Checking images...")
34
  for i in response['images']:
35
  st.image(i)
36
- if response['code']:
37
- exec(response['code'])
38
- return response['content']
39
 
40
  # Streamlit UI
41
  st.title(TITLE)
@@ -60,6 +59,17 @@ if prompt := st.chat_input("Ask Palm 2 anything..."):
60
  response = predict(prompt)
61
  # Display assistant response in chat message container
62
  with st.chat_message("assistant", avatar='🌴'):
63
- st.markdown(response)
 
 
 
 
 
 
 
 
 
 
 
64
  # Add assistant response to chat history
65
  st.session_state.messages.append({"role": "assistant", "content": response})
 
33
  st.write("Checking images...")
34
  for i in response['images']:
35
  st.image(i)
36
+
37
+ return response
 
38
 
39
  # Streamlit UI
40
  st.title(TITLE)
 
59
  response = predict(prompt)
60
  # Display assistant response in chat message container
61
  with st.chat_message("assistant", avatar='🌴'):
62
+ st.markdown(response['content'])
63
+
64
+ if response['code']:
65
+ if st.button('Run Code')
66
+ with st.status("Running code..."):
67
+ try:
68
+ exec(response['code'])
69
+ except Exception as e:
70
+ st.write(f"ERROR {e}...")
71
+
72
+
73
+
74
  # Add assistant response to chat history
75
  st.session_state.messages.append({"role": "assistant", "content": response})