File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,10 @@ func (cc *ChatCompletion) accumulateDelta(chunk ChatCompletionChunk) bool {
110
110
choice .Index = delta .Index
111
111
choice .FinishReason = ChatCompletionChoicesFinishReason (delta .FinishReason )
112
112
113
+ if delta .Delta .Role != "" {
114
+ choice .Message .Role = ChatCompletionMessageRole (delta .Delta .Role )
115
+ }
116
+
113
117
choice .Message .Content += delta .Delta .Content
114
118
choice .Message .Refusal += delta .Delta .Refusal
115
119
@@ -119,8 +123,12 @@ func (cc *ChatCompletion) accumulateDelta(chunk ChatCompletionChunk) bool {
119
123
choice .Message .ToolCalls = expandToFit (choice .Message .ToolCalls , int (deltaTool .Index ))
120
124
tool := & choice .Message .ToolCalls [deltaTool .Index ]
121
125
122
- tool .ID = deltaTool .ID
123
- tool .Type = ChatCompletionMessageToolCallType (deltaTool .Type )
126
+ if deltaTool .ID != "" {
127
+ tool .ID = deltaTool .ID
128
+ }
129
+ if deltaTool .Type != "" {
130
+ tool .Type = ChatCompletionMessageToolCallType (deltaTool .Type )
131
+ }
124
132
tool .Function .Name += deltaTool .Function .Name
125
133
tool .Function .Arguments += deltaTool .Function .Arguments
126
134
}
You can’t perform that action at this time.
0 commit comments