Rename inputs -> input to match Engine (#190)

Tool definitions in the Engine were missing `input` because the field
was renamed.

---------

Co-authored-by: Eric Gustin <eric@arcade-ai.com>
This commit is contained in:
Nate Barbettini 2025-01-03 17:42:58 -08:00 committed by GitHub
parent 890ee96ef4
commit fd5b429322
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 44 additions and 44 deletions

View file

@ -49,7 +49,7 @@ def display_tool_details(tool: ToolDefinition) -> None:
) )
# Inputs Panel # Inputs Panel
inputs = tool.inputs.parameters inputs = tool.input.parameters
if inputs: if inputs:
inputs_table = Table(show_header=True, header_style="bold green") inputs_table = Table(show_header=True, header_style="bold green")
inputs_table.add_column("Name", style="cyan") inputs_table.add_column("Name", style="cyan")

View file

@ -34,7 +34,7 @@ from arcade.core.schema import (
ToolAuthRequirement, ToolAuthRequirement,
ToolContext, ToolContext,
ToolDefinition, ToolDefinition,
ToolInputs, ToolInput,
ToolkitDefinition, ToolkitDefinition,
ToolOutput, ToolOutput,
ToolRequirements, ToolRequirements,
@ -317,7 +317,7 @@ class ToolCatalog(BaseModel):
fully_qualified_name=str(fully_qualified_name), fully_qualified_name=str(fully_qualified_name),
description=tool_description, description=tool_description,
toolkit=toolkit_definition, toolkit=toolkit_definition,
inputs=create_input_definition(tool), input=create_input_definition(tool),
output=create_output_definition(tool), output=create_output_definition(tool),
requirements=ToolRequirements( requirements=ToolRequirements(
authorization=auth_requirement, authorization=auth_requirement,
@ -325,7 +325,7 @@ class ToolCatalog(BaseModel):
) )
def create_input_definition(func: Callable) -> ToolInputs: def create_input_definition(func: Callable) -> ToolInput:
""" """
Create an input model for a function based on its parameters. Create an input model for a function based on its parameters.
""" """
@ -363,7 +363,7 @@ def create_input_definition(func: Callable) -> ToolInputs:
) )
) )
return ToolInputs( return ToolInput(
parameters=input_parameters, tool_context_parameter_name=tool_context_param_name parameters=input_parameters, tool_context_parameter_name=tool_context_param_name
) )

View file

@ -37,8 +37,8 @@ class ToolExecutor:
func_args = inputs.model_dump() func_args = inputs.model_dump()
# inject ToolContext, if the target function supports it # inject ToolContext, if the target function supports it
if definition.inputs.tool_context_parameter_name is not None: if definition.input.tool_context_parameter_name is not None:
func_args[definition.inputs.tool_context_parameter_name] = context func_args[definition.input.tool_context_parameter_name] = context
# execute the tool function # execute the tool function
if asyncio.iscoroutinefunction(func): if asyncio.iscoroutinefunction(func):

View file

@ -42,7 +42,7 @@ class InputParameter(BaseModel):
) )
class ToolInputs(BaseModel): class ToolInput(BaseModel):
"""The inputs that a tool accepts.""" """The inputs that a tool accepts."""
parameters: list[InputParameter] parameters: list[InputParameter]
@ -179,7 +179,7 @@ class ToolDefinition(BaseModel):
toolkit: ToolkitDefinition toolkit: ToolkitDefinition
"""The toolkit that contains the tool.""" """The toolkit that contains the tool."""
inputs: ToolInputs input: ToolInput
"""The inputs that the tool accepts.""" """The inputs that the tool accepts."""
output: ToolOutput output: ToolOutput

View file

@ -9,7 +9,7 @@ from arcade.core.schema import (
OAuth2Requirement, OAuth2Requirement,
ToolAuthRequirement, ToolAuthRequirement,
ToolContext, ToolContext,
ToolInputs, ToolInput,
ToolOutput, ToolOutput,
ToolRequirements, ToolRequirements,
ValueSchema, ValueSchema,
@ -313,7 +313,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_non_inferrable_param, func_with_non_inferrable_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -330,7 +330,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_renamed_param, func_with_renamed_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="ParamOne", name="ParamOne",
@ -347,7 +347,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_enum_param, func_with_enum_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -364,7 +364,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_dict_param, func_with_dict_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -381,7 +381,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_string_literal_param, func_with_string_literal_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -398,7 +398,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_param_with_default, func_with_param_with_default,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -418,7 +418,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_optional_param, func_with_optional_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -438,7 +438,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_optional_param_with_default_None, func_with_optional_param_with_default_None,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -458,7 +458,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_optional_param_with_default_value, func_with_optional_param_with_default_value,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -478,7 +478,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_optional_param_with_bar_syntax, func_with_optional_param_with_bar_syntax,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -498,7 +498,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_mixed_params, func_with_mixed_params,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -523,7 +523,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_list_param, func_with_list_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -542,7 +542,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_list_float_param, func_with_list_float_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -561,7 +561,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_list_of_enums_param, func_with_list_of_enums_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -580,7 +580,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_complex_param, func_with_complex_param,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="param1", name="param1",
@ -597,9 +597,9 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_context, func_with_context,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[], tool_context_parameter_name="my_context" parameters=[], tool_context_parameter_name="my_context"
), # ToolContext type is not an input param, but it's stored in the inputs field ), # ToolContext type is not an input param, but it's stored in the input field
}, },
id="func_with_context", id="func_with_context",
), ),
@ -607,7 +607,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_list_return, func_with_list_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="array", inner_val_type="string", enum=None), value_schema=ValueSchema(val_type="array", inner_val_type="string", enum=None),
available_modes=["value", "error"], available_modes=["value", "error"],
@ -619,7 +619,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_known_list_return, func_with_known_list_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="string", enum=["value1", "value2"]), value_schema=ValueSchema(val_type="string", enum=["value1", "value2"]),
available_modes=["value", "error"], available_modes=["value", "error"],
@ -631,7 +631,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_enum_return, func_with_enum_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="string", enum=["foo bar", "baz"]), value_schema=ValueSchema(val_type="string", enum=["foo bar", "baz"]),
available_modes=["value", "error"], available_modes=["value", "error"],
@ -643,7 +643,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_annotated_return, func_with_annotated_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="string", enum=None), value_schema=ValueSchema(val_type="string", enum=None),
available_modes=["value", "error"], available_modes=["value", "error"],
@ -655,7 +655,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_optional_return, func_with_optional_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="string", enum=None), value_schema=ValueSchema(val_type="string", enum=None),
available_modes=["value", "error", "null"], available_modes=["value", "error", "null"],
@ -667,7 +667,7 @@ def func_with_complex_return() -> dict[str, str]:
pytest.param( pytest.param(
func_with_complex_return, func_with_complex_return,
{ {
"inputs": ToolInputs(parameters=[]), "input": ToolInput(parameters=[]),
"output": ToolOutput( "output": ToolOutput(
value_schema=ValueSchema(val_type="json", enum=None), value_schema=ValueSchema(val_type="json", enum=None),
available_modes=["value", "error"], available_modes=["value", "error"],

View file

@ -64,7 +64,7 @@ def test_create_tool_def2(test_case):
tool_def = ToolCatalog.create_tool_definition(generated_func, "1.0") tool_def = ToolCatalog.create_tool_definition(generated_func, "1.0")
for i, input_type in enumerate(input_types): for i, input_type in enumerate(input_types):
param = tool_def.inputs.parameters[i] param = tool_def.input.parameters[i]
assert ( assert (
param.value_schema.val_type == get_wire_type(input_type) param.value_schema.val_type == get_wire_type(input_type)
), f"Parameter {param.name} has value type {param.value_schema.val_type} but {input_type} was expected at index {i}" ), f"Parameter {param.name} has value type {param.value_schema.val_type} but {input_type} was expected at index {i}"

View file

@ -6,7 +6,7 @@ from pydantic import BaseModel, Field
from arcade.core.catalog import ToolCatalog from arcade.core.catalog import ToolCatalog
from arcade.core.schema import ( from arcade.core.schema import (
InputParameter, InputParameter,
ToolInputs, ToolInput,
ToolOutput, ToolOutput,
ValueSchema, ValueSchema,
) )
@ -143,7 +143,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_with_description, func_takes_pydantic_field_with_description,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="product_name", name="product_name",
@ -160,7 +160,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_optional, func_takes_pydantic_field_optional,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="product_name", name="product_name",
@ -177,7 +177,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_annotated_description, func_takes_pydantic_field_annotated_description,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="product_name", name="product_name",
@ -194,7 +194,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_annotated_name_and_description, func_takes_pydantic_field_annotated_name_and_description,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="ProductName", name="ProductName",
@ -211,7 +211,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_default, func_takes_pydantic_field_default,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="product_name", name="product_name",
@ -228,7 +228,7 @@ def read_products(
pytest.param( pytest.param(
func_takes_pydantic_field_default_factory, func_takes_pydantic_field_default_factory,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="product_name", name="product_name",
@ -245,7 +245,7 @@ def read_products(
pytest.param( pytest.param(
read_products, read_products,
{ {
"inputs": ToolInputs( "input": ToolInput(
parameters=[ parameters=[
InputParameter( InputParameter(
name="action", name="action",

View file

@ -78,7 +78,7 @@
"required": ["name", "version"], "required": ["name", "version"],
"additionalProperties": false "additionalProperties": false
}, },
"inputs": { "input": {
"type": "object", "type": "object",
"properties": { "properties": {
"parameters": { "parameters": {
@ -181,6 +181,6 @@
"additionalProperties": false "additionalProperties": false
} }
}, },
"required": ["name", "fully_qualified_name", "toolkit", "inputs", "output"], "required": ["name", "fully_qualified_name", "toolkit", "input", "output"],
"additionalProperties": false "additionalProperties": false
} }