Skip to content

pi_llm.utils.validation

validation

Tool call argument validation using jsonschema.

Validates tool call arguments against their JSON Schema definitions.

validate_tool_call(tools, tool_call)

Find a tool by name and validate the call's arguments.

Parameters:

Name Type Description Default
tools list[Tool]

Available tools to search.

required
tool_call ToolCall

The tool call to validate.

required

Returns:

Type Description
Any

A deep copy of the validated arguments.

Raises:

Type Description
ValueError

If the tool is not found or arguments are invalid.

validate_tool_arguments(tool, tool_call)

Validate tool call arguments against JSON Schema.

Returns a deep copy of validated arguments. Raises ValueError with formatted message on validation failure.