mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Add required parameters with defaults if missing
Merge https://github.com/google/adk-python/pull/2054 fixes https://github.com/google/adk-python/issues/2053 Co-authored-by: Xuan Yang <xygoogle@google.com> COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2054 from jeffbryner:fix-required-params dd75a0b5798792dccb1ca0ac0240ce0c0b1fad14 PiperOrigin-RevId: 830251203
This commit is contained in:
committed by
Copybara-Service
parent
f31226ee92
commit
352dd995e1
@@ -23,6 +23,7 @@ from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
from fastapi.openapi.models import Operation
|
||||
from fastapi.openapi.models import Schema
|
||||
from google.genai.types import FunctionDeclaration
|
||||
import requests
|
||||
from typing_extensions import override
|
||||
@@ -392,6 +393,17 @@ class RestApiTool(BaseTool):
|
||||
|
||||
# Attach parameters from auth into main parameters list
|
||||
api_params, api_args = self._operation_parser.get_parameters().copy(), args
|
||||
|
||||
# Add any required arguments that are missing and have defaults:
|
||||
for api_param in api_params:
|
||||
if api_param.py_name not in api_args:
|
||||
if (
|
||||
api_param.required
|
||||
and isinstance(api_param.param_schema, Schema)
|
||||
and api_param.param_schema.default is not None
|
||||
):
|
||||
api_args[api_param.py_name] = api_param.param_schema.default
|
||||
|
||||
if auth_credential:
|
||||
# Attach parameters from auth into main parameters list
|
||||
auth_param, auth_args = self._prepare_auth_request_params(
|
||||
|
||||
Reference in New Issue
Block a user