Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,8 +69,8 @@ def stream_chat(
|
|
69 |
):
|
70 |
# Prepare the conversation context
|
71 |
conversation_text = system_prompt + "\n"
|
72 |
-
for
|
73 |
-
conversation_text += f"
|
74 |
|
75 |
conversation_text += f"User: {message}\nMisMath:"
|
76 |
|
@@ -95,14 +95,13 @@ def stream_chat(
|
|
95 |
thread.start()
|
96 |
|
97 |
buffer = ""
|
|
|
98 |
for new_text in streamer:
|
99 |
buffer += new_text
|
100 |
-
#
|
101 |
if "MisMath:" in buffer:
|
102 |
-
|
103 |
-
|
104 |
-
else:
|
105 |
-
yield buffer.strip()
|
106 |
|
107 |
# Define the Gradio chatbot component
|
108 |
chatbot = gr.Chatbot(height=500, placeholder=PLACEHOLDER)
|
|
|
69 |
):
|
70 |
# Prepare the conversation context
|
71 |
conversation_text = system_prompt + "\n"
|
72 |
+
for _, answer in history:
|
73 |
+
conversation_text += f"MisMath: {answer}\n"
|
74 |
|
75 |
conversation_text += f"User: {message}\nMisMath:"
|
76 |
|
|
|
95 |
thread.start()
|
96 |
|
97 |
buffer = ""
|
98 |
+
final_output = ""
|
99 |
for new_text in streamer:
|
100 |
buffer += new_text
|
101 |
+
# Extract only the final response after the last "MisMath:"
|
102 |
if "MisMath:" in buffer:
|
103 |
+
final_output = buffer.split("MisMath:")[-1].strip()
|
104 |
+
yield final_output
|
|
|
|
|
105 |
|
106 |
# Define the Gradio chatbot component
|
107 |
chatbot = gr.Chatbot(height=500, placeholder=PLACEHOLDER)
|