feat(function call): complete utility method for KimiK2Detector and enhance documentation (#8043)
This commit is contained in:
@@ -19,10 +19,17 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class PythonicDetector(BaseFormatDetector):
|
||||
"""
|
||||
Detector for Llama-3.2 and Llama-4 models with pythonic tool call format.
|
||||
Assumes function call format:
|
||||
[tool1(arg1=val1, arg2=val2), tool2(arg1=val3)]
|
||||
Arguments are Python literals (not JSON).
|
||||
Detector for Llama-4 models with Pythonic tool call format.
|
||||
|
||||
The Pythonic format uses Python function call syntax within square brackets,
|
||||
with arguments as Python literals rather than JSON.
|
||||
|
||||
Format Structure:
|
||||
```
|
||||
[tool1(arg1=val1, arg2=val2), tool2(arg1=val3)]
|
||||
```
|
||||
|
||||
Reference: https://huggingface.co/meta-llama/Llama-4-Scout-17B-16E-Instruct?chat_template=default
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -75,11 +82,7 @@ class PythonicDetector(BaseFormatDetector):
|
||||
return StreamingParseResult(normal_text=normal_text, calls=[])
|
||||
|
||||
calls = []
|
||||
tool_indices = {
|
||||
tool.function.name: i
|
||||
for i, tool in enumerate(tools)
|
||||
if tool.function.name
|
||||
}
|
||||
tool_indices = self._get_tool_indices(tools)
|
||||
for call_index, call in enumerate(parsed.elts):
|
||||
if not isinstance(call.func, ast.Name):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user