Skip to content

Parse description field if return type of a function is a pydantic.BaseModel #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ site/
Thumbs.db
*.bak
*.tmp
*.temp
*.temp
6 changes: 5 additions & 1 deletion src/google/adk/tools/function_parameter_parse_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,16 @@ def _is_default_value_compatible(


def _parse_schema_from_parameter(
variant: str, param: inspect.Parameter, func_name: str
variant: str, param: inspect.Parameter, func_name: str,
description: str | None = None
) -> types.Schema:
"""parse schema from parameter.

from the simplest case to the most complex case.
"""
schema = types.Schema()
if description is not None:
schema.description = description
default_value_error_msg = (
f'Default value {param.default} of parameter {param} of function'
f' {func_name} is not compatible with the parameter annotation'
Expand Down Expand Up @@ -286,6 +289,7 @@ def _parse_schema_from_parameter(
annotation=field_info.annotation,
),
func_name,
description=field_info.description if field_info.description else None
)
_raise_if_schema_unsupported(variant, schema)
return schema
Expand Down