hunyuan-t commited on
Commit
5ecc655
Β·
verified Β·
1 Parent(s): 7993b36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -44,17 +44,21 @@ def respond(
44
  }
45
  )
46
  response = ""
 
47
  is_reasoning_end = True
 
48
 
49
- for index, event in enumerate(completion):
50
  if hasattr(event.choices[0].delta, 'reasoning_content'):
51
- separator = '--- **开始思考** ---' if index == 0 else ''
52
- response += separator + '\n'
53
- token = f'<span style="color: #1e88e5; background-color: #e8f5e9; padding: 2px 4px; border-radius: 3px;">{event.choices[0].delta.reasoning_content}</span>'
 
54
  else:
55
- response += '--- **η»“ζŸζ€θ€ƒ** ---\n'
56
- token = f'<span style="color: #43a047; background-color: #f1f8e9; padding: 2px 4px; border-radius: 3px;">{event.choices[0].delta.content}</span>'
57
- response += token + '\n'
 
58
  yield response
59
  except Exception as e:
60
  raise gr.Error(f"ε‘η”Ÿι”™θ――: {str(e)}")
 
44
  }
45
  )
46
  response = ""
47
+ is_reasoning_start = True
48
  is_reasoning_end = True
49
+
50
 
51
+ for event in completion:
52
  if hasattr(event.choices[0].delta, 'reasoning_content'):
53
+ if is_reasoning_start:
54
+ response += '> **开始思考**\n\n'
55
+ is_reasoning_start = False
56
+ token = event.choices[0].delta.reasoning_content
57
  else:
58
+ if is_reasoning_end:
59
+ response += '> **η»“ζŸζ€θ€ƒ**\n\n'
60
+ is_reasoning_end = False
61
+ token = event.choices[0].delta.content
62
  yield response
63
  except Exception as e:
64
  raise gr.Error(f"ε‘η”Ÿι”™θ――: {str(e)}")