yangtb24 commited on
Commit
5dc5286
·
verified ·
1 Parent(s): 52d6899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -539,12 +539,16 @@ def handsome_chat_completions():
539
  completion_tokens = response_json["usage"]["completion_tokens"]
540
  response_content = ""
541
 
542
- # Special handling for deepseek-reasoner in non-streaming mode
543
  if model_name == "deepseek-reasoner" and "choices" in response_json and len(response_json["choices"]) > 0:
544
  choice = response_json["choices"][0]
545
  if "message" in choice:
546
  if "reasoning_content" in choice["message"]:
547
- formatted_reasoning = f"```Thinking\n{choice['message']['reasoning_content']}\n```"
 
 
 
 
 
548
  response_content += formatted_reasoning + "\n"
549
  if "content" in choice["message"]:
550
  response_content += choice["message"]["content"]
 
539
  completion_tokens = response_json["usage"]["completion_tokens"]
540
  response_content = ""
541
 
 
542
  if model_name == "deepseek-reasoner" and "choices" in response_json and len(response_json["choices"]) > 0:
543
  choice = response_json["choices"][0]
544
  if "message" in choice:
545
  if "reasoning_content" in choice["message"]:
546
+ reasoning_chunk = delta["reasoning_content"]
547
+ reasoning_chunk = reasoning_chunk.replace('\n', '\n> ')
548
+ if first_reasoning_chunk:
549
+ reasoning_chunk = "> " + reasoning_chunk
550
+ first_reasoning_chunk = False
551
+ formatted_reasoning = f"```Thinking\n{choice['message']['reasoning_chunk']}\n```"
552
  response_content += formatted_reasoning + "\n"
553
  if "content" in choice["message"]:
554
  response_content += choice["message"]["content"]