yangtb24 commited on
Commit
5c7a32d
·
verified ·
1 Parent(s): 481e2c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -471,9 +471,6 @@ def handsome_chat_completions():
471
  reasoning_content_accumulated = ""
472
  content_accumulated = ""
473
  first_reasoning_chunk = True
474
-
475
-
476
- yield f"data: {json.dumps({'choices': [{'delta': {'content': ''}, 'index': 0}]})}\n\n"
477
 
478
  for chunk in response.iter_lines():
479
  if chunk:
@@ -493,14 +490,14 @@ def handsome_chat_completions():
493
  if first_reasoning_chunk:
494
  reasoning_chunk = f"<think>\n{reasoning_chunk}"
495
  first_reasoning_chunk = False
496
- yield f"data: {json.dumps({'choices': [{'delta': {'content': reasoning_chunk}, 'index': 0}]})}\n\n"
497
 
498
  if delta.get("content") is not None:
499
  if not first_reasoning_chunk:
500
  reasoning_chunk = f"\n</think>\n"
501
- yield f"data: {json.dumps({'choices': [{'delta': {'content': reasoning_chunk}, 'index': 0}]})}\n\n"
502
  first_reasoning_chunk = True
503
- yield f"data: {json.dumps({'choices': [{'delta': {'content': delta["content"]}, 'index': 0}]})}\n\n"
504
 
505
  except (KeyError, ValueError, json.JSONDecodeError) as e:
506
  continue
 
471
  reasoning_content_accumulated = ""
472
  content_accumulated = ""
473
  first_reasoning_chunk = True
 
 
 
474
 
475
  for chunk in response.iter_lines():
476
  if chunk:
 
490
  if first_reasoning_chunk:
491
  reasoning_chunk = f"<think>\n{reasoning_chunk}"
492
  first_reasoning_chunk = False
493
+ yield f"data: {json.dumps({'choices': [{'delta': {'content': reasoning_chunk, 'reasoning_content': null}, 'index': 0}]})}\n\n"
494
 
495
  if delta.get("content") is not None:
496
  if not first_reasoning_chunk:
497
  reasoning_chunk = f"\n</think>\n"
498
+ yield f"data: {json.dumps({'choices': [{'delta': {'content': reasoning_chunk, 'reasoning_content': null}, 'index': 0}]})}\n\n"
499
  first_reasoning_chunk = True
500
+ yield f"data: {json.dumps({'choices': [{'delta': {'content': delta["content"], 'reasoning_content': null}, 'index': 0}]})}\n\n"
501
 
502
  except (KeyError, ValueError, json.JSONDecodeError) as e:
503
  continue