@@ -92,10 +92,11 @@ type ChatMessagePart struct {
92
92
}
93
93
94
94
type ChatCompletionMessage struct {
95
- Role string `json:"role"`
96
- Content string `json:"content,omitempty"`
97
- Refusal string `json:"refusal,omitempty"`
98
- MultiContent []ChatMessagePart
95
+ Role string `json:"role"`
96
+ ReasoningContent string `json:"reasoning_content,omitempty"`
97
+ Content string `json:"content"`
98
+ Refusal string `json:"refusal,omitempty"`
99
+ MultiContent []ChatMessagePart
99
100
100
101
// This property isn't in the official documentation, but it's in
101
102
// the documentation for the official library for python:
@@ -118,56 +119,60 @@ func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
118
119
}
119
120
if len (m .MultiContent ) > 0 {
120
121
msg := struct {
121
- Role string `json:"role"`
122
- Content string `json:"-"`
123
- Refusal string `json:"refusal,omitempty"`
124
- MultiContent []ChatMessagePart `json:"content,omitempty"`
125
- Name string `json:"name,omitempty"`
126
- FunctionCall * FunctionCall `json:"function_call,omitempty"`
127
- ToolCalls []ToolCall `json:"tool_calls,omitempty"`
128
- ToolCallID string `json:"tool_call_id,omitempty"`
122
+ Role string `json:"role"`
123
+ ReasoningContent string `json:"reasoning_content,omitempty"`
124
+ Content string `json:"-"`
125
+ Refusal string `json:"refusal,omitempty"`
126
+ MultiContent []ChatMessagePart `json:"content,omitempty"`
127
+ Name string `json:"name,omitempty"`
128
+ FunctionCall * FunctionCall `json:"function_call,omitempty"`
129
+ ToolCalls []ToolCall `json:"tool_calls,omitempty"`
130
+ ToolCallID string `json:"tool_call_id,omitempty"`
129
131
}(m )
130
132
return json .Marshal (msg )
131
133
}
132
134
133
135
msg := struct {
134
- Role string `json:"role"`
135
- Content string `json:"content,omitempty"`
136
- Refusal string `json:"refusal,omitempty"`
137
- MultiContent []ChatMessagePart `json:"-"`
138
- Name string `json:"name,omitempty"`
139
- FunctionCall * FunctionCall `json:"function_call,omitempty"`
140
- ToolCalls []ToolCall `json:"tool_calls,omitempty"`
141
- ToolCallID string `json:"tool_call_id,omitempty"`
136
+ Role string `json:"role"`
137
+ ReasoningContent string `json:"reasoning_content,omitempty"`
138
+ Content string `json:"content"`
139
+ Refusal string `json:"refusal,omitempty"`
140
+ MultiContent []ChatMessagePart `json:"-"`
141
+ Name string `json:"name,omitempty"`
142
+ FunctionCall * FunctionCall `json:"function_call,omitempty"`
143
+ ToolCalls []ToolCall `json:"tool_calls,omitempty"`
144
+ ToolCallID string `json:"tool_call_id,omitempty"`
142
145
}(m )
143
146
return json .Marshal (msg )
144
147
}
145
148
146
149
func (m * ChatCompletionMessage ) UnmarshalJSON (bs []byte ) error {
147
150
msg := struct {
148
- Role string `json:"role"`
149
- Content string `json:"content,omitempty"`
150
- Refusal string `json:"refusal,omitempty"`
151
- MultiContent []ChatMessagePart
152
- Name string `json:"name,omitempty"`
153
- FunctionCall * FunctionCall `json:"function_call,omitempty"`
154
- ToolCalls []ToolCall `json:"tool_calls,omitempty"`
155
- ToolCallID string `json:"tool_call_id,omitempty"`
151
+ Role string `json:"role"`
152
+ ReasoningContent string `json:"reasoning_content,omitempty"`
153
+ Content string `json:"content"`
154
+ Refusal string `json:"refusal,omitempty"`
155
+ MultiContent []ChatMessagePart
156
+ Name string `json:"name,omitempty"`
157
+ FunctionCall * FunctionCall `json:"function_call,omitempty"`
158
+ ToolCalls []ToolCall `json:"tool_calls,omitempty"`
159
+ ToolCallID string `json:"tool_call_id,omitempty"`
156
160
}{}
157
161
158
162
if err := json .Unmarshal (bs , & msg ); err == nil {
159
163
* m = ChatCompletionMessage (msg )
160
164
return nil
161
165
}
162
166
multiMsg := struct {
163
- Role string `json:"role"`
164
- Content string
165
- Refusal string `json:"refusal,omitempty"`
166
- MultiContent []ChatMessagePart `json:"content"`
167
- Name string `json:"name,omitempty"`
168
- FunctionCall * FunctionCall `json:"function_call,omitempty"`
169
- ToolCalls []ToolCall `json:"tool_calls,omitempty"`
170
- ToolCallID string `json:"tool_call_id,omitempty"`
167
+ Role string `json:"role"`
168
+ ReasoningContent string `json:"reasoning_content,omitempty"`
169
+ Content string
170
+ Refusal string `json:"refusal,omitempty"`
171
+ MultiContent []ChatMessagePart `json:"content"`
172
+ Name string `json:"name,omitempty"`
173
+ FunctionCall * FunctionCall `json:"function_call,omitempty"`
174
+ ToolCalls []ToolCall `json:"tool_calls,omitempty"`
175
+ ToolCallID string `json:"tool_call_id,omitempty"`
171
176
}{}
172
177
if err := json .Unmarshal (bs , & multiMsg ); err != nil {
173
178
return err
0 commit comments