Update app.py
Browse files
app.py
CHANGED
|
@@ -367,14 +367,12 @@ def count_message_tokens(messages, model="gpt-3.5-turbo-0301"):
|
|
| 367 |
|
| 368 |
def stream_notdiamond_response(response, model):
|
| 369 |
"""流式处理 notdiamond API 响应。"""
|
| 370 |
-
|
| 371 |
for chunk in response.iter_content(1024):
|
| 372 |
if chunk:
|
| 373 |
new_content = chunk.decode('utf-8')
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
yield create_openai_chunk(to_send, model)
|
| 377 |
-
last_sent = new_content
|
| 378 |
|
| 379 |
yield create_openai_chunk('', model, 'stop')
|
| 380 |
|
|
|
|
| 367 |
|
| 368 |
def stream_notdiamond_response(response, model):
|
| 369 |
"""流式处理 notdiamond API 响应。"""
|
| 370 |
+
buffer = ""
|
| 371 |
for chunk in response.iter_content(1024):
|
| 372 |
if chunk:
|
| 373 |
new_content = chunk.decode('utf-8')
|
| 374 |
+
buffer += new_content
|
| 375 |
+
yield create_openai_chunk(new_content, model)
|
|
|
|
|
|
|
| 376 |
|
| 377 |
yield create_openai_chunk('', model, 'stop')
|
| 378 |
|