-
Notifications
You must be signed in to change notification settings - Fork 35
/
betathreadmessage.go
2128 lines (1816 loc) · 65.1 KB
/
betathreadmessage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openai
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"github.com/openai/openai-go/internal/apijson"
"github.com/openai/openai-go/internal/apiquery"
"github.com/openai/openai-go/internal/param"
"github.com/openai/openai-go/internal/requestconfig"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/packages/pagination"
"github.com/tidwall/gjson"
)
// BetaThreadMessageService contains methods and other services that help with
// interacting with the openai API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaThreadMessageService] method instead.
type BetaThreadMessageService struct {
Options []option.RequestOption
}
// NewBetaThreadMessageService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewBetaThreadMessageService(opts ...option.RequestOption) (r *BetaThreadMessageService) {
r = &BetaThreadMessageService{}
r.Options = opts
return
}
// Create a message.
func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, body BetaThreadMessageNewParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
}
path := fmt.Sprintf("threads/%s/messages", threadID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Retrieve a message.
func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
}
if messageID == "" {
err = errors.New("missing required message_id parameter")
return
}
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Modifies a message.
func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
}
if messageID == "" {
err = errors.New("missing required message_id parameter")
return
}
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Returns a list of messages for a given thread.
func (r *BetaThreadMessageService) List(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Message], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
}
path := fmt.Sprintf("threads/%s/messages", threadID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Returns a list of messages for a given thread.
func (r *BetaThreadMessageService) ListAutoPaging(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Message] {
return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, query, opts...))
}
// Deletes a message.
func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
}
if messageID == "" {
err = errors.New("missing required message_id parameter")
return
}
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
type Annotation struct {
EndIndex int64 `json:"end_index,required"`
StartIndex int64 `json:"start_index,required"`
// The text in the message content that needs to be replaced.
Text string `json:"text,required"`
// Always `file_citation`.
Type AnnotationType `json:"type,required"`
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
FileCitation interface{} `json:"file_citation"`
// This field can have the runtime type of [FilePathAnnotationFilePath].
FilePath interface{} `json:"file_path"`
JSON annotationJSON `json:"-"`
union AnnotationUnion
}
// annotationJSON contains the JSON metadata for the struct [Annotation]
type annotationJSON struct {
EndIndex apijson.Field
StartIndex apijson.Field
Text apijson.Field
Type apijson.Field
FileCitation apijson.Field
FilePath apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r annotationJSON) RawJSON() string {
return r.raw
}
func (r *Annotation) UnmarshalJSON(data []byte) (err error) {
*r = Annotation{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [AnnotationUnion] interface which you can cast to the specific
// types for more type safety.
//
// Possible runtime types of the union are [FileCitationAnnotation],
// [FilePathAnnotation].
func (r Annotation) AsUnion() AnnotationUnion {
return r.union
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
//
// Union satisfied by [FileCitationAnnotation] or [FilePathAnnotation].
type AnnotationUnion interface {
implementsAnnotation()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*AnnotationUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(FileCitationAnnotation{}),
DiscriminatorValue: "file_citation",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(FilePathAnnotation{}),
DiscriminatorValue: "file_path",
},
)
}
// Always `file_citation`.
type AnnotationType string
const (
AnnotationTypeFileCitation AnnotationType = "file_citation"
AnnotationTypeFilePath AnnotationType = "file_path"
)
func (r AnnotationType) IsKnown() bool {
switch r {
case AnnotationTypeFileCitation, AnnotationTypeFilePath:
return true
}
return false
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
type AnnotationDelta struct {
// The index of the annotation in the text content part.
Index int64 `json:"index,required"`
// Always `file_citation`.
Type AnnotationDeltaType `json:"type,required"`
EndIndex int64 `json:"end_index"`
// This field can have the runtime type of
// [FileCitationDeltaAnnotationFileCitation].
FileCitation interface{} `json:"file_citation"`
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
FilePath interface{} `json:"file_path"`
StartIndex int64 `json:"start_index"`
// The text in the message content that needs to be replaced.
Text string `json:"text"`
JSON annotationDeltaJSON `json:"-"`
union AnnotationDeltaUnion
}
// annotationDeltaJSON contains the JSON metadata for the struct [AnnotationDelta]
type annotationDeltaJSON struct {
Index apijson.Field
Type apijson.Field
EndIndex apijson.Field
FileCitation apijson.Field
FilePath apijson.Field
StartIndex apijson.Field
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r annotationDeltaJSON) RawJSON() string {
return r.raw
}
func (r *AnnotationDelta) UnmarshalJSON(data []byte) (err error) {
*r = AnnotationDelta{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [AnnotationDeltaUnion] interface which you can cast to the
// specific types for more type safety.
//
// Possible runtime types of the union are [FileCitationDeltaAnnotation],
// [FilePathDeltaAnnotation].
func (r AnnotationDelta) AsUnion() AnnotationDeltaUnion {
return r.union
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
//
// Union satisfied by [FileCitationDeltaAnnotation] or [FilePathDeltaAnnotation].
type AnnotationDeltaUnion interface {
implementsAnnotationDelta()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*AnnotationDeltaUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(FileCitationDeltaAnnotation{}),
DiscriminatorValue: "file_citation",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(FilePathDeltaAnnotation{}),
DiscriminatorValue: "file_path",
},
)
}
// Always `file_citation`.
type AnnotationDeltaType string
const (
AnnotationDeltaTypeFileCitation AnnotationDeltaType = "file_citation"
AnnotationDeltaTypeFilePath AnnotationDeltaType = "file_path"
)
func (r AnnotationDeltaType) IsKnown() bool {
switch r {
case AnnotationDeltaTypeFileCitation, AnnotationDeltaTypeFilePath:
return true
}
return false
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
type FileCitationAnnotation struct {
EndIndex int64 `json:"end_index,required"`
FileCitation FileCitationAnnotationFileCitation `json:"file_citation,required"`
StartIndex int64 `json:"start_index,required"`
// The text in the message content that needs to be replaced.
Text string `json:"text,required"`
// Always `file_citation`.
Type FileCitationAnnotationType `json:"type,required"`
JSON fileCitationAnnotationJSON `json:"-"`
}
// fileCitationAnnotationJSON contains the JSON metadata for the struct
// [FileCitationAnnotation]
type fileCitationAnnotationJSON struct {
EndIndex apijson.Field
FileCitation apijson.Field
StartIndex apijson.Field
Text apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileCitationAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileCitationAnnotationJSON) RawJSON() string {
return r.raw
}
func (r FileCitationAnnotation) implementsAnnotation() {}
type FileCitationAnnotationFileCitation struct {
// The ID of the specific File the citation is from.
FileID string `json:"file_id,required"`
JSON fileCitationAnnotationFileCitationJSON `json:"-"`
}
// fileCitationAnnotationFileCitationJSON contains the JSON metadata for the struct
// [FileCitationAnnotationFileCitation]
type fileCitationAnnotationFileCitationJSON struct {
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileCitationAnnotationFileCitation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileCitationAnnotationFileCitationJSON) RawJSON() string {
return r.raw
}
// Always `file_citation`.
type FileCitationAnnotationType string
const (
FileCitationAnnotationTypeFileCitation FileCitationAnnotationType = "file_citation"
)
func (r FileCitationAnnotationType) IsKnown() bool {
switch r {
case FileCitationAnnotationTypeFileCitation:
return true
}
return false
}
// A citation within the message that points to a specific quote from a specific
// File associated with the assistant or the message. Generated when the assistant
// uses the "file_search" tool to search files.
type FileCitationDeltaAnnotation struct {
// The index of the annotation in the text content part.
Index int64 `json:"index,required"`
// Always `file_citation`.
Type FileCitationDeltaAnnotationType `json:"type,required"`
EndIndex int64 `json:"end_index"`
FileCitation FileCitationDeltaAnnotationFileCitation `json:"file_citation"`
StartIndex int64 `json:"start_index"`
// The text in the message content that needs to be replaced.
Text string `json:"text"`
JSON fileCitationDeltaAnnotationJSON `json:"-"`
}
// fileCitationDeltaAnnotationJSON contains the JSON metadata for the struct
// [FileCitationDeltaAnnotation]
type fileCitationDeltaAnnotationJSON struct {
Index apijson.Field
Type apijson.Field
EndIndex apijson.Field
FileCitation apijson.Field
StartIndex apijson.Field
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileCitationDeltaAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileCitationDeltaAnnotationJSON) RawJSON() string {
return r.raw
}
func (r FileCitationDeltaAnnotation) implementsAnnotationDelta() {}
// Always `file_citation`.
type FileCitationDeltaAnnotationType string
const (
FileCitationDeltaAnnotationTypeFileCitation FileCitationDeltaAnnotationType = "file_citation"
)
func (r FileCitationDeltaAnnotationType) IsKnown() bool {
switch r {
case FileCitationDeltaAnnotationTypeFileCitation:
return true
}
return false
}
type FileCitationDeltaAnnotationFileCitation struct {
// The ID of the specific File the citation is from.
FileID string `json:"file_id"`
// The specific quote in the file.
Quote string `json:"quote"`
JSON fileCitationDeltaAnnotationFileCitationJSON `json:"-"`
}
// fileCitationDeltaAnnotationFileCitationJSON contains the JSON metadata for the
// struct [FileCitationDeltaAnnotationFileCitation]
type fileCitationDeltaAnnotationFileCitationJSON struct {
FileID apijson.Field
Quote apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileCitationDeltaAnnotationFileCitation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileCitationDeltaAnnotationFileCitationJSON) RawJSON() string {
return r.raw
}
// A URL for the file that's generated when the assistant used the
// `code_interpreter` tool to generate a file.
type FilePathAnnotation struct {
EndIndex int64 `json:"end_index,required"`
FilePath FilePathAnnotationFilePath `json:"file_path,required"`
StartIndex int64 `json:"start_index,required"`
// The text in the message content that needs to be replaced.
Text string `json:"text,required"`
// Always `file_path`.
Type FilePathAnnotationType `json:"type,required"`
JSON filePathAnnotationJSON `json:"-"`
}
// filePathAnnotationJSON contains the JSON metadata for the struct
// [FilePathAnnotation]
type filePathAnnotationJSON struct {
EndIndex apijson.Field
FilePath apijson.Field
StartIndex apijson.Field
Text apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FilePathAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r filePathAnnotationJSON) RawJSON() string {
return r.raw
}
func (r FilePathAnnotation) implementsAnnotation() {}
type FilePathAnnotationFilePath struct {
// The ID of the file that was generated.
FileID string `json:"file_id,required"`
JSON filePathAnnotationFilePathJSON `json:"-"`
}
// filePathAnnotationFilePathJSON contains the JSON metadata for the struct
// [FilePathAnnotationFilePath]
type filePathAnnotationFilePathJSON struct {
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FilePathAnnotationFilePath) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r filePathAnnotationFilePathJSON) RawJSON() string {
return r.raw
}
// Always `file_path`.
type FilePathAnnotationType string
const (
FilePathAnnotationTypeFilePath FilePathAnnotationType = "file_path"
)
func (r FilePathAnnotationType) IsKnown() bool {
switch r {
case FilePathAnnotationTypeFilePath:
return true
}
return false
}
// A URL for the file that's generated when the assistant used the
// `code_interpreter` tool to generate a file.
type FilePathDeltaAnnotation struct {
// The index of the annotation in the text content part.
Index int64 `json:"index,required"`
// Always `file_path`.
Type FilePathDeltaAnnotationType `json:"type,required"`
EndIndex int64 `json:"end_index"`
FilePath FilePathDeltaAnnotationFilePath `json:"file_path"`
StartIndex int64 `json:"start_index"`
// The text in the message content that needs to be replaced.
Text string `json:"text"`
JSON filePathDeltaAnnotationJSON `json:"-"`
}
// filePathDeltaAnnotationJSON contains the JSON metadata for the struct
// [FilePathDeltaAnnotation]
type filePathDeltaAnnotationJSON struct {
Index apijson.Field
Type apijson.Field
EndIndex apijson.Field
FilePath apijson.Field
StartIndex apijson.Field
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FilePathDeltaAnnotation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r filePathDeltaAnnotationJSON) RawJSON() string {
return r.raw
}
func (r FilePathDeltaAnnotation) implementsAnnotationDelta() {}
// Always `file_path`.
type FilePathDeltaAnnotationType string
const (
FilePathDeltaAnnotationTypeFilePath FilePathDeltaAnnotationType = "file_path"
)
func (r FilePathDeltaAnnotationType) IsKnown() bool {
switch r {
case FilePathDeltaAnnotationTypeFilePath:
return true
}
return false
}
type FilePathDeltaAnnotationFilePath struct {
// The ID of the file that was generated.
FileID string `json:"file_id"`
JSON filePathDeltaAnnotationFilePathJSON `json:"-"`
}
// filePathDeltaAnnotationFilePathJSON contains the JSON metadata for the struct
// [FilePathDeltaAnnotationFilePath]
type filePathDeltaAnnotationFilePathJSON struct {
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FilePathDeltaAnnotationFilePath) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r filePathDeltaAnnotationFilePathJSON) RawJSON() string {
return r.raw
}
type ImageFile struct {
// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
// in the message content. Set `purpose="vision"` when uploading the File if you
// need to later display the file content.
FileID string `json:"file_id,required"`
// Specifies the detail level of the image if specified by the user. `low` uses
// fewer tokens, you can opt in to high resolution using `high`.
Detail ImageFileDetail `json:"detail"`
JSON imageFileJSON `json:"-"`
}
// imageFileJSON contains the JSON metadata for the struct [ImageFile]
type imageFileJSON struct {
FileID apijson.Field
Detail apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageFile) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageFileJSON) RawJSON() string {
return r.raw
}
// Specifies the detail level of the image if specified by the user. `low` uses
// fewer tokens, you can opt in to high resolution using `high`.
type ImageFileDetail string
const (
ImageFileDetailAuto ImageFileDetail = "auto"
ImageFileDetailLow ImageFileDetail = "low"
ImageFileDetailHigh ImageFileDetail = "high"
)
func (r ImageFileDetail) IsKnown() bool {
switch r {
case ImageFileDetailAuto, ImageFileDetailLow, ImageFileDetailHigh:
return true
}
return false
}
type ImageFileParam struct {
// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
// in the message content. Set `purpose="vision"` when uploading the File if you
// need to later display the file content.
FileID param.Field[string] `json:"file_id,required"`
// Specifies the detail level of the image if specified by the user. `low` uses
// fewer tokens, you can opt in to high resolution using `high`.
Detail param.Field[ImageFileDetail] `json:"detail"`
}
func (r ImageFileParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// References an image [File](https://platform.openai.com/docs/api-reference/files)
// in the content of a message.
type ImageFileContentBlock struct {
ImageFile ImageFile `json:"image_file,required"`
// Always `image_file`.
Type ImageFileContentBlockType `json:"type,required"`
JSON imageFileContentBlockJSON `json:"-"`
}
// imageFileContentBlockJSON contains the JSON metadata for the struct
// [ImageFileContentBlock]
type imageFileContentBlockJSON struct {
ImageFile apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageFileContentBlock) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageFileContentBlockJSON) RawJSON() string {
return r.raw
}
func (r ImageFileContentBlock) implementsMessageContent() {}
// Always `image_file`.
type ImageFileContentBlockType string
const (
ImageFileContentBlockTypeImageFile ImageFileContentBlockType = "image_file"
)
func (r ImageFileContentBlockType) IsKnown() bool {
switch r {
case ImageFileContentBlockTypeImageFile:
return true
}
return false
}
// References an image [File](https://platform.openai.com/docs/api-reference/files)
// in the content of a message.
type ImageFileContentBlockParam struct {
ImageFile param.Field[ImageFileParam] `json:"image_file,required"`
// Always `image_file`.
Type param.Field[ImageFileContentBlockType] `json:"type,required"`
}
func (r ImageFileContentBlockParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r ImageFileContentBlockParam) implementsMessageContentPartParamUnion() {}
type ImageFileDelta struct {
// Specifies the detail level of the image if specified by the user. `low` uses
// fewer tokens, you can opt in to high resolution using `high`.
Detail ImageFileDeltaDetail `json:"detail"`
// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
// in the message content. Set `purpose="vision"` when uploading the File if you
// need to later display the file content.
FileID string `json:"file_id"`
JSON imageFileDeltaJSON `json:"-"`
}
// imageFileDeltaJSON contains the JSON metadata for the struct [ImageFileDelta]
type imageFileDeltaJSON struct {
Detail apijson.Field
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageFileDelta) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageFileDeltaJSON) RawJSON() string {
return r.raw
}
// Specifies the detail level of the image if specified by the user. `low` uses
// fewer tokens, you can opt in to high resolution using `high`.
type ImageFileDeltaDetail string
const (
ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"
ImageFileDeltaDetailLow ImageFileDeltaDetail = "low"
ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"
)
func (r ImageFileDeltaDetail) IsKnown() bool {
switch r {
case ImageFileDeltaDetailAuto, ImageFileDeltaDetailLow, ImageFileDeltaDetailHigh:
return true
}
return false
}
// References an image [File](https://platform.openai.com/docs/api-reference/files)
// in the content of a message.
type ImageFileDeltaBlock struct {
// The index of the content part in the message.
Index int64 `json:"index,required"`
// Always `image_file`.
Type ImageFileDeltaBlockType `json:"type,required"`
ImageFile ImageFileDelta `json:"image_file"`
JSON imageFileDeltaBlockJSON `json:"-"`
}
// imageFileDeltaBlockJSON contains the JSON metadata for the struct
// [ImageFileDeltaBlock]
type imageFileDeltaBlockJSON struct {
Index apijson.Field
Type apijson.Field
ImageFile apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageFileDeltaBlock) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageFileDeltaBlockJSON) RawJSON() string {
return r.raw
}
func (r ImageFileDeltaBlock) implementsMessageContentDelta() {}
// Always `image_file`.
type ImageFileDeltaBlockType string
const (
ImageFileDeltaBlockTypeImageFile ImageFileDeltaBlockType = "image_file"
)
func (r ImageFileDeltaBlockType) IsKnown() bool {
switch r {
case ImageFileDeltaBlockTypeImageFile:
return true
}
return false
}
type ImageURL struct {
// The external URL of the image, must be a supported image types: jpeg, jpg, png,
// gif, webp.
URL string `json:"url,required" format:"uri"`
// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
// to high resolution using `high`. Default value is `auto`
Detail ImageURLDetail `json:"detail"`
JSON imageURLJSON `json:"-"`
}
// imageURLJSON contains the JSON metadata for the struct [ImageURL]
type imageURLJSON struct {
URL apijson.Field
Detail apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageURL) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageURLJSON) RawJSON() string {
return r.raw
}
// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
// to high resolution using `high`. Default value is `auto`
type ImageURLDetail string
const (
ImageURLDetailAuto ImageURLDetail = "auto"
ImageURLDetailLow ImageURLDetail = "low"
ImageURLDetailHigh ImageURLDetail = "high"
)
func (r ImageURLDetail) IsKnown() bool {
switch r {
case ImageURLDetailAuto, ImageURLDetailLow, ImageURLDetailHigh:
return true
}
return false
}
type ImageURLParam struct {
// The external URL of the image, must be a supported image types: jpeg, jpg, png,
// gif, webp.
URL param.Field[string] `json:"url,required" format:"uri"`
// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
// to high resolution using `high`. Default value is `auto`
Detail param.Field[ImageURLDetail] `json:"detail"`
}
func (r ImageURLParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// References an image URL in the content of a message.
type ImageURLContentBlock struct {
ImageURL ImageURL `json:"image_url,required"`
// The type of the content part.
Type ImageURLContentBlockType `json:"type,required"`
JSON imageURLContentBlockJSON `json:"-"`
}
// imageURLContentBlockJSON contains the JSON metadata for the struct
// [ImageURLContentBlock]
type imageURLContentBlockJSON struct {
ImageURL apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageURLContentBlock) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageURLContentBlockJSON) RawJSON() string {
return r.raw
}
func (r ImageURLContentBlock) implementsMessageContent() {}
// The type of the content part.
type ImageURLContentBlockType string
const (
ImageURLContentBlockTypeImageURL ImageURLContentBlockType = "image_url"
)
func (r ImageURLContentBlockType) IsKnown() bool {
switch r {
case ImageURLContentBlockTypeImageURL:
return true
}
return false
}
// References an image URL in the content of a message.
type ImageURLContentBlockParam struct {
ImageURL param.Field[ImageURLParam] `json:"image_url,required"`
// The type of the content part.
Type param.Field[ImageURLContentBlockType] `json:"type,required"`
}
func (r ImageURLContentBlockParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r ImageURLContentBlockParam) implementsMessageContentPartParamUnion() {}
type ImageURLDelta struct {
// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
// to high resolution using `high`.
Detail ImageURLDeltaDetail `json:"detail"`
// The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
// webp.
URL string `json:"url"`
JSON imageURLDeltaJSON `json:"-"`
}
// imageURLDeltaJSON contains the JSON metadata for the struct [ImageURLDelta]
type imageURLDeltaJSON struct {
Detail apijson.Field
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ImageURLDelta) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r imageURLDeltaJSON) RawJSON() string {
return r.raw
}
// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
// to high resolution using `high`.
type ImageURLDeltaDetail string
const (
ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"
ImageURLDeltaDetailLow ImageURLDeltaDetail = "low"
ImageURLDeltaDetailHigh ImageURLDeltaDetail = "high"
)
func (r ImageURLDeltaDetail) IsKnown() bool {
switch r {
case ImageURLDeltaDetailAuto, ImageURLDeltaDetailLow, ImageURLDeltaDetailHigh:
return true
}
return false
}
// References an image URL in the content of a message.
type ImageURLDeltaBlock struct {
// The index of the content part in the message.
Index int64 `json:"index,required"`
// Always `image_url`.
Type ImageURLDeltaBlockType `json:"type,required"`
ImageURL ImageURLDelta `json:"image_url"`
JSON imageURLDeltaBlockJSON `json:"-"`
}
// imageURLDeltaBlockJSON contains the JSON metadata for the struct
// [ImageURLDeltaBlock]
type imageURLDeltaBlockJSON struct {
Index apijson.Field
Type apijson.Field