Skip to content

Commit 3cd99fd

Browse files
committed
fix Gemini structured output for 3 series models and adapt schema
1 parent d7e243c commit 3cd99fd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Providers/Gemini/HandleStructured.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
use function json_encode;
1414
use function in_array;
1515

16-
/**
17-
* Structured outputs with tools is available only for the Gemini 3 series models.
18-
* https://ai.google.dev/gemini-api/docs/structured-output?example=recipe#structured_outputs_with_tools
19-
*/
20-
const SUPPORTED_MODELS = [
21-
'gemini-3-pro-preview',
22-
'gemini-3-flash-preview',
23-
];
24-
2516
trait HandleStructured
2617
{
18+
/**
19+
* Structured outputs with tools is available only for the Gemini 3 series models.
20+
* https://ai.google.dev/gemini-api/docs/structured-output?example=recipe#structured_outputs_with_tools
21+
*/
22+
protected array $supportedModels = [
23+
'gemini-3-pro-preview',
24+
'gemini-3-flash-preview',
25+
];
26+
2727
public function structured(
2828
array $messages,
2929
string $class,
@@ -37,7 +37,7 @@ public function structured(
3737

3838
// Gemini does not support structured output in combination with tools.
3939
// So we try to work with a JSON mode in case the agent has some tools defined.
40-
if (!empty($this->tools) && !in_array($this->model, SUPPORTED_MODELS)) {
40+
if (!empty($this->tools) && !in_array($this->model, $this->supportedModels)) {
4141
$last_message = end($messages);
4242
if ($last_message instanceof Message && $last_message->getRole() === MessageRole::USER->value) {
4343
$last_message->setContent(

0 commit comments

Comments
 (0)