<think>之我的LLM为什么只有一半TAG
This commit is contained in:
@@ -36,6 +36,7 @@ class LLM_request:
|
|||||||
data = {
|
data = {
|
||||||
"model": self.model_name,
|
"model": self.model_name,
|
||||||
"messages": [{"role": "user", "content": prompt}],
|
"messages": [{"role": "user", "content": prompt}],
|
||||||
|
"max_tokens": 8000,
|
||||||
**self.params
|
**self.params
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +66,10 @@ class LLM_request:
|
|||||||
think_match = None
|
think_match = None
|
||||||
reasoning_content = message.get("reasoning_content", "")
|
reasoning_content = message.get("reasoning_content", "")
|
||||||
if not reasoning_content:
|
if not reasoning_content:
|
||||||
think_match = re.search(r'<think>(.*?)</think>', content, re.DOTALL)
|
think_match = re.search(r'(?:<think>)?(.*?)</think>', content, re.DOTALL)
|
||||||
if think_match:
|
if think_match:
|
||||||
reasoning_content = think_match.group(1).strip()
|
reasoning_content = think_match.group(1).strip()
|
||||||
content = re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
|
content = re.sub(r'(?:<think>)?.*?</think>', '', content, flags=re.DOTALL, count=1).strip()
|
||||||
return content, reasoning_content
|
return content, reasoning_content
|
||||||
return "没有返回结果", ""
|
return "没有返回结果", ""
|
||||||
|
|
||||||
@@ -112,6 +113,7 @@ class LLM_request:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"max_tokens": 8000,
|
||||||
**self.params
|
**self.params
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,10 +153,10 @@ class LLM_request:
|
|||||||
think_match = None
|
think_match = None
|
||||||
reasoning_content = message.get("reasoning_content", "")
|
reasoning_content = message.get("reasoning_content", "")
|
||||||
if not reasoning_content:
|
if not reasoning_content:
|
||||||
think_match = re.search(r'<think>(.*?)</think>', content, re.DOTALL)
|
think_match = re.search(r'(?:<think>)?(.*?)</think>', content, re.DOTALL)
|
||||||
if think_match:
|
if think_match:
|
||||||
reasoning_content = think_match.group(1).strip()
|
reasoning_content = think_match.group(1).strip()
|
||||||
content = re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
|
content = re.sub(r'(?:<think>)?.*?</think>', '', content, flags=re.DOTALL, count=1).strip()
|
||||||
return content, reasoning_content
|
return content, reasoning_content
|
||||||
return "没有返回结果", ""
|
return "没有返回结果", ""
|
||||||
|
|
||||||
@@ -197,6 +199,7 @@ class LLM_request:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"max_tokens": 8000,
|
||||||
**self.params
|
**self.params
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,10 +229,10 @@ class LLM_request:
|
|||||||
think_match = None
|
think_match = None
|
||||||
reasoning_content = message.get("reasoning_content", "")
|
reasoning_content = message.get("reasoning_content", "")
|
||||||
if not reasoning_content:
|
if not reasoning_content:
|
||||||
think_match = re.search(r'<think>(.*?)</think>', content, re.DOTALL)
|
think_match = re.search(r'(?:<think>)?(.*?)</think>', content, re.DOTALL)
|
||||||
if think_match:
|
if think_match:
|
||||||
reasoning_content = think_match.group(1).strip()
|
reasoning_content = think_match.group(1).strip()
|
||||||
content = re.sub(r'<think>.*?</think>', '', content, flags=re.DOTALL).strip()
|
content = re.sub(r'(?:<think>)?.*?</think>', '', content, flags=re.DOTALL, count=1).strip()
|
||||||
return content, reasoning_content
|
return content, reasoning_content
|
||||||
return "没有返回结果", ""
|
return "没有返回结果", ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user