@@ -38,7 +38,7 @@ public class OpenAIError
38
38
public string ? Message { get ; set ; }
39
39
}
40
40
41
- public abstract class OpenAIResponse : ILanguageModelCompletionResponse
41
+ public abstract class OpenAIResponse : ILanguageModelCompletionResponse
42
42
{
43
43
public long Created { get ; set ; }
44
44
public OpenAIError ? Error { get ; set ; }
@@ -106,9 +106,63 @@ public class OpenAICompletionResponseChoice : OpenAIResponseChoice
106
106
public string Text { get ; set ; } = string . Empty ;
107
107
}
108
108
109
- public class OpenAIChatCompletionMessage : ILanguageModelChatCompletionMessage
109
+ #region content parts
110
+
111
+ public abstract class OpenAIContentPart
110
112
{
111
- public string Content { get ; set ; } = string . Empty ;
113
+ public string ? Type { get ; set ; }
114
+ }
115
+
116
+ public class OpenAITextContentPart : OpenAIContentPart
117
+ {
118
+ public string ? Text { get ; set ; }
119
+ }
120
+
121
+ public class OpenAIImageContentPartUrl
122
+ {
123
+ public string ? Detail { get ; set ; } = "auto" ;
124
+ public string ? Url { get ; set ; }
125
+ }
126
+
127
+ public class OpenAIImageContentPart : OpenAIContentPart
128
+ {
129
+ [ JsonPropertyName ( "image_url" ) ]
130
+ public OpenAIImageContentPartUrl ? Url { get ; set ; }
131
+ }
132
+
133
+ public class OpenAIAudioContentPartInputAudio
134
+ {
135
+ public string ? Data { get ; set ; }
136
+ public string ? Format { get ; set ; }
137
+ }
138
+
139
+ public class OpenAIAudioContentPart : OpenAIContentPart
140
+ {
141
+ [ JsonPropertyName ( "input_audio" ) ]
142
+ public OpenAIAudioContentPartInputAudio ? InputAudio { get ; set ; }
143
+ }
144
+
145
+ public class OpenAIFileContentPartFile
146
+ {
147
+ [ JsonPropertyName ( "file_data" ) ]
148
+ public string ? Data { get ; set ; }
149
+ [ JsonPropertyName ( "file_id" ) ]
150
+ public string ? Id { get ; set ; }
151
+ [ JsonPropertyName ( "filename" ) ]
152
+ public string ? Name { get ; set ; }
153
+ }
154
+
155
+ public class OpenAIFileContentPart : OpenAIContentPart
156
+ {
157
+ public OpenAIFileContentPartFile ? File { get ; set ; }
158
+ }
159
+
160
+ #endregion
161
+
162
+ public class OpenAIChatCompletionMessage : ILanguageModelChatCompletionMessage
163
+ {
164
+ [ JsonConverter ( typeof ( OpenAIContentPartJsonConverter ) ) ]
165
+ public object Content { get ; set ; } = string . Empty ;
112
166
public string Role { get ; set ; } = string . Empty ;
113
167
114
168
public override bool Equals ( object ? obj )
@@ -204,13 +258,13 @@ public class OpenAIFineTuneRequest : OpenAIRequest
204
258
}
205
259
206
260
public class OpenAIFineTuneResponse : OpenAIResponse
207
- {
261
+ {
208
262
[ JsonPropertyName ( "fine_tuned_model" ) ]
209
- public string ? FineTunedModel { get ; set ; }
210
- public string Status { get ; set ; } = string . Empty ;
211
- public string ? Organization { get ; set ; }
212
- public long CreatedAt { get ; set ; }
213
- public long UpdatedAt { get ; set ; }
263
+ public string ? FineTunedModel { get ; set ; }
264
+ public string Status { get ; set ; } = string . Empty ;
265
+ public string ? Organization { get ; set ; }
266
+ public long CreatedAt { get ; set ; }
267
+ public long UpdatedAt { get ; set ; }
214
268
[ JsonPropertyName ( "training_file" ) ]
215
269
public string TrainingFile { get ; set ; } = string . Empty ;
216
270
[ JsonPropertyName ( "validation_file" ) ]
@@ -233,16 +287,16 @@ public class OpenAIImageRequest : OpenAIRequest
233
287
}
234
288
235
289
public class OpenAIImageResponse : OpenAIResponse
236
- {
237
- public OpenAIImageData [ ] ? Data { get ; set ; }
290
+ {
291
+ public OpenAIImageData [ ] ? Data { get ; set ; }
238
292
public override string ? Response => null ; // Image responses don't have a text response
239
293
}
240
294
241
295
public class OpenAIImageData
242
296
{
243
- public string ? Url { get ; set ; }
297
+ public string ? Url { get ; set ; }
244
298
[ JsonPropertyName ( "b64_json" ) ]
245
- public string ? Base64Json { get ; set ; }
299
+ public string ? Base64Json { get ; set ; }
246
300
[ JsonPropertyName ( "revised_prompt" ) ]
247
301
public string ? RevisedPrompt { get ; set ; }
248
302
}
0 commit comments