jojd
Browse files
app.py
CHANGED
|
@@ -162,15 +162,16 @@ def chat():
|
|
| 162 |
|
| 163 |
full_response = ""
|
| 164 |
thoughts = ""
|
| 165 |
-
|
| 166 |
for chunk in response_stream:
|
| 167 |
for part in chunk.candidates[0].content.parts:
|
| 168 |
if part.text:
|
| 169 |
-
full_response += part.text
|
| 170 |
-
yield f"data: {json.dumps({'type': 'text', 'content': part.text})}\n\n"
|
| 171 |
if part.thought and thinking_enabled:
|
| 172 |
thoughts += part.text
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
| 174 |
# Ajouter la réponse de l'assistant à l'historique
|
| 175 |
if full_response:
|
| 176 |
add_message_to_history(conversation_id, 'assistant', full_response)
|
|
@@ -269,15 +270,17 @@ def chat_with_file():
|
|
| 269 |
)
|
| 270 |
|
| 271 |
full_response = ""
|
| 272 |
-
|
|
|
|
| 273 |
for chunk in response_stream:
|
| 274 |
for part in chunk.candidates[0].content.parts:
|
| 275 |
if part.text:
|
| 276 |
-
full_response += part.text
|
| 277 |
-
yield f"data: {json.dumps({'type': 'text', 'content': part.text})}\n\n"
|
| 278 |
if part.thought and thinking_enabled:
|
| 279 |
thoughts += part.text
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
| 281 |
# Ajouter la réponse de l'assistant à l'historique
|
| 282 |
if full_response:
|
| 283 |
add_message_to_history(conversation_id, 'assistant', full_response)
|
|
|
|
| 162 |
|
| 163 |
full_response = ""
|
| 164 |
thoughts = ""
|
| 165 |
+
|
| 166 |
for chunk in response_stream:
|
| 167 |
for part in chunk.candidates[0].content.parts:
|
| 168 |
if part.text:
|
|
|
|
|
|
|
| 169 |
if part.thought and thinking_enabled:
|
| 170 |
thoughts += part.text
|
| 171 |
+
yield f"data: {json.dumps({'type': 'thought', 'content': part.text})}\n\n"
|
| 172 |
+
full_response += part.text
|
| 173 |
+
yield f"data: {json.dumps({'type': 'text', 'content': part.text})}\n\n"
|
| 174 |
+
|
| 175 |
# Ajouter la réponse de l'assistant à l'historique
|
| 176 |
if full_response:
|
| 177 |
add_message_to_history(conversation_id, 'assistant', full_response)
|
|
|
|
| 270 |
)
|
| 271 |
|
| 272 |
full_response = ""
|
| 273 |
+
thoughts = ""
|
| 274 |
+
|
| 275 |
for chunk in response_stream:
|
| 276 |
for part in chunk.candidates[0].content.parts:
|
| 277 |
if part.text:
|
|
|
|
|
|
|
| 278 |
if part.thought and thinking_enabled:
|
| 279 |
thoughts += part.text
|
| 280 |
+
yield f"data: {json.dumps({'type': 'thought', 'content': part.text})}\n\n"
|
| 281 |
+
full_response += part.text
|
| 282 |
+
yield f"data: {json.dumps({'type': 'text', 'content': part.text})}\n\n"
|
| 283 |
+
|
| 284 |
# Ajouter la réponse de l'assistant à l'historique
|
| 285 |
if full_response:
|
| 286 |
add_message_to_history(conversation_id, 'assistant', full_response)
|