Find answers from the community

Updated 3 months ago

'ello all! what am i doing wrong here

'ello all! what am i doing wrong here with a function tool with a pydantic arg? is there a better way to have function tools that take typed objects as args?

Plain Text
class TestObj(BaseModel):
    id: str = Field(description="Unique identifier.")

def test_fn(obj: TestObj):
    return 1

FunctionTool.from_defaults(test_fn),


RuntimeError: no validator found for <class 'app.leader_agent.TestObj'>, see arbitrary_types_allowed in Config
L
e
5 comments
I think this is a bug πŸ€” I thiiink you can set the field in the arg though

def test_fn(obj: str = Field(description="Unique identifier.")):
(maybe, I might be out to lunch here)
otherwise the function that reads the arg schema needs an upgrade
ah ok! πŸ™

for now then (that was just a repro, my real objects are larger) probably best to write the tool manually by subclassing BaseTool and providing the spec in the tool metadata function (hopefully that doesn't bump into the same bug)
Yea that might be the way around it πŸ‘€
Add a reply
Sign up and join the conversation on Discord