Skip to content

Commit

Permalink
fix compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianliechti committed Dec 15, 2024
1 parent 7926800 commit 6ea2a04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pkg/provider/anthropic/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ func (c *Completer) completeStream(ctx context.Context, req anthropic.MessageNew

case anthropic.ContentBlockDeltaEvent:
delta := provider.Completion{
ID: message.ID,

Message: provider.Message{
Role: provider.MessageRoleAssistant,
Content: event.Delta.Text,
},
}
Expand Down
10 changes: 4 additions & 6 deletions pkg/provider/bedrock/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ func (c *Completer) completeStream(ctx context.Context, req *bedrockruntime.Conv
case *types.ConverseStreamOutputMemberMessageStop:
reason := toCompletionResult(v.Value.StopReason)

if reason != "" {
result.Reason = reason
if reason == "" {
reason = provider.CompletionReasonStop
}

result.Reason = reason

delta := provider.Completion{
ID: result.ID,
Reason: result.Reason,
Expand All @@ -206,10 +208,6 @@ func (c *Completer) completeStream(ctx context.Context, req *bedrockruntime.Conv
},
}

if delta.Reason == "" {
delta.Reason = provider.CompletionReasonStop
}

if err := options.Stream(ctx, delta); err != nil {
return nil, err
}
Expand Down

0 comments on commit 6ea2a04

Please sign in to comment.