MCPcopy Index your code
hub / github.com/ModelTC/LightLLM / parse_once

Method parse_once

lightllm/server/function_call_parser.py:425–442  ·  view source on GitHub ↗

One-time parsing: Loop through detectors until there are no new matches or text is exhausted Return: (final_text, all_calls) - final_text: The remaining text after parsing that was not consumed by any Detector (can be treated as normal text) - all_calls:

(self, text: str, tools: List[Function])

Source from the content-addressed store, hash-verified

423 self.detectors = detectors
424
425 def parse_once(self, text: str, tools: List[Function]):
426 """
427 One-time parsing: Loop through detectors until there are no new matches or text is exhausted
428 Return: (final_text, all_calls)
429 - final_text: The remaining text after parsing that was not
430 consumed by any Detector (can be treated as normal text)
431 - all_calls: All calls parsed by the Detectors
432 """
433 final_calls = []
434 final_normal_text = text
435 for detector in self.detectors:
436 tool_call_list = detector.detect_and_parse(text, tools)
437 if len(tool_call_list) > 0: # parsed successfully
438 final_calls = tool_call_list
439 break
440
441 # leftover_text is the normal text not consumed by any Detector
442 return final_normal_text, final_calls
443
444 def parse_streaming_increment(self, new_text: str, tools: List[Function]):
445 """

Callers 1

parse_non_streamMethod · 0.80

Calls 1

detect_and_parseMethod · 0.45

Tested by

no test coverage detected