FunctionToolCall
FunctionToolCall
dataclass
¶
Represents a function tool call with its name, arguments, and optional ID.
Attributes:
-
name
(str
) –The name of the function to call.
-
arguments
(str
) –Arguments to pass to the function. This is must be a JSON formatted string
-
id
(int | None
) –An optional identifier for the tool call.
Source code in flexeval/core/tool_parser/base.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
__post_init__ ¶
__post_init__() -> None
Source code in flexeval/core/tool_parser/base.py
51 52 53 54 55 56 57 58 |
|
to_dict ¶
to_dict() -> dict[str, Any]
Return a dictionary representation of the function tool call.
Returns:
-
dict[str, Any]
–A dictionary with the structure required for function tool calls.
Source code in flexeval/core/tool_parser/base.py
60 61 62 63 64 65 66 67 |
|
ToolCall
dataclass
¶
An abstract base class representing a generic tool call.
Subclasses should implement the to_dict
method to return a dictionary representation of the tool call.
Source code in flexeval/core/tool_parser/base.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
to_dict
abstractmethod
¶
to_dict() -> dict[str, Any]
Return a dictionary representation of the tool call.
Returns:
-
dict[str, Any]
–A dictionary describing the tool call.
Source code in flexeval/core/tool_parser/base.py
24 25 26 27 28 29 30 31 32 |
|
ToolCallingMessage
dataclass
¶
Represents the parsed result of a model output that may contain tool calls.
Attributes:
-
validation_result
(Literal['CompleteToolCall', 'InCompleteToolCall', 'TextOnly']
) –The validation result of the parsing (e.g., 'CompleteToolCall', 'InCompleteToolCall', or 'TextOnly').
-
text
(str
) –The text remaining after extracting the tool-calling part.
-
raw_text
(str
) –The raw, unprocessed text.
-
tool_calls
(list[ToolCall]
) –A list of ToolCall objects extracted from the text.
Source code in flexeval/core/tool_parser/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
validation_result
instance-attribute
¶
validation_result: Literal[
"CompleteToolCall", "InCompleteToolCall", "TextOnly"
]
tool_calls
class-attribute
instance-attribute
¶
tool_calls: list[ToolCall] = field(default_factory=list)
__init__ ¶
__init__(
validation_result: Literal[
"CompleteToolCall", "InCompleteToolCall", "TextOnly"
],
text: str = None,
raw_text: str = None,
tool_calls: list[ToolCall] = list(),
) -> None
__post_init__ ¶
__post_init__() -> None
Source code in flexeval/core/tool_parser/base.py
92 93 |
|
ToolParser ¶
An interface class used to extract tool calls from the model's output.
Source code in flexeval/core/tool_parser/base.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
__call__
abstractmethod
¶
__call__(text: str) -> ToolCallingMessage
Extract tool_calls from the input text.
Parameters:
-
text
(str
) –The text to process.
Source code in flexeval/core/tool_parser/base.py
101 102 103 104 105 106 107 108 109 |
|