Skip to content

Commit 0026edc

Browse files
sasha-gitgcopybara-github
authored andcommitted
chore: update filtered schema parameters for Gemini API.
PiperOrigin-RevId: 762209590
1 parent d3910e7 commit 0026edc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
from .operation_parser import OperationParser
4242
from .tool_auth_handler import ToolAuthHandler
4343

44+
# Not supported by the Gemini API
45+
_OPENAPI_SCHEMA_IGNORE_FIELDS = (
46+
"title",
47+
"default",
48+
"format",
49+
"additional_properties",
50+
"ref",
51+
"def"
52+
)
53+
4454

4555
def snake_to_lower_camel(snake_case_string: str):
4656
"""Converts a snake_case string to a lower_camel_case string.
@@ -121,7 +131,7 @@ def to_gemini_schema(openapi_schema: Optional[Dict[str, Any]] = None) -> Schema:
121131
snake_case_key = to_snake_case(key)
122132
# Check if the snake_case_key exists in the Schema model's fields.
123133
if snake_case_key in Schema.model_fields:
124-
if snake_case_key in ["title", "default", "format"]:
134+
if snake_case_key in _OPENAPI_SCHEMA_IGNORE_FIELDS:
125135
# Ignore these fields as Gemini backend doesn't recognize them, and will
126136
# throw exception if they appear in the schema.
127137
# Format: properties[expiration].format: only 'enum' and 'date-time' are

0 commit comments

Comments
 (0)