Great question β answering as the UphillTech team:
You get that error because @tool on a bound instance method is not supported. When you decorate a method like: @tool def read_file(self, path: str) -> str: ... LangChain wraps it as a StructuredTool , but since itβs already bound (i.e. self is already attached), at runtime it gets passed another implicit self β so Python sees two self args β and thus: TypeError: StructuredTool._run() got multiple values for argument 'self' In a nutshell: tools need to be plain callables, not bound methods . So, To fix this you can wrap the instance method into a closure that captures self : class FileInterface: def __init__(self, base_dir: str): self.base_dir = Path(base_dir) def _read_file(self, filename:...
Full answer by Ajeet Verma: https://stackoverflow.stackexchange.com/a/79808579 (CC BY-SA 4.0).
Need it done for your business? UphillTech.