text_processing.py 322 B

12345678910111213141516
  1. """Utility helpers for normalizing agent generated text."""
  2. from __future__ import annotations
  3. import re
  4. def strip_tool_calls(text: str) -> str:
  5. """移除文本中的工具调用标记。"""
  6. if not text:
  7. return text
  8. pattern = re.compile(r"\[TOOL_CALL:[^\]]+\]")
  9. return pattern.sub("", text)