yangtb24 commited on
Commit
44634fb
·
verified ·
1 Parent(s): 6e7818d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -425,7 +425,7 @@ def handsome_chat_completions():
425
 
426
  if delta.get("content") is not None:
427
  if not first_reasoning_chunk:
428
- yield f"data: {json.dumps({'choices': [{'delta': {'content': '\n```'}, 'index': 0}]})}\n\n"
429
  first_reasoning_chunk = True
430
  yield f"data: {json.dumps({'choices': [{'delta': {'content': delta["content"]}, 'index': 0}]})}\n\n"
431
 
@@ -525,7 +525,6 @@ def handsome_chat_completions():
525
  content_type="text/event-stream"
526
  )
527
  else:
528
- # ... (Non-streaming part remains the same as in the previous response)
529
  response.raise_for_status()
530
  end_time = time.time()
531
  response_json = response.json()
@@ -597,7 +596,6 @@ def handsome_chat_completions():
597
  request_timestamps.append(time.time())
598
  token_counts.append(prompt_tokens + completion_tokens)
599
 
600
- # Reformat the response to standard OpenAI format for non-streaming responses
601
  formatted_response = {
602
  "id": response_json.get("id", ""),
603
  "object": "chat.completion",
 
425
 
426
  if delta.get("content") is not None:
427
  if not first_reasoning_chunk:
428
+ yield f"data: {json.dumps({'choices': [{'delta': {'content': '\n```\n'}, 'index': 0}]})}\n\n"
429
  first_reasoning_chunk = True
430
  yield f"data: {json.dumps({'choices': [{'delta': {'content': delta["content"]}, 'index': 0}]})}\n\n"
431
 
 
525
  content_type="text/event-stream"
526
  )
527
  else:
 
528
  response.raise_for_status()
529
  end_time = time.time()
530
  response_json = response.json()
 
596
  request_timestamps.append(time.time())
597
  token_counts.append(prompt_tokens + completion_tokens)
598
 
 
599
  formatted_response = {
600
  "id": response_json.get("id", ""),
601
  "object": "chat.completion",