trait ParsesTextResponses

Traits

Methods

array
decodeStructuredOutput(string|null $text)

Decode a structured output payload, tolerating markdown code fences.

static string
joinReasoning(iterable $blocks)

Join reasoning blocks, separating each block with a blank line.

void
validateTextResponse(array $data)

Validate the Mistral response data.

parseTextResponse(array $data, Provider $provider, bool $structured)

Parse the Mistral response data into a single step response.

string
extractReasoning(mixed $content)

Extract the reasoning text from the thinking chunks of a message content value.

string
extractContentText(mixed $content)

Extract the text from a message content value, which may be a list of content chunks.

extractUsage(array $data)

Extract usage data from the response.

FinishReason
extractFinishReason(array $choice)

Extract and map the finish reason from the response.

Details

protected array decodeStructuredOutput(string|null $text)

Decode a structured output payload, tolerating markdown code fences.

Parameters

string|null $text

Return Value

array

in JoinsReasoning at line 16
static protected string joinReasoning(iterable $blocks)

Join reasoning blocks, separating each block with a blank line.

Parameters

iterable $blocks

Return Value

string

at line 27
protected void validateTextResponse(array $data)

Validate the Mistral response data.

Parameters

array $data

Return Value

void

Exceptions

AiException

at line 41
protected StepResponse parseTextResponse(array $data, Provider $provider, bool $structured)

Parse the Mistral response data into a single step response.

Parameters

array $data
Provider $provider
bool $structured

Return Value

StepResponse

at line 75
protected string extractReasoning(mixed $content)

Extract the reasoning text from the thinking chunks of a message content value.

Parameters

mixed $content

Return Value

string

at line 90
protected string extractContentText(mixed $content)

Extract the text from a message content value, which may be a list of content chunks.

Parameters

mixed $content

Return Value

string

at line 105
protected TextUsage extractUsage(array $data)

Extract usage data from the response.

Parameters

array $data

Return Value

TextUsage

at line 119
protected FinishReason extractFinishReason(array $choice)

Extract and map the finish reason from the response.

Parameters

array $choice

Return Value

FinishReason