Propagate model through streamed responses

StreamAccumulator never set its model field, so
Response().Model was always empty for streamed
completions. Add a Model field to stream events
and populate it in all three providers (OpenAI,
Anthropic, Bedrock).

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-13 19:17:17 +01:00
parent 9e842b8ef3
commit 2df9a3fe59
5 changed files with 35 additions and 15 deletions

View File

@@ -90,6 +90,7 @@ type (
}
ChatCompletionStreamEvent struct {
Model string // present on first event if provider supports it
Delta MessageDelta
Usage *Usage // present on final event if provider supports it
FinishReason *FinishReason // present on final event
@@ -206,6 +207,10 @@ func (a *StreamAccumulator) Response() *ChatCompletionResponse {
}
func (a *StreamAccumulator) accumulate(event ChatCompletionStreamEvent) {
if a.model == "" && event.Model != "" {
a.model = event.Model
}
a.content.WriteString(event.Delta.Content)
for _, tcd := range event.Delta.ToolCalls {