Skip to content

Conversation

axyr
Copy link

@axyr axyr commented May 30, 2025

I have minimal viable stream working, but only tested with anthropic.claude-3-5-sonnet-20240620-v1:0.

It is far from complete, and it was a bit harder than I expected...

I'm still finding my way around the different schema's and message formats.

I tried to keep things as 'Prism' as possible, but to get the stream even decoding working I had to use the aws sdk client in order to retrieve readable events from converseStream.

Added this WIP PR for first feedback and to 'publish' the work to prevent doing double work if others are also working on this.

        $stream = Prism::text()
            ->using(Bedrock::KEY, env('ANTHROPIC_MODEL'))
            ->withPrompt('Hi, how are you?')
            ->asStream();

        foreach ($stream as $chunk) {
            $this->line($chunk->text);
        }
image


protected function handleMessageStart(array $chunk): null
{
// {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to best store this information.

);
}

protected function handleReasoningContentBlockDelta(array $reasoningContent): Chunk
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not tested yet.

);
}

protected function handleMetadata(array $chunk): void
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do with this information.

'version' => config('prism.providers.bedrock.version', 'latest'),
'credentials' => [
'key' => config('prism.providers.bedrock.api_key', ''),
'secret' => config('prism.providers.bedrock.api_secret', ''),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to add 'token' => config('prism.providers.bedrock.session_token', ''), to work with sts.

* 'main' of github.com:prism-php/bedrock:
  fix(converse): parameterless tools (prism-php#28)
  fix: prism >=v0.77.1 incompatibilities (prism-php#27)

# Conflicts:
#	src/Bedrock.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants