Repository navigation
fix(models): send ApigeeLlm tool parameters as JSON Schema - #8431
Open
omkarbandikatte wants to merge 1 commit into
Open
omkarbandikatte wants to merge 1 commit into
omkarbandikatte wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
No existing issue; describing the change below.
Problem:
CompletionsHTTPClient._function_declaration_to_tool(used byApigeeLlmfor OpenAI-compatible Chat Completions endpoints) convertsFunctionDeclaration.parameterswithfunc.parameters.model_dump(exclude_none=True). For atypes.Schemathat produces Gemini's representation, not JSON Schema: uppercase type names and snake_case field names.A Chat Completions endpoint expects
"object","array",minItems,anyOf, and so on; with these keys, unions and constraints are ignored or the request is rejected. This affects any tool declared withparameters=types.Schema(...), includingModelConsultTool. The response schema in the same file is already converted withmodel_dump(by_alias=True, mode='json')andlowercase_schema_types(#7920), but tool parameters weren't.Solution:
Dump tool parameters with
by_alias=True, mode='json'and applylowercase_schema_types, the same conversion as the response schema.parameters_json_schemais still passed through unchanged.Testing Plan
Unit Tests:
New
test_construct_payload_tool_schema_parameters_as_json_schemaintests/unittests/models/test_completions_http_client.pybuilds a payload for a tool with an array (min_items) and anany_ofparameter and checks the exact JSON Schema sent. It fails onmainand passes with this change.pyink,isortandruff(pre-commit versions) are clean.Manual End-to-End (E2E) Tests:
I don't have access to an Apigee proxy, so I checked the request payload built by
CompletionsHTTPClientrather than a live call.Checklist
An AI coding assistant helped find this and draft the change; I reviewed it and ran the tests myself.