diff --git a/pkg/provider/anthropic/completer.go b/pkg/provider/anthropic/completer.go index f1fc948..c8dbd07 100644 --- a/pkg/provider/anthropic/completer.go +++ b/pkg/provider/anthropic/completer.go @@ -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, }, } diff --git a/pkg/provider/bedrock/completer.go b/pkg/provider/bedrock/completer.go index 0453755..3a0e9b5 100644 --- a/pkg/provider/bedrock/completer.go +++ b/pkg/provider/bedrock/completer.go @@ -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, @@ -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 }