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