Spaces:
Running
Running
update
Browse files
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 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
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"
|