gaurv007 commited on
Commit
9fb868c
·
verified ·
1 Parent(s): 8a49c31

Upload alpha_factory/infra/llm_client.py

Browse files
Files changed (1) hide show
  1. alpha_factory/infra/llm_client.py +4 -3
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
- text = re.sub(r'\s*\s*', '', text, flags=re.DOTALL).strip()
277
- text = re.sub(r'\s*<thinking>.*?</thinking>\s*', '', text, flags=re.DOTALL).strip()
 
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: