mirror of https://github.com/Mai-with-u/MaiBot.git
<think>之查缺补漏 (#53)
parent
9057f972f7
commit
8e48e72019
|
|
@ -60,8 +60,15 @@ class LLM_request:
|
||||||
|
|
||||||
result = await response.json()
|
result = await response.json()
|
||||||
if "choices" in result and len(result["choices"]) > 0:
|
if "choices" in result and len(result["choices"]) > 0:
|
||||||
content = result["choices"][0]["message"]["content"]
|
message = result["choices"][0]["message"]
|
||||||
reasoning_content = result["choices"][0]["message"].get("reasoning_content", "")
|
content = message.get("content", "")
|
||||||
|
think_match = None
|
||||||
|
reasoning_content = message.get("reasoning_content", "")
|
||||||
|
if not reasoning_content:
|
||||||
|
think_match = re.search(r'<think>(.*?)</think>', content, re.DOTALL)
|
||||||
|
if think_match:
|
||||||
|
reasoning_content = think_match.group(1).strip()
|
||||||
|
content = re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
|
||||||
return content, reasoning_content
|
return content, reasoning_content
|
||||||
return "没有返回结果", ""
|
return "没有返回结果", ""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue