yangtb24 commited on
Commit
071bdc2
·
verified ·
1 Parent(s): 812f8ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -474,6 +474,7 @@ def handsome_chat_completions():
474
  first_reasoning_chunk = True
475
  response_id = f"chatcmpl-{uuid.uuid4()}"
476
  created_time = int(time.time())
 
477
  for chunk in response.iter_lines():
478
  if chunk:
479
  if first_chunk_time is None:
@@ -500,6 +501,12 @@ def handsome_chat_completions():
500
 
501
  if delta.get("reasoning_content") is not None:
502
  if first_reasoning_chunk:
 
 
 
 
 
 
503
  openai_chunk["choices"][0]["delta"]["content"] = "<think>\n"
504
  openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
505
  yield f"data: {json.dumps(openai_chunk)}\n\n"
 
474
  first_reasoning_chunk = True
475
  response_id = f"chatcmpl-{uuid.uuid4()}"
476
  created_time = int(time.time())
477
+
478
  for chunk in response.iter_lines():
479
  if chunk:
480
  if first_chunk_time is None:
 
501
 
502
  if delta.get("reasoning_content") is not None:
503
  if first_reasoning_chunk:
504
+ first_chunk = openai_chunk.copy()
505
+
506
+ first_chunk["choices"][0]["delta"]["content"] = ""
507
+ first_chunk["choices"][0]["delta"]["reasoning_content"] = ""
508
+ yield f"data: {json.dumps(first_chunk)}\n\n"
509
+
510
  openai_chunk["choices"][0]["delta"]["content"] = "<think>\n"
511
  openai_chunk["choices"][0]["delta"]["reasoning_content"] = None
512
  yield f"data: {json.dumps(openai_chunk)}\n\n"