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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user