ParsesTextResponses
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.
from
JoinsReasoning
void
validateTextResponse(mixed $data)
Validate the Cohere response data.
parseTextResponse(array $data, Provider $provider, string $model, bool $structured)
Parse the Cohere response data into a single step response.
extractUsage(array $usage)
Extract usage data from a Cohere usage object.
FinishReason
extractFinishReason(string|null $finishReason)
Map a Cohere finish reason to the finish reason enum.
Details
in
DecodesStructuredOutput at line 12
protected array
decodeStructuredOutput(string|null $text)
Decode a structured output payload, tolerating markdown code fences.
in
JoinsReasoning at line 16
static protected string
joinReasoning(iterable $blocks)
Join reasoning blocks, separating each block with a blank line.
at line 27
protected void
validateTextResponse(mixed $data)
Validate the Cohere response data.
at line 40
protected StepResponse
parseTextResponse(array $data, Provider $provider, string $model, bool $structured)
Parse the Cohere response data into a single step response.
at line 80
protected TextUsage
extractUsage(array $usage)
Extract usage data from a Cohere usage object.
at line 92
protected FinishReason
extractFinishReason(string|null $finishReason)
Map a Cohere finish reason to the finish reason enum.