[Python] Why is this happening, even though I’ve already defined a Pydantic input model using...

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am using LangChain’s Tool.from_function() to define a tool called derivative, and I’ve also provided a Pydantic BaseModel (Input_structure) using the args_schema parameter:

    class Input_structure(BaseModel):
    expression: str
    variable: str

    def compute_derivative(expression: str, variable: str) -> str:
    ...

    derivative_tool = Tool.from_function(
    func=compute_derivative,
    name="derivative",
    description="Compute derivative",
    args_schema=Input_structure
    )


    However, when I chain this tool like so:

    result = derivative_tool.invoke(('x^2 + 10', 'x'))


    I get the following error:

    ToolException: Too many arguments to single-input tool derivative.
    Consider using StructuredTool instead. Args: ['x^2 + 10', 'x']

    Continue reading...

Compartilhe esta Página