Update app.py
Browse files
app.py
CHANGED
@@ -507,11 +507,27 @@ def handsome_chat_completions():
|
|
507 |
first_chunk["choices"][0]["delta"]["reasoning_content"] = ""
|
508 |
first_chunk["choices"][0]["delta"]["role"] = "assistant"
|
509 |
yield f"data: {json.dumps(first_chunk)}\n\n"
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
first_reasoning_chunk = False
|
|
|
|
|
|
|
|
|
|
|
515 |
else:
|
516 |
openai_chunk["choices"][0]["delta"]["content"] = delta["reasoning_content"]
|
517 |
openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
@@ -520,7 +536,7 @@ def handsome_chat_completions():
|
|
520 |
|
521 |
if delta.get("content") is not None:
|
522 |
if not first_reasoning_chunk:
|
523 |
-
openai_chunk["choices"][0]["delta"]["content"] = "\n</
|
524 |
openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
525 |
yield f"data: {json.dumps(openai_chunk)}\n\n"
|
526 |
first_reasoning_chunk = True
|
|
|
507 |
first_chunk["choices"][0]["delta"]["reasoning_content"] = ""
|
508 |
first_chunk["choices"][0]["delta"]["role"] = "assistant"
|
509 |
yield f"data: {json.dumps(first_chunk)}\n\n"
|
510 |
+
|
511 |
+
openai1_chunk = openai_chunk.copy()
|
512 |
+
openai2_chunk = openai_chunk.copy()
|
513 |
+
openai3_chunk = openai_chunk.copy()
|
514 |
+
|
515 |
+
openai1_chunk["choices"][0]["delta"]["content"] = "<"
|
516 |
+
openai2_chunk["choices"][0]["delta"]["content"] = "think"
|
517 |
+
openai3_chunk["choices"][0]["delta"]["content"] = ">\n"
|
518 |
+
openai1_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
519 |
+
openai2_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
520 |
+
openai3_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
521 |
+
|
522 |
+
yield f"data: {json.dumps(openai1_chunk)}\n\n"
|
523 |
+
yield f"data: {json.dumps(openai2_chunk)}\n\n"
|
524 |
+
yield f"data: {json.dumps(openai3_chunk)}\n\n"
|
525 |
first_reasoning_chunk = False
|
526 |
+
|
527 |
+
# openai_chunk["choices"][0]["delta"]["content"] = "<think>\n"
|
528 |
+
# openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
529 |
+
# yield f"data: {json.dumps(openai_chunk)}\n\n"
|
530 |
+
# first_reasoning_chunk = False
|
531 |
else:
|
532 |
openai_chunk["choices"][0]["delta"]["content"] = delta["reasoning_content"]
|
533 |
openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
|
|
536 |
|
537 |
if delta.get("content") is not None:
|
538 |
if not first_reasoning_chunk:
|
539 |
+
openai_chunk["choices"][0]["delta"]["content"] = "\n</think>\n"
|
540 |
openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
|
541 |
yield f"data: {json.dumps(openai_chunk)}\n\n"
|
542 |
first_reasoning_chunk = True
|