nanova commited on
Commit
9cb8eea
·
1 Parent(s): 8709f65
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -67,13 +67,16 @@ def respond(
67
  if r.status_code == 200:
68
  json_response = r.json()
69
  if 'choices' in json_response and len(json_response['choices']) > 0:
70
- response = json_response['choices'][0].get('message', {}).get('content', '')
71
- if response:
72
- print(f"[INFO] API response content: {response}")
73
- return response
 
 
 
74
  else:
75
- print("[ERROR] No content found in API response")
76
- return "No content in the response"
77
  else:
78
  print("[ERROR] No choices found in API response")
79
  return "No choices in the response"
 
67
  if r.status_code == 200:
68
  json_response = r.json()
69
  if 'choices' in json_response and len(json_response['choices']) > 0:
70
+ response_content = json_response['choices'][0].get('message', {}).get('content', '')
71
+ # 去掉<think>标签及其内容
72
+ import re
73
+ clean_response = re.sub(r'<think>.*?</think>', '', response_content).strip()
74
+ if clean_response:
75
+ print(f"[INFO] Cleaned API response content: {clean_response}")
76
+ return clean_response
77
  else:
78
+ print("[ERROR] No cleaned content found in API response")
79
+ return "No content in the response after cleaning"
80
  else:
81
  print("[ERROR] No choices found in API response")
82
  return "No choices in the response"