trait BuildsTextRequests

Traits

Methods

string|null
composeInstructions(string|null $instructions, array|null $schema)

Add structured output requirements to the instructions.

array
buildStepBody(TextProvider $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 Ollama Chat API.

array
buildChatRequestBody(Provider $provider, string $model, array $chatMessages, array $tools, array|null $schema, TextGenerationOptions|null $options, bool $stream = false)

Build a request body from pre-mapped chat messages.

array
buildResponseFormat(array $schema)

Build the response format schema for structured output.

Details

protected string|null composeInstructions(string|null $instructions, array|null $schema)

Add structured output requirements to the instructions.

Parameters

string|null $instructions
array|null $schema

Return Value

string|null

at line 26
protected array buildStepBody(TextProvider $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

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

Return Value

array

at line 42
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 Ollama Chat API.

Parameters

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

Return Value

array

at line 64
protected array buildChatRequestBody(Provider $provider, string $model, array $chatMessages, array $tools, array|null $schema, TextGenerationOptions|null $options, bool $stream = false)

Build a request body from pre-mapped chat messages.

Parameters

Provider $provider
string $model
array $chatMessages
array $tools
array|null $schema
TextGenerationOptions|null $options
bool $stream

Return Value

array

at line 126
protected array buildResponseFormat(array $schema)

Build the response format schema for structured output.

Parameters

array $schema

Return Value

array