This pull request adds a method events() to the Response class. It returns an EventStream instance for the content type application/vnd.amazon.eventstream.
Example
Streaming responses from Bedrock AI models:
use com\amazon\aws\{ServiceEndpoint, CredentialProvider};
use util\cmd\Console;
$runtime= (new ServiceEndpoint('bedrock', CredentialProvider::default()))
->using('bedrock-runtime.')
->in('eu-central-1')
;
$events= $runtime
->resource('/model/anthropic.claude-3-5-sonnet-20240620-v1:0/converse-stream')
->transmit($payload, 'application/json')
->events()
;
// Streams responses from AI.
foreach ($events as $event) {
Console::writeLine($event->header(':event-type'), ': ', $event->value());
}
This pull request adds a method events() to the Response class. It returns an EventStream instance for the content type
application/vnd.amazon.eventstream
.Example
Streaming responses from Bedrock AI models:
Message format
Source: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTSelectObjectAppendix.html
See also