Tool Call Parser
Shared tool-call conversion between our public ToolCall model and DeepEval's.
Extracted from deepeval_tool_correctness.py so conv_deepeval_metric.py can import ToolCallParser without a circular import (deepeval_tool_use.py imports ConvDeepEvalMetricFactory from conv_deepeval_metric.py at module level).
ToolCallParser
ToolCallParser converts public tool-call rows into DeepEval tool calls.
from_tool_definitions(tools)
Convert a tool catalogue of name/description/parameters dicts into DeepEval tool calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tools
|
list[dict[str, Any]]
|
Tool definitions, each with 'name', 'description', and 'parameters'. |
required |
Returns:
| Type | Description |
|---|---|
list[ToolCall]
|
List of |
from_trajectory_steps(steps)
Convert internal trajectory step dictionaries to public tool calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steps
|
list[dict[str, Any]]
|
Internal step dictionaries produced by |
required |
Returns:
| Type | Description |
|---|---|
list[ToolCall]
|
List of typed public |
normalize_tool_name(tool_name)
Normalize tool names by removing dynamic suffixes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
The original tool name with potential suffix. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized tool name without dynamic suffix. |
parse(tool_calls)
Parse public tool-call payloads into DeepEval tool calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_calls
|
list[ToolCall | dict[str, Any]]
|
Public tool-call payloads as |
required |
Returns:
| Type | Description |
|---|---|
list[ToolCall]
|
List of |
to_deepeval_tool_calls(steps, normalize_names=True, include_output=True)
Convert public tool calls into DeepEval tool calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steps
|
list[ToolCall]
|
List of tool calls with 'name', 'input_parameters', and optional 'output'. |
required |
normalize_names
|
bool
|
Whether to normalize tool names by removing dynamic suffixes (e.g., _xg7c). Defaults to True. |
True
|
include_output
|
bool
|
Whether to include the 'output' field from each step in the DeepEval tool call. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
list[ToolCall]
|
List of |