Find answers from the community

Home
Members
ap0st0L
a
ap0st0L
Offline, last seen 3 months ago
Joined September 25, 2024
a
ap0st0L
·

Tool

Loading tools, give me error of pydantic:

pydantic.v1.error_wrappers.ValidationError: 1 validation error for AgentToolCallEvent
tool -> fn_schema
subclass of BaseModel expected (type=type_error.subclass; expected_class=BaseModel)


Plain Text
        metadata = ToolMetadata(
            name=definition.get('name'), 
            description=definition.get('description', None), 
            fn_schema=tool.ToolSchema if hasattr(my_tool, 'ToolSchema') else None
        )
        tool_spec = my_tool.CustomToolSpec()
        new_tool = tool_spec.to_tool_list(func_to_metadata_mapping={tool_spec.spec_functions[0]: metadata})[0]
        self.tools.append(new_tool)
        
        self.agent = OpenAIAgent.from_tools(
                self.tools,
                verbose=True,
                llm=self.llm,
                memory=self.memory,
                system_prompt=system_prompt,
                tool_call_parser=custom_tool_call_parser
        )
        self.agent.chat("My message that invoke some tool")


My_tool:

Plain Text
from llama_index.core.bridge.pydantic import BaseModel, Field
from llama_index.core.tools.tool_spec.base import BaseToolSpec
# ...

class ToolSchema(BaseModel):
    summary:Optional[str] = Field(description="A concise summary (translated to english) of the problem.")

class CustomToolSpec(BaseToolSpec):
    spec_functions = ["helpdesk_open_ticket"]
7 comments
L
a