Upload alpha_factory/infra/llm_client.py
Browse files
alpha_factory/infra/llm_client.py
CHANGED
|
@@ -268,13 +268,14 @@ class LLMClient:
|
|
| 268 |
Parse JSON from LLM response, handling common issues:
|
| 269 |
- Markdown code blocks
|
| 270 |
- Leading/trailing text
|
| 271 |
-
- Thinking tags
|
| 272 |
"""
|
| 273 |
text = content.strip()
|
| 274 |
|
| 275 |
# Remove thinking tags (Qwen/DeepSeek R1 style)
|
| 276 |
-
|
| 277 |
-
text = re.sub(r'
|
|
|
|
| 278 |
|
| 279 |
# Remove markdown code blocks
|
| 280 |
if "```json" in text:
|
|
|
|
| 268 |
Parse JSON from LLM response, handling common issues:
|
| 269 |
- Markdown code blocks
|
| 270 |
- Leading/trailing text
|
| 271 |
+
- Thinking tags (<think>...</think>, <thinking>...</thinking>)
|
| 272 |
"""
|
| 273 |
text = content.strip()
|
| 274 |
|
| 275 |
# Remove thinking tags (Qwen/DeepSeek R1 style)
|
| 276 |
+
# Match <think>...</think> or <thinking>...</thinking>
|
| 277 |
+
text = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL).strip()
|
| 278 |
+
text = re.sub(r'<thinking>.*?</thinking>', '', text, flags=re.DOTALL).strip()
|
| 279 |
|
| 280 |
# Remove markdown code blocks
|
| 281 |
if "```json" in text:
|