trait BuildsTextRequests

Constants

private TOP_LEVEL_INTERACTION_KEYS

The request keys Gemini expects beside the generation config rather than within it.

Methods

array
buildStepBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options, StepContext $stepContext)

Build the request body for the current text generation step.

array
buildTextRequestBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options)

Build the request body for the Gemini Interactions API.

array
buildFunctionResultSteps(array $toolResults)

Build function result steps from tool results for the Gemini API.

array
buildResponseSchema(array $schema)

Build the response schema for structured output.

string|array
toolChoiceConfig(ToolChoice $choice)

Map a tool choice to the Gemini tool choice configuration.

Details

at line 32
protected array buildStepBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options, StepContext $stepContext)

Build the request body for the current text generation step.

Parameters

Provider $provider
string $model
string|null $instructions
array $messages
array $tools
array|null $schema
TextGenerationOptions|null $options
StepContext $stepContext

Return Value

array

at line 48
protected array buildTextRequestBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options)

Build the request body for the Gemini Interactions API.

Parameters

Provider $provider
string $model
string|null $instructions
array $messages
array $tools
array|null $schema
TextGenerationOptions|null $options

Return Value

array

at line 141
protected array buildFunctionResultSteps(array $toolResults)

Build function result steps from tool results for the Gemini API.

Parameters

array $toolResults

Return Value

array

at line 154
protected array buildResponseSchema(array $schema)

Build the response schema for structured output.

Parameters

array $schema

Return Value

array

at line 162
protected string|array toolChoiceConfig(ToolChoice $choice)

Map a tool choice to the Gemini tool choice configuration.

Parameters

ToolChoice $choice

Return Value

string|array