View module source on GitHub

ToolCallConfig

@deprecated(
    "This class will be removed in a future version. Use {} which is TypedDict."
)

@dataclass
class ToolCallConfig()

Tool call config.

This class represents a tool call config.

ToolCallConfigDict

class ToolCallConfigDict(TypedDict)

Tool call config dict.

This class represents a tool call config dictionary.

get_tool_call_config_dict

def get_tool_call_config_dict(
        config: Union[ToolCallConfig,
                      ToolCallConfigDict]) -> ToolCallConfigDict

Convert a tool call config to a tool call config dict else return the config.

Arguments:

NameDescription
configThe config to convert.

Returns:

NameDescription
[ToolCallConfigDict](/sdk/python/references/logger/components/tool_call)The tool call config dict.

ToolCallError

@deprecated(
    "This class will be removed in a future version. Use {} which is TypedDict instead."
)

@dataclass
class ToolCallError()

Tool call error.

This class represents a tool call error.

get_tool_call_error_dict

def get_tool_call_error_dict(
        error: Union[ToolCallError, ToolCallErrorDict]) -> dict[str, Any]

Convert a tool call error to a tool call error dict else return the error.

Arguments:

NameDescription
errorThe error to convert.

Returns:

dict[str, Any]: The tool call error dict.

ToolCall

class ToolCall(BaseContainer)

Tool call.

This class represents a tool call.

__init__

def __init__(config: Union[ToolCallConfig, ToolCallConfigDict],
             writer: LogWriter)

Initialize a tool call.

Arguments:

NameDescription
configThe config to initialize the tool call with.
writerThe writer to use.

update

def update(data: Dict[str, Any])

Update the tool call.

Arguments:

NameDescription
dataThe data to update the tool call with.

update_

@staticmethod
def update_(writer: LogWriter, id: str, data: Dict[str, Any])

Update the tool call.

Arguments:

NameDescription
writerThe writer to use.
idThe id of the tool call to update.
dataThe data to update the tool call with.

result_

@staticmethod
def result_(writer: LogWriter, id: str, result: str)

Update the tool call.

Arguments:

NameDescription
writerThe writer to use.
idThe id of the tool call to update.
resultThe result to update the tool call with.

attach_evaluators

def attach_evaluators(evaluators: List[str])

Attach evaluators to the tool call.

Arguments:

NameDescription
evaluatorsThe evaluators to attach to the tool call.

result

def result(result: str)

Update the tool call.

Arguments:

NameDescription
resultThe result to update the tool call with.

error

def error(error: ToolCallError)

Add an error to the tool call.

Arguments:

NameDescription
errorThe tool call error.

error_

@staticmethod
def error_(writer: LogWriter, id: str, error: Union[ToolCallError,
                                                    ToolCallErrorDict])

Add an error to the tool call.

Arguments:

NameDescription
writerThe writer to use.
idThe id of the tool call to add the error to.
errorThe tool call error.

data

def data() -> Dict[str, Any]

Get the data for the tool call.

Returns:

Dict[str, Any]: The data for the tool call.