Commit a0bb765

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-03-01 07:00:59
fix(gpt): match reasoning pattern
1 parent d01d358
Changed files (1)
src
src/llm/utils.py
@@ -116,7 +116,10 @@ def extract_reasoning(text: str) -> tuple[str, str]:
         text = re.sub(r"<thinking>(.*?)</thinking>", "", text, count=1, flags=re.DOTALL)
 
     # Reverse engineered Web API
-    if matched := re.search(r"^>?正在推理(.*?)(已推理,持续.*?)\n\n(.*)", text, re.DOTALL):  # noqa: RUF001
+    if matched := re.search(r"^>?(正在)?推理(.*?)(,持续.*?)秒\n\n(.*)", text, re.DOTALL):  # noqa: RUF001
+        reasoning = matched.group(2)
+        text = matched.group(4)
+    if matched := re.search(r"^>?\s?Reasoning(.*?)Reasoned(.*?)seconds\n\n(.*)", text, re.DOTALL):
         reasoning = matched.group(1)
         text = matched.group(3)