update
Browse filesFiles changed (2)
221 unmodified lines222223224225226227228229230231232233234235236237238239240241242221 unmodified lines messages.append({"role": "assistant", "content": assistant_msg}) return messages
def strip_tool_call_markers(text): """Remove TOOL_CALL markers that some LLMs (like Qwen) add to their output.""" if not text: return text # Remove [TOOL_CALL] and [/TOOL_CALL] markers text = re.sub(r'\[/?TOOL_CALL\]', '', text, flags=re.IGNORECASE) # Remove standalone }} that appears with tool calls # Only remove if it's on its own line or at the end text = re.sub(r'^\s*\}\}\s*$', '', text, flags=re.MULTILINE) return text.strip()
def remove_code_block(text): # First strip any tool call markers text = strip_tool_call_markers(text) # Try to match code blocks with language markers patterns = [ r'```(?:html|HTML)\n([\s\S]+?)\n```', # Match ```html or ```HTML14 unmodified lines15161718192021222324252627282930313233343514 unmodified lines# Type definitionsHistory = List[Dict[str, str]]
def strip_tool_call_markers(text): """Remove TOOL_CALL markers that some LLMs (like Qwen) add to their output.""" if not text: return text # Remove [TOOL_CALL] and [/TOOL_CALL] markers text = re.sub(r'\[/?TOOL_CALL\]', '', text, flags=re.IGNORECASE) # Remove standalone }} that appears with tool calls # Only remove if it's on its own line or at the end text = re.sub(r'^\s*\}\}\s*$', '', text, flags=re.MULTILINE) return text.strip()
def remove_code_block(text): # First strip any tool call markers text = strip_tool_call_markers(text) # Try to match code blocks with language markers patterns = [ r'```(?:html|HTML)\n([\s\S]+?)\n```', # Match ```html or ```HTMLanycoder_app/models.py+14
anycoder_app/parsers.py+14