trait ParsesTextResponses

Traits

Methods

array
decodeStructuredOutput(string|null $text)

Decode a structured output payload, tolerating markdown code fences.

void
validateTextResponse(array $data)

Validate the Groq response data.

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

Parse a single Groq response into a StepResponse.

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

at line 25
protected void validateTextResponse(array $data)

Validate the Groq response data.

Parameters

array $data

Return Value

void

Exceptions

AiException

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

Parse a single Groq response into a StepResponse.

Parameters

array $data
Provider $provider
bool $structured

Return Value

StepResponse

at line 74
protected TextUsage extractUsage(array $data)

Extract usage data from the response.

Parameters

array $data

Return Value

TextUsage

at line 89
protected FinishReason extractFinishReason(array $choice)

Extract and map the finish reason from the response.

Parameters

array $choice

Return Value

FinishReason