One-time parsing: Detects and parses tool calls in the provided text. :param text: The complete text to parse. :param tools: List of available tools. :return: ParseResult indicating success or failure, consumed text, leftover text, and parsed calls.
(self, text: str, tools: List[Function])
| 357 | return "" |
| 358 | |
| 359 | def detect_and_parse(self, text: str, tools: List[Function]) -> List[ToolCallItem]: |
| 360 | """ |
| 361 | One-time parsing: Detects and parses tool calls in the provided text. |
| 362 | |
| 363 | :param text: The complete text to parse. |
| 364 | :param tools: List of available tools. |
| 365 | :return: ParseResult indicating success or failure, consumed text, leftover text, and parsed calls. |
| 366 | """ |
| 367 | text = self._clean_text(text) |
| 368 | tool_content = text.replace("[TOOL_CALLS]", "").strip() |
| 369 | raw_tool_calls = self.tool_call_regex.findall(tool_content) |
| 370 | calls = [] |
| 371 | if len(raw_tool_calls) > 0: |
| 372 | raw_tool_call = raw_tool_calls[0] |
| 373 | function_call_arr = json.loads(raw_tool_call) |
| 374 | for match_result in function_call_arr: |
| 375 | calls.extend(self.parse_base_json(match_result, tools)) |
| 376 | return calls |
| 377 | |
| 378 | |
| 379 | class Llama32Detector(BaseFormatDetector): |
nothing calls this directly
no test coverage detected