[Python] When creating LangChain custom tool, how can I add new property

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I want to create a custom tool class with an additional property, let's say number. How can I change this code so that it doesn't throw an error?

    Code:

    from langchain.tools import BaseTool


    class MyTool(BaseTool):
    name = "Whatever"
    description = "Whatever"

    def __init__(self):
    self.number = 123

    def _run(self):
    pass

    def _arun(self):
    pass


    tool = MyTool()


    Error:

    ValueError: "MyTool" object has no field "number"

    Continue reading...

Compartilhe esta Página