@@ -9,26 +9,26 @@ import (
99
1010// ContentPart represents a single OpenAI-compatible multimodal chat content part.
1111type ContentPart struct {
12- Type string `json:"type"`
13- Text string `json:"text,omitempty"`
14- ImageURL * ImageURLContent `json:"image_url,omitempty"`
15- InputAudio * InputAudioContent `json:"input_audio,omitempty"`
16- ExtraFields map [ string ]json. RawMessage `json:"-" swaggerignore:"true"`
12+ Type string `json:"type"`
13+ Text string `json:"text,omitempty"`
14+ ImageURL * ImageURLContent `json:"image_url,omitempty"`
15+ InputAudio * InputAudioContent `json:"input_audio,omitempty"`
16+ ExtraFields UnknownJSONFields `json:"-" swaggerignore:"true"`
1717}
1818
1919// ImageURLContent contains an image reference for image_url parts.
2020type ImageURLContent struct {
21- URL string `json:"url"`
22- Detail string `json:"detail,omitempty"`
23- MediaType string `json:"media_type,omitempty"`
24- ExtraFields map [ string ]json. RawMessage `json:"-" swaggerignore:"true"`
21+ URL string `json:"url"`
22+ Detail string `json:"detail,omitempty"`
23+ MediaType string `json:"media_type,omitempty"`
24+ ExtraFields UnknownJSONFields `json:"-" swaggerignore:"true"`
2525}
2626
2727// InputAudioContent contains inline audio payload metadata.
2828type InputAudioContent struct {
29- Data string `json:"data"`
30- Format string `json:"format"`
31- ExtraFields map [ string ]json. RawMessage `json:"-" swaggerignore:"true"`
29+ Data string `json:"data"`
30+ Format string `json:"format"`
31+ ExtraFields UnknownJSONFields `json:"-" swaggerignore:"true"`
3232}
3333
3434func (p * ContentPart ) UnmarshalJSON (data []byte ) error {
@@ -97,7 +97,7 @@ func (c *ImageURLContent) UnmarshalJSON(data []byte) error {
9797 c .URL = url
9898 c .Detail = ""
9999 c .MediaType = ""
100- c .ExtraFields = nil
100+ c .ExtraFields = UnknownJSONFields {}
101101 return nil
102102 }
103103
@@ -412,7 +412,7 @@ func normalizeTypedContentPart(part ContentPart) (ContentPart, error) {
412412 return ContentPart {
413413 Type : "text" ,
414414 Text : part .Text ,
415- ExtraFields : CloneRawJSONMap (part .ExtraFields ),
415+ ExtraFields : CloneUnknownJSONFields (part .ExtraFields ),
416416 }, nil
417417 case "image_url" , "input_image" :
418418 if part .ImageURL == nil || part .ImageURL .URL == "" {
@@ -424,9 +424,9 @@ func normalizeTypedContentPart(part ContentPart) (ContentPart, error) {
424424 URL : part .ImageURL .URL ,
425425 Detail : part .ImageURL .Detail ,
426426 MediaType : part .ImageURL .MediaType ,
427- ExtraFields : CloneRawJSONMap (part .ImageURL .ExtraFields ),
427+ ExtraFields : CloneUnknownJSONFields (part .ImageURL .ExtraFields ),
428428 },
429- ExtraFields : CloneRawJSONMap (part .ExtraFields ),
429+ ExtraFields : CloneUnknownJSONFields (part .ExtraFields ),
430430 }, nil
431431 case "input_audio" :
432432 if part .InputAudio == nil || part .InputAudio .Data == "" || part .InputAudio .Format == "" {
@@ -437,9 +437,9 @@ func normalizeTypedContentPart(part ContentPart) (ContentPart, error) {
437437 InputAudio : & InputAudioContent {
438438 Data : part .InputAudio .Data ,
439439 Format : part .InputAudio .Format ,
440- ExtraFields : CloneRawJSONMap (part .InputAudio .ExtraFields ),
440+ ExtraFields : CloneUnknownJSONFields (part .InputAudio .ExtraFields ),
441441 },
442- ExtraFields : CloneRawJSONMap (part .ExtraFields ),
442+ ExtraFields : CloneUnknownJSONFields (part .ExtraFields ),
443443 }, nil
444444 default :
445445 return ContentPart {}, fmt .Errorf ("unsupported content part type %q" , part .Type )
0 commit comments