abstract class StreamProtocol

Properties

protected bool $started
protected bool $errored
protected Throwable|null $exception

Methods

parts(StreamableAgentResponse $response)

Get the protocol parts that represent the given response's events.

maskedErrorParts()

Get the protocol parts that terminate a stream interrupted by an exception.

array
headers()

Get the response headers for the protocol.

Response
response(StreamableAgentResponse $response)

Create an HTTP response that represents the given response using the protocol.

string|null
terminator()

Get the raw frame that terminates the stream, if any.

string
encode(array $part)

Encode the given protocol part as a server-sent event line.

string
json(mixed $value)

Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.

Details

at line 26
abstract protected Generator parts(StreamableAgentResponse $response)

Get the protocol parts that represent the given response's events.

Parameters

StreamableAgentResponse $response

Return Value

Generator

at line 31
abstract protected Generator maskedErrorParts()

Get the protocol parts that terminate a stream interrupted by an exception.

Return Value

Generator

at line 38
protected array headers()

Get the response headers for the protocol.

Return Value

array

at line 49
Response response(StreamableAgentResponse $response)

Create an HTTP response that represents the given response using the protocol.

Parameters

StreamableAgentResponse $response

Return Value

Response

at line 88
protected string|null terminator()

Get the raw frame that terminates the stream, if any.

Return Value

string|null

at line 98
protected string encode(array $part)

Encode the given protocol part as a server-sent event line.

Parameters

array $part

Return Value

string

at line 106
protected string json(mixed $value)

Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.

Parameters

mixed $value

Return Value

string