Skip to content

Feature: support Pydantic Model as function param and return type #1066

Description

@Jacksunwei

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Is your feature request related to a problem? Please describe.

When defining function tool using python function, we need to allow simple pyndatic model as params and return types.

E.g.

class Param1(BaseModel); id: str
query: str
class Param2(BaseModel); id: str
log: str
class ReturnType(BaseModel):
result: str
def my_tool(param_1: Param1, param_2: Param2) -> ReturnType:
... 

Describe the solution you'd like

  • Supporting to convert PydanticModel to json schema then to FunctionDeclaration for the usage of GenAI SDK.

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Labels

models[Component] This issue is related to model supportneeds review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions