Update app_chat.py
Browse files- app_chat.py +16 -2
app_chat.py
CHANGED
|
@@ -48,6 +48,8 @@ def app_chat(agent_config):
|
|
| 48 |
# Handle submission with the selected inference URL
|
| 49 |
#app_agent_config()
|
| 50 |
|
|
|
|
|
|
|
| 51 |
with st.spinner('Please stand by ...'):
|
| 52 |
|
| 53 |
response = handle_submission(user_message, selected_tools, agent_config.url_endpoint, agent_config.document, agent_config.image, agent_config.context)
|
|
@@ -64,7 +66,7 @@ def app_chat(agent_config):
|
|
| 64 |
st.image(response)
|
| 65 |
elif isinstance(response, AudioSegment):
|
| 66 |
agent_config.audio = response
|
| 67 |
-
chat_respone = handle_submission_chat(user_message, "
|
| 68 |
st.write(chat_respone)
|
| 69 |
st.audio(response)
|
| 70 |
elif isinstance(response, int):
|
|
@@ -73,7 +75,7 @@ def app_chat(agent_config):
|
|
| 73 |
st.markdown(response)
|
| 74 |
elif isinstance(response, str):
|
| 75 |
if "emojified_text" in response:
|
| 76 |
-
chat_respone = handle_submission_chat(user_message, "
|
| 77 |
st.write(chat_respone)
|
| 78 |
st.markdown(f"{response['emojified_text']}")
|
| 79 |
else:
|
|
@@ -81,30 +83,42 @@ def app_chat(agent_config):
|
|
| 81 |
st.write(chat_respone)
|
| 82 |
st.markdown(response)
|
| 83 |
elif isinstance(response, list):
|
|
|
|
| 84 |
for item in response:
|
| 85 |
st.markdown(item) # Assuming the list contains strings
|
| 86 |
elif isinstance(response, pd.DataFrame):
|
|
|
|
| 87 |
st.dataframe(response)
|
| 88 |
elif isinstance(response, pd.Series):
|
|
|
|
| 89 |
st.table(response.iloc[0:10])
|
| 90 |
elif isinstance(response, dict):
|
|
|
|
| 91 |
st.json(response)
|
| 92 |
elif isinstance(response, st.graphics_altair.AltairChart):
|
|
|
|
| 93 |
st.altair_chart(response)
|
| 94 |
elif isinstance(response, st.graphics_bokeh.BokehChart):
|
|
|
|
| 95 |
st.bokeh_chart(response)
|
| 96 |
elif isinstance(response, st.graphics_graphviz.GraphvizChart):
|
|
|
|
| 97 |
st.graphviz_chart(response)
|
| 98 |
elif isinstance(response, st.graphics_plotly.PlotlyChart):
|
|
|
|
| 99 |
st.plotly_chart(response)
|
| 100 |
elif isinstance(response, st.graphics_pydeck.PydeckChart):
|
|
|
|
| 101 |
st.pydeck_chart(response)
|
| 102 |
elif isinstance(response, matplotlib.figure.Figure):
|
|
|
|
| 103 |
st.pyplot(response)
|
| 104 |
elif isinstance(response, streamlit.graphics_vega_lite.VegaLiteChart):
|
|
|
|
| 105 |
st.vega_lite_chart(response)
|
| 106 |
else:
|
| 107 |
st.warning("Unrecognized response type. Please try again. e.g. Generate an image of a flying horse.")
|
| 108 |
|
|
|
|
| 109 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 110 |
|
|
|
|
| 48 |
# Handle submission with the selected inference URL
|
| 49 |
#app_agent_config()
|
| 50 |
|
| 51 |
+
response = ""
|
| 52 |
+
chat_response = ""
|
| 53 |
with st.spinner('Please stand by ...'):
|
| 54 |
|
| 55 |
response = handle_submission(user_message, selected_tools, agent_config.url_endpoint, agent_config.document, agent_config.image, agent_config.context)
|
|
|
|
| 66 |
st.image(response)
|
| 67 |
elif isinstance(response, AudioSegment):
|
| 68 |
agent_config.audio = response
|
| 69 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool created audio file.")
|
| 70 |
st.write(chat_respone)
|
| 71 |
st.audio(response)
|
| 72 |
elif isinstance(response, int):
|
|
|
|
| 75 |
st.markdown(response)
|
| 76 |
elif isinstance(response, str):
|
| 77 |
if "emojified_text" in response:
|
| 78 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool created the text with emojies.")
|
| 79 |
st.write(chat_respone)
|
| 80 |
st.markdown(f"{response['emojified_text']}")
|
| 81 |
else:
|
|
|
|
| 83 |
st.write(chat_respone)
|
| 84 |
st.markdown(response)
|
| 85 |
elif isinstance(response, list):
|
| 86 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a list")
|
| 87 |
for item in response:
|
| 88 |
st.markdown(item) # Assuming the list contains strings
|
| 89 |
elif isinstance(response, pd.DataFrame):
|
| 90 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a pd.DataFrame")
|
| 91 |
st.dataframe(response)
|
| 92 |
elif isinstance(response, pd.Series):
|
| 93 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a pd.Series")
|
| 94 |
st.table(response.iloc[0:10])
|
| 95 |
elif isinstance(response, dict):
|
| 96 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a dict")
|
| 97 |
st.json(response)
|
| 98 |
elif isinstance(response, st.graphics_altair.AltairChart):
|
| 99 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a st.graphics_altair.AltairChart")
|
| 100 |
st.altair_chart(response)
|
| 101 |
elif isinstance(response, st.graphics_bokeh.BokehChart):
|
| 102 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a st.graphics_bokeh.BokehChart")
|
| 103 |
st.bokeh_chart(response)
|
| 104 |
elif isinstance(response, st.graphics_graphviz.GraphvizChart):
|
| 105 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a st.graphics_graphviz.GraphvizChart")
|
| 106 |
st.graphviz_chart(response)
|
| 107 |
elif isinstance(response, st.graphics_plotly.PlotlyChart):
|
| 108 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a st.graphics_plotly.PlotlyChart")
|
| 109 |
st.plotly_chart(response)
|
| 110 |
elif isinstance(response, st.graphics_pydeck.PydeckChart):
|
| 111 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a st.graphics_pydeck.PydeckChart")
|
| 112 |
st.pydeck_chart(response)
|
| 113 |
elif isinstance(response, matplotlib.figure.Figure):
|
| 114 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a matplotlib.figure.Figure")
|
| 115 |
st.pyplot(response)
|
| 116 |
elif isinstance(response, streamlit.graphics_vega_lite.VegaLiteChart):
|
| 117 |
+
chat_respone = handle_submission_chat(user_message, "Agent Tool produced a VegaLiteChart")
|
| 118 |
st.vega_lite_chart(response)
|
| 119 |
else:
|
| 120 |
st.warning("Unrecognized response type. Please try again. e.g. Generate an image of a flying horse.")
|
| 121 |
|
| 122 |
+
st.session_state.messages.append({"role": "assistant", "content": chat_response})
|
| 123 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 124 |
|