Update app.py
Browse files
app.py
CHANGED
|
@@ -46,9 +46,9 @@ def call_api(message):
|
|
| 46 |
if chunk.strip(): # Ensure the chunk is not empty
|
| 47 |
try:
|
| 48 |
# Parse JSON chunk
|
| 49 |
-
|
| 50 |
if "response" in data:
|
| 51 |
-
|
| 52 |
except json.JSONDecodeError:
|
| 53 |
bot_response += "\nError decoding response chunk."
|
| 54 |
|
|
@@ -81,7 +81,7 @@ if prompt := st.chat_input():
|
|
| 81 |
|
| 82 |
with st.spinner("Translating Dubs language (Woof Woof!)"):
|
| 83 |
assistant_message_placeholder = st.chat_message("assistant").empty()
|
| 84 |
-
response_stream =
|
| 85 |
assistant_message_placeholder.write_stream(response_stream)
|
| 86 |
|
| 87 |
# Append the final assistant's response to the chat history
|
|
|
|
| 46 |
if chunk.strip(): # Ensure the chunk is not empty
|
| 47 |
try:
|
| 48 |
# Parse JSON chunk
|
| 49 |
+
data = json.loads(chunk)
|
| 50 |
if "response" in data:
|
| 51 |
+
yield data["response"]
|
| 52 |
except json.JSONDecodeError:
|
| 53 |
bot_response += "\nError decoding response chunk."
|
| 54 |
|
|
|
|
| 81 |
|
| 82 |
with st.spinner("Translating Dubs language (Woof Woof!)"):
|
| 83 |
assistant_message_placeholder = st.chat_message("assistant").empty()
|
| 84 |
+
response_stream = call_api(prompt)
|
| 85 |
assistant_message_placeholder.write_stream(response_stream)
|
| 86 |
|
| 87 |
# Append the final assistant's response to the chat history
|