@@ -82,6 +82,7 @@ type ChatMessagePart struct {
82
82
type ChatCompletionMessage struct {
83
83
Role string `json:"role"`
84
84
Content string `json:"content"`
85
+ Refusal string `json:"refusal,omitempty"`
85
86
MultiContent []ChatMessagePart
86
87
87
88
// This property isn't in the official documentation, but it's in
@@ -107,6 +108,7 @@ func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
107
108
msg := struct {
108
109
Role string `json:"role"`
109
110
Content string `json:"-"`
111
+ Refusal string `json:"refusal,omitempty"`
110
112
MultiContent []ChatMessagePart `json:"content,omitempty"`
111
113
Name string `json:"name,omitempty"`
112
114
FunctionCall * FunctionCall `json:"function_call,omitempty"`
@@ -115,9 +117,11 @@ func (m ChatCompletionMessage) MarshalJSON() ([]byte, error) {
115
117
}(m )
116
118
return json .Marshal (msg )
117
119
}
120
+
118
121
msg := struct {
119
122
Role string `json:"role"`
120
123
Content string `json:"content"`
124
+ Refusal string `json:"refusal,omitempty"`
121
125
MultiContent []ChatMessagePart `json:"-"`
122
126
Name string `json:"name,omitempty"`
123
127
FunctionCall * FunctionCall `json:"function_call,omitempty"`
@@ -131,19 +135,22 @@ func (m *ChatCompletionMessage) UnmarshalJSON(bs []byte) error {
131
135
msg := struct {
132
136
Role string `json:"role"`
133
137
Content string `json:"content"`
138
+ Refusal string `json:"refusal,omitempty"`
134
139
MultiContent []ChatMessagePart
135
140
Name string `json:"name,omitempty"`
136
141
FunctionCall * FunctionCall `json:"function_call,omitempty"`
137
142
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
138
143
ToolCallID string `json:"tool_call_id,omitempty"`
139
144
}{}
145
+
140
146
if err := json .Unmarshal (bs , & msg ); err == nil {
141
147
* m = ChatCompletionMessage (msg )
142
148
return nil
143
149
}
144
150
multiMsg := struct {
145
151
Role string `json:"role"`
146
152
Content string
153
+ Refusal string `json:"refusal,omitempty"`
147
154
MultiContent []ChatMessagePart `json:"content"`
148
155
Name string `json:"name,omitempty"`
149
156
FunctionCall * FunctionCall `json:"function_call,omitempty"`
0 commit comments