trait ParsesTextResponses

Traits

Methods

array
decodeStructuredOutput(string|null $text)

Decode a structured output payload, tolerating markdown code fences.

void
validateTextResponse(array $data)

Validate the DeepSeek response data.

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

Parse the DeepSeek response data into a single step response.

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 DeepSeek response data.

Parameters

array $data

Return Value

void

Exceptions

AiException

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

Parse the DeepSeek response data into a single step response.

DeepSeek thinking-mode responses can include reasoning_content on each choice's message. We capture it into replayBlocks; the message mapper only replays it for assistant messages that include tool calls.

Parameters

array $data
Provider $provider
bool $structured

Return Value

StepResponse

at line 81
protected TextUsage extractUsage(array $data)

Extract usage data from the response.

Parameters

array $data

Return Value

TextUsage

at line 96
protected FinishReason extractFinishReason(array $choice)

Extract and map the finish reason from the response.

Parameters

array $choice

Return Value

FinishReason