If I'm using the AI Client to set a JSON response schema, example wp_ai_client_prompt( $prompt )->as_json_response( $this->suggestions_schema() ), the schema I set has additionalProperties keys, which is required to make that work with OpenAI.
This then causes issues when using this Google Provider, you'll end up with errors like Bad Request (400) - Invalid JSON payload received. Unknown name "additionalProperties" at 'generation_config.response_schema.properties[0].value.items': Cannot find field.
In debugging this, it seems Google does not support the additionalProperties key and in fact there's already code in place within this Provider to remove that from function declarations, see
|
// The Google AI API does not allow the `additionalProperties` key for function parameters. |
|
$data['parameters'] = $this->removeAdditionalPropertiesKey($data['parameters']); |
I think we'll want to run this same code when processing the JSON response schema and it may need extended to support removing this key from nested items.
If I'm using the AI Client to set a JSON response schema, example
wp_ai_client_prompt( $prompt )->as_json_response( $this->suggestions_schema() ), the schema I set hasadditionalPropertieskeys, which is required to make that work with OpenAI.This then causes issues when using this Google Provider, you'll end up with errors like
Bad Request (400) - Invalid JSON payload received. Unknown name "additionalProperties" at 'generation_config.response_schema.properties[0].value.items': Cannot find field.In debugging this, it seems Google does not support the
additionalPropertieskey and in fact there's already code in place within this Provider to remove that from function declarations, seeai-provider-for-google/src/Models/GoogleTextGenerationModel.php
Lines 494 to 495 in f8ba19c
I think we'll want to run this same code when processing the JSON response schema and it may need extended to support removing this key from nested items.