Update app.py
Browse files
app.py
CHANGED
@@ -91,16 +91,40 @@ def handle_submission():
|
|
91 |
#response = agent.run(message, tools=selected_tools)
|
92 |
response = agent.run(message)
|
93 |
|
|
|
|
|
94 |
# Display the agent's response
|
95 |
-
|
96 |
-
if response.startswith("Image:"):
|
97 |
-
# Display the image response
|
98 |
-
image_data = base64.b64decode(response.split(",")[1])
|
99 |
-
img = Image.open(io.BytesIO(image_data))
|
100 |
-
st.image(img)
|
101 |
-
else:
|
102 |
# Display the text response
|
103 |
st.write(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# Add a button to trigger the agent to respond again
|
106 |
#st.button("Ask Again
|
|
|
91 |
#response = agent.run(message, tools=selected_tools)
|
92 |
response = agent.run(message)
|
93 |
|
94 |
+
print(response)
|
95 |
+
|
96 |
# Display the agent's response
|
97 |
+
if isinstance(response, str):
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
# Display the text response
|
99 |
st.write(response)
|
100 |
+
elif isinstance(response, dict):
|
101 |
+
# Check for image, audio, or other types dynamically
|
102 |
+
response_keys = response.keys()
|
103 |
+
|
104 |
+
if "Image" in response_keys:
|
105 |
+
# Display the image response
|
106 |
+
image_data = base64.b64decode(response["Image"].split(",")[1])
|
107 |
+
img = Image.open(io.BytesIO(image_data))
|
108 |
+
st.image(img)
|
109 |
+
elif "Audio" in response_keys:
|
110 |
+
# Handle audio response (replace with your audio rendering code)
|
111 |
+
st.audio(response["Audio"])
|
112 |
+
# Add more conditions for other types if needed
|
113 |
+
else:
|
114 |
+
# Handle unrecognized response type
|
115 |
+
st.warning("Unrecognized response type.")
|
116 |
+
|
117 |
+
|
118 |
+
# Display the agent's response
|
119 |
+
# Display the agent's response
|
120 |
+
#if response.startswith("Image:"):
|
121 |
+
# # Display the image response
|
122 |
+
# image_data = base64.b64decode(response.split(",")[1])
|
123 |
+
# img = Image.open(io.BytesIO(image_data))
|
124 |
+
# st.image(img)
|
125 |
+
#else:
|
126 |
+
# # Display the text response
|
127 |
+
# st.write(response)
|
128 |
|
129 |
# Add a button to trigger the agent to respond again
|
130 |
#st.button("Ask Again
|