-
Notifications
You must be signed in to change notification settings - Fork 28
/
betathreadrunstep.go
1985 lines (1706 loc) · 62.6 KB
/
betathreadrunstep.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"
)
// BetaThreadRunStepService 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 [NewBetaThreadRunStepService] method instead.
type BetaThreadRunStepService struct {
Options []option.RequestOption
}
// NewBetaThreadRunStepService 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 NewBetaThreadRunStepService(opts ...option.RequestOption) (r *BetaThreadRunStepService) {
r = &BetaThreadRunStepService{}
r.Options = opts
return
}
// Retrieves a run step.
func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, 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 runID == "" {
err = errors.New("missing required run_id parameter")
return
}
if stepID == "" {
err = errors.New("missing required step_id parameter")
return
}
path := fmt.Sprintf("threads/%s/runs/%s/steps/%s", threadID, runID, stepID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
// Returns a list of run steps belonging to a run.
func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) (res *pagination.CursorPage[RunStep], 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
}
if runID == "" {
err = errors.New("missing required run_id parameter")
return
}
path := fmt.Sprintf("threads/%s/runs/%s/steps", threadID, runID)
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 run steps belonging to a run.
func (r *BetaThreadRunStepService) ListAutoPaging(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[RunStep] {
return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, runID, query, opts...))
}
// Text output from the Code Interpreter tool call as part of a run step.
type CodeInterpreterLogs struct {
// The index of the output in the outputs array.
Index int64 `json:"index,required"`
// Always `logs`.
Type CodeInterpreterLogsType `json:"type,required"`
// The text output from the Code Interpreter tool call.
Logs string `json:"logs"`
JSON codeInterpreterLogsJSON `json:"-"`
}
// codeInterpreterLogsJSON contains the JSON metadata for the struct
// [CodeInterpreterLogs]
type codeInterpreterLogsJSON struct {
Index apijson.Field
Type apijson.Field
Logs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterLogs) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterLogsJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterLogs) implementsCodeInterpreterToolCallDeltaCodeInterpreterOutput() {}
// Always `logs`.
type CodeInterpreterLogsType string
const (
CodeInterpreterLogsTypeLogs CodeInterpreterLogsType = "logs"
)
func (r CodeInterpreterLogsType) IsKnown() bool {
switch r {
case CodeInterpreterLogsTypeLogs:
return true
}
return false
}
type CodeInterpreterOutputImage struct {
// The index of the output in the outputs array.
Index int64 `json:"index,required"`
// Always `image`.
Type CodeInterpreterOutputImageType `json:"type,required"`
Image CodeInterpreterOutputImageImage `json:"image"`
JSON codeInterpreterOutputImageJSON `json:"-"`
}
// codeInterpreterOutputImageJSON contains the JSON metadata for the struct
// [CodeInterpreterOutputImage]
type codeInterpreterOutputImageJSON struct {
Index apijson.Field
Type apijson.Field
Image apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterOutputImage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterOutputImageJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterOutputImage) implementsCodeInterpreterToolCallDeltaCodeInterpreterOutput() {}
// Always `image`.
type CodeInterpreterOutputImageType string
const (
CodeInterpreterOutputImageTypeImage CodeInterpreterOutputImageType = "image"
)
func (r CodeInterpreterOutputImageType) IsKnown() bool {
switch r {
case CodeInterpreterOutputImageTypeImage:
return true
}
return false
}
type CodeInterpreterOutputImageImage struct {
// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
// image.
FileID string `json:"file_id"`
JSON codeInterpreterOutputImageImageJSON `json:"-"`
}
// codeInterpreterOutputImageImageJSON contains the JSON metadata for the struct
// [CodeInterpreterOutputImageImage]
type codeInterpreterOutputImageImageJSON struct {
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterOutputImageImage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterOutputImageImageJSON) RawJSON() string {
return r.raw
}
// Details of the Code Interpreter tool call the run step was involved in.
type CodeInterpreterToolCall struct {
// The ID of the tool call.
ID string `json:"id,required"`
// The Code Interpreter tool call definition.
CodeInterpreter CodeInterpreterToolCallCodeInterpreter `json:"code_interpreter,required"`
// The type of tool call. This is always going to be `code_interpreter` for this
// type of tool call.
Type CodeInterpreterToolCallType `json:"type,required"`
JSON codeInterpreterToolCallJSON `json:"-"`
}
// codeInterpreterToolCallJSON contains the JSON metadata for the struct
// [CodeInterpreterToolCall]
type codeInterpreterToolCallJSON struct {
ID apijson.Field
CodeInterpreter apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCall) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterToolCall) implementsToolCall() {}
// The Code Interpreter tool call definition.
type CodeInterpreterToolCallCodeInterpreter struct {
// The input to the Code Interpreter tool call.
Input string `json:"input,required"`
// The outputs from the Code Interpreter tool call. Code Interpreter can output one
// or more items, including text (`logs`) or images (`image`). Each of these are
// represented by a different object type.
Outputs []CodeInterpreterToolCallCodeInterpreterOutput `json:"outputs,required"`
JSON codeInterpreterToolCallCodeInterpreterJSON `json:"-"`
}
// codeInterpreterToolCallCodeInterpreterJSON contains the JSON metadata for the
// struct [CodeInterpreterToolCallCodeInterpreter]
type codeInterpreterToolCallCodeInterpreterJSON struct {
Input apijson.Field
Outputs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallCodeInterpreter) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallCodeInterpreterJSON) RawJSON() string {
return r.raw
}
// Text output from the Code Interpreter tool call as part of a run step.
type CodeInterpreterToolCallCodeInterpreterOutput struct {
// Always `logs`.
Type CodeInterpreterToolCallCodeInterpreterOutputsType `json:"type,required"`
// This field can have the runtime type of
// [CodeInterpreterToolCallCodeInterpreterOutputsImageImage].
Image interface{} `json:"image"`
// The text output from the Code Interpreter tool call.
Logs string `json:"logs"`
JSON codeInterpreterToolCallCodeInterpreterOutputJSON `json:"-"`
union CodeInterpreterToolCallCodeInterpreterOutputsUnion
}
// codeInterpreterToolCallCodeInterpreterOutputJSON contains the JSON metadata for
// the struct [CodeInterpreterToolCallCodeInterpreterOutput]
type codeInterpreterToolCallCodeInterpreterOutputJSON struct {
Type apijson.Field
Image apijson.Field
Logs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r codeInterpreterToolCallCodeInterpreterOutputJSON) RawJSON() string {
return r.raw
}
func (r *CodeInterpreterToolCallCodeInterpreterOutput) UnmarshalJSON(data []byte) (err error) {
*r = CodeInterpreterToolCallCodeInterpreterOutput{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [CodeInterpreterToolCallCodeInterpreterOutputsUnion] interface
// which you can cast to the specific types for more type safety.
//
// Possible runtime types of the union are
// [CodeInterpreterToolCallCodeInterpreterOutputsLogs],
// [CodeInterpreterToolCallCodeInterpreterOutputsImage].
func (r CodeInterpreterToolCallCodeInterpreterOutput) AsUnion() CodeInterpreterToolCallCodeInterpreterOutputsUnion {
return r.union
}
// Text output from the Code Interpreter tool call as part of a run step.
//
// Union satisfied by [CodeInterpreterToolCallCodeInterpreterOutputsLogs] or
// [CodeInterpreterToolCallCodeInterpreterOutputsImage].
type CodeInterpreterToolCallCodeInterpreterOutputsUnion interface {
implementsCodeInterpreterToolCallCodeInterpreterOutput()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*CodeInterpreterToolCallCodeInterpreterOutputsUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(CodeInterpreterToolCallCodeInterpreterOutputsLogs{}),
DiscriminatorValue: "logs",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(CodeInterpreterToolCallCodeInterpreterOutputsImage{}),
DiscriminatorValue: "image",
},
)
}
// Text output from the Code Interpreter tool call as part of a run step.
type CodeInterpreterToolCallCodeInterpreterOutputsLogs struct {
// The text output from the Code Interpreter tool call.
Logs string `json:"logs,required"`
// Always `logs`.
Type CodeInterpreterToolCallCodeInterpreterOutputsLogsType `json:"type,required"`
JSON codeInterpreterToolCallCodeInterpreterOutputsLogsJSON `json:"-"`
}
// codeInterpreterToolCallCodeInterpreterOutputsLogsJSON contains the JSON metadata
// for the struct [CodeInterpreterToolCallCodeInterpreterOutputsLogs]
type codeInterpreterToolCallCodeInterpreterOutputsLogsJSON struct {
Logs apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallCodeInterpreterOutputsLogs) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallCodeInterpreterOutputsLogsJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterToolCallCodeInterpreterOutputsLogs) implementsCodeInterpreterToolCallCodeInterpreterOutput() {
}
// Always `logs`.
type CodeInterpreterToolCallCodeInterpreterOutputsLogsType string
const (
CodeInterpreterToolCallCodeInterpreterOutputsLogsTypeLogs CodeInterpreterToolCallCodeInterpreterOutputsLogsType = "logs"
)
func (r CodeInterpreterToolCallCodeInterpreterOutputsLogsType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallCodeInterpreterOutputsLogsTypeLogs:
return true
}
return false
}
type CodeInterpreterToolCallCodeInterpreterOutputsImage struct {
Image CodeInterpreterToolCallCodeInterpreterOutputsImageImage `json:"image,required"`
// Always `image`.
Type CodeInterpreterToolCallCodeInterpreterOutputsImageType `json:"type,required"`
JSON codeInterpreterToolCallCodeInterpreterOutputsImageJSON `json:"-"`
}
// codeInterpreterToolCallCodeInterpreterOutputsImageJSON contains the JSON
// metadata for the struct [CodeInterpreterToolCallCodeInterpreterOutputsImage]
type codeInterpreterToolCallCodeInterpreterOutputsImageJSON struct {
Image apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallCodeInterpreterOutputsImage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallCodeInterpreterOutputsImageJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterToolCallCodeInterpreterOutputsImage) implementsCodeInterpreterToolCallCodeInterpreterOutput() {
}
type CodeInterpreterToolCallCodeInterpreterOutputsImageImage struct {
// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
// image.
FileID string `json:"file_id,required"`
JSON codeInterpreterToolCallCodeInterpreterOutputsImageImageJSON `json:"-"`
}
// codeInterpreterToolCallCodeInterpreterOutputsImageImageJSON contains the JSON
// metadata for the struct
// [CodeInterpreterToolCallCodeInterpreterOutputsImageImage]
type codeInterpreterToolCallCodeInterpreterOutputsImageImageJSON struct {
FileID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallCodeInterpreterOutputsImageImage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallCodeInterpreterOutputsImageImageJSON) RawJSON() string {
return r.raw
}
// Always `image`.
type CodeInterpreterToolCallCodeInterpreterOutputsImageType string
const (
CodeInterpreterToolCallCodeInterpreterOutputsImageTypeImage CodeInterpreterToolCallCodeInterpreterOutputsImageType = "image"
)
func (r CodeInterpreterToolCallCodeInterpreterOutputsImageType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallCodeInterpreterOutputsImageTypeImage:
return true
}
return false
}
// Always `logs`.
type CodeInterpreterToolCallCodeInterpreterOutputsType string
const (
CodeInterpreterToolCallCodeInterpreterOutputsTypeLogs CodeInterpreterToolCallCodeInterpreterOutputsType = "logs"
CodeInterpreterToolCallCodeInterpreterOutputsTypeImage CodeInterpreterToolCallCodeInterpreterOutputsType = "image"
)
func (r CodeInterpreterToolCallCodeInterpreterOutputsType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallCodeInterpreterOutputsTypeLogs, CodeInterpreterToolCallCodeInterpreterOutputsTypeImage:
return true
}
return false
}
// The type of tool call. This is always going to be `code_interpreter` for this
// type of tool call.
type CodeInterpreterToolCallType string
const (
CodeInterpreterToolCallTypeCodeInterpreter CodeInterpreterToolCallType = "code_interpreter"
)
func (r CodeInterpreterToolCallType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallTypeCodeInterpreter:
return true
}
return false
}
// Details of the Code Interpreter tool call the run step was involved in.
type CodeInterpreterToolCallDelta struct {
// The index of the tool call in the tool calls array.
Index int64 `json:"index,required"`
// The type of tool call. This is always going to be `code_interpreter` for this
// type of tool call.
Type CodeInterpreterToolCallDeltaType `json:"type,required"`
// The ID of the tool call.
ID string `json:"id"`
// The Code Interpreter tool call definition.
CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter `json:"code_interpreter"`
JSON codeInterpreterToolCallDeltaJSON `json:"-"`
}
// codeInterpreterToolCallDeltaJSON contains the JSON metadata for the struct
// [CodeInterpreterToolCallDelta]
type codeInterpreterToolCallDeltaJSON struct {
Index apijson.Field
Type apijson.Field
ID apijson.Field
CodeInterpreter apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallDelta) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallDeltaJSON) RawJSON() string {
return r.raw
}
func (r CodeInterpreterToolCallDelta) implementsToolCallDelta() {}
// The type of tool call. This is always going to be `code_interpreter` for this
// type of tool call.
type CodeInterpreterToolCallDeltaType string
const (
CodeInterpreterToolCallDeltaTypeCodeInterpreter CodeInterpreterToolCallDeltaType = "code_interpreter"
)
func (r CodeInterpreterToolCallDeltaType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallDeltaTypeCodeInterpreter:
return true
}
return false
}
// The Code Interpreter tool call definition.
type CodeInterpreterToolCallDeltaCodeInterpreter struct {
// The input to the Code Interpreter tool call.
Input string `json:"input"`
// The outputs from the Code Interpreter tool call. Code Interpreter can output one
// or more items, including text (`logs`) or images (`image`). Each of these are
// represented by a different object type.
Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutput `json:"outputs"`
JSON codeInterpreterToolCallDeltaCodeInterpreterJSON `json:"-"`
}
// codeInterpreterToolCallDeltaCodeInterpreterJSON contains the JSON metadata for
// the struct [CodeInterpreterToolCallDeltaCodeInterpreter]
type codeInterpreterToolCallDeltaCodeInterpreterJSON struct {
Input apijson.Field
Outputs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CodeInterpreterToolCallDeltaCodeInterpreter) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r codeInterpreterToolCallDeltaCodeInterpreterJSON) RawJSON() string {
return r.raw
}
// Text output from the Code Interpreter tool call as part of a run step.
type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct {
// The index of the output in the outputs array.
Index int64 `json:"index,required"`
// Always `logs`.
Type CodeInterpreterToolCallDeltaCodeInterpreterOutputsType `json:"type,required"`
// This field can have the runtime type of [CodeInterpreterOutputImageImage].
Image interface{} `json:"image"`
// The text output from the Code Interpreter tool call.
Logs string `json:"logs"`
JSON codeInterpreterToolCallDeltaCodeInterpreterOutputJSON `json:"-"`
union CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion
}
// codeInterpreterToolCallDeltaCodeInterpreterOutputJSON contains the JSON metadata
// for the struct [CodeInterpreterToolCallDeltaCodeInterpreterOutput]
type codeInterpreterToolCallDeltaCodeInterpreterOutputJSON struct {
Index apijson.Field
Type apijson.Field
Image apijson.Field
Logs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r codeInterpreterToolCallDeltaCodeInterpreterOutputJSON) RawJSON() string {
return r.raw
}
func (r *CodeInterpreterToolCallDeltaCodeInterpreterOutput) UnmarshalJSON(data []byte) (err error) {
*r = CodeInterpreterToolCallDeltaCodeInterpreterOutput{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion]
// interface which you can cast to the specific types for more type safety.
//
// Possible runtime types of the union are [CodeInterpreterLogs],
// [CodeInterpreterOutputImage].
func (r CodeInterpreterToolCallDeltaCodeInterpreterOutput) AsUnion() CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion {
return r.union
}
// Text output from the Code Interpreter tool call as part of a run step.
//
// Union satisfied by [CodeInterpreterLogs] or [CodeInterpreterOutputImage].
type CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion interface {
implementsCodeInterpreterToolCallDeltaCodeInterpreterOutput()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(CodeInterpreterLogs{}),
DiscriminatorValue: "logs",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(CodeInterpreterOutputImage{}),
DiscriminatorValue: "image",
},
)
}
// Always `logs`.
type CodeInterpreterToolCallDeltaCodeInterpreterOutputsType string
const (
CodeInterpreterToolCallDeltaCodeInterpreterOutputsTypeLogs CodeInterpreterToolCallDeltaCodeInterpreterOutputsType = "logs"
CodeInterpreterToolCallDeltaCodeInterpreterOutputsTypeImage CodeInterpreterToolCallDeltaCodeInterpreterOutputsType = "image"
)
func (r CodeInterpreterToolCallDeltaCodeInterpreterOutputsType) IsKnown() bool {
switch r {
case CodeInterpreterToolCallDeltaCodeInterpreterOutputsTypeLogs, CodeInterpreterToolCallDeltaCodeInterpreterOutputsTypeImage:
return true
}
return false
}
type FileSearchToolCall struct {
// The ID of the tool call object.
ID string `json:"id,required"`
// For now, this is always going to be an empty object.
FileSearch FileSearchToolCallFileSearch `json:"file_search,required"`
// The type of tool call. This is always going to be `file_search` for this type of
// tool call.
Type FileSearchToolCallType `json:"type,required"`
JSON fileSearchToolCallJSON `json:"-"`
}
// fileSearchToolCallJSON contains the JSON metadata for the struct
// [FileSearchToolCall]
type fileSearchToolCallJSON struct {
ID apijson.Field
FileSearch apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCall) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallJSON) RawJSON() string {
return r.raw
}
func (r FileSearchToolCall) implementsToolCall() {}
// For now, this is always going to be an empty object.
type FileSearchToolCallFileSearch struct {
// The ranking options for the file search.
RankingOptions FileSearchToolCallFileSearchRankingOptions `json:"ranking_options"`
// The results of the file search.
Results []FileSearchToolCallFileSearchResult `json:"results"`
JSON fileSearchToolCallFileSearchJSON `json:"-"`
}
// fileSearchToolCallFileSearchJSON contains the JSON metadata for the struct
// [FileSearchToolCallFileSearch]
type fileSearchToolCallFileSearchJSON struct {
RankingOptions apijson.Field
Results apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCallFileSearch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallFileSearchJSON) RawJSON() string {
return r.raw
}
// The ranking options for the file search.
type FileSearchToolCallFileSearchRankingOptions struct {
// The ranker used for the file search.
Ranker FileSearchToolCallFileSearchRankingOptionsRanker `json:"ranker,required"`
// The score threshold for the file search. All values must be a floating point
// number between 0 and 1.
ScoreThreshold float64 `json:"score_threshold,required"`
JSON fileSearchToolCallFileSearchRankingOptionsJSON `json:"-"`
}
// fileSearchToolCallFileSearchRankingOptionsJSON contains the JSON metadata for
// the struct [FileSearchToolCallFileSearchRankingOptions]
type fileSearchToolCallFileSearchRankingOptionsJSON struct {
Ranker apijson.Field
ScoreThreshold apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCallFileSearchRankingOptions) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallFileSearchRankingOptionsJSON) RawJSON() string {
return r.raw
}
// The ranker used for the file search.
type FileSearchToolCallFileSearchRankingOptionsRanker string
const (
FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21"
)
func (r FileSearchToolCallFileSearchRankingOptionsRanker) IsKnown() bool {
switch r {
case FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21:
return true
}
return false
}
// A result instance of the file search.
type FileSearchToolCallFileSearchResult struct {
// The ID of the file that result was found in.
FileID string `json:"file_id,required"`
// The name of the file that result was found in.
FileName string `json:"file_name,required"`
// The score of the result. All values must be a floating point number between 0
// and 1.
Score float64 `json:"score,required"`
// The content of the result that was found. The content is only included if
// requested via the include query parameter.
Content []FileSearchToolCallFileSearchResultsContent `json:"content"`
JSON fileSearchToolCallFileSearchResultJSON `json:"-"`
}
// fileSearchToolCallFileSearchResultJSON contains the JSON metadata for the struct
// [FileSearchToolCallFileSearchResult]
type fileSearchToolCallFileSearchResultJSON struct {
FileID apijson.Field
FileName apijson.Field
Score apijson.Field
Content apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCallFileSearchResult) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallFileSearchResultJSON) RawJSON() string {
return r.raw
}
type FileSearchToolCallFileSearchResultsContent struct {
// The text content of the file.
Text string `json:"text"`
// The type of the content.
Type FileSearchToolCallFileSearchResultsContentType `json:"type"`
JSON fileSearchToolCallFileSearchResultsContentJSON `json:"-"`
}
// fileSearchToolCallFileSearchResultsContentJSON contains the JSON metadata for
// the struct [FileSearchToolCallFileSearchResultsContent]
type fileSearchToolCallFileSearchResultsContentJSON struct {
Text apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCallFileSearchResultsContent) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallFileSearchResultsContentJSON) RawJSON() string {
return r.raw
}
// The type of the content.
type FileSearchToolCallFileSearchResultsContentType string
const (
FileSearchToolCallFileSearchResultsContentTypeText FileSearchToolCallFileSearchResultsContentType = "text"
)
func (r FileSearchToolCallFileSearchResultsContentType) IsKnown() bool {
switch r {
case FileSearchToolCallFileSearchResultsContentTypeText:
return true
}
return false
}
// The type of tool call. This is always going to be `file_search` for this type of
// tool call.
type FileSearchToolCallType string
const (
FileSearchToolCallTypeFileSearch FileSearchToolCallType = "file_search"
)
func (r FileSearchToolCallType) IsKnown() bool {
switch r {
case FileSearchToolCallTypeFileSearch:
return true
}
return false
}
type FileSearchToolCallDelta struct {
// For now, this is always going to be an empty object.
FileSearch interface{} `json:"file_search,required"`
// The index of the tool call in the tool calls array.
Index int64 `json:"index,required"`
// The type of tool call. This is always going to be `file_search` for this type of
// tool call.
Type FileSearchToolCallDeltaType `json:"type,required"`
// The ID of the tool call object.
ID string `json:"id"`
JSON fileSearchToolCallDeltaJSON `json:"-"`
}
// fileSearchToolCallDeltaJSON contains the JSON metadata for the struct
// [FileSearchToolCallDelta]
type fileSearchToolCallDeltaJSON struct {
FileSearch apijson.Field
Index apijson.Field
Type apijson.Field
ID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FileSearchToolCallDelta) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fileSearchToolCallDeltaJSON) RawJSON() string {
return r.raw
}
func (r FileSearchToolCallDelta) implementsToolCallDelta() {}
// The type of tool call. This is always going to be `file_search` for this type of
// tool call.
type FileSearchToolCallDeltaType string
const (
FileSearchToolCallDeltaTypeFileSearch FileSearchToolCallDeltaType = "file_search"
)
func (r FileSearchToolCallDeltaType) IsKnown() bool {
switch r {
case FileSearchToolCallDeltaTypeFileSearch:
return true
}
return false
}
type FunctionToolCall struct {
// The ID of the tool call object.
ID string `json:"id,required"`
// The definition of the function that was called.
Function FunctionToolCallFunction `json:"function,required"`
// The type of tool call. This is always going to be `function` for this type of
// tool call.
Type FunctionToolCallType `json:"type,required"`
JSON functionToolCallJSON `json:"-"`
}
// functionToolCallJSON contains the JSON metadata for the struct
// [FunctionToolCall]
type functionToolCallJSON struct {
ID apijson.Field
Function apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FunctionToolCall) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r functionToolCallJSON) RawJSON() string {
return r.raw
}
func (r FunctionToolCall) implementsToolCall() {}
// The definition of the function that was called.
type FunctionToolCallFunction struct {
// The arguments passed to the function.
Arguments string `json:"arguments,required"`
// The name of the function.
Name string `json:"name,required"`
// The output of the function. This will be `null` if the outputs have not been
// [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
// yet.
Output string `json:"output,required,nullable"`
JSON functionToolCallFunctionJSON `json:"-"`
}
// functionToolCallFunctionJSON contains the JSON metadata for the struct
// [FunctionToolCallFunction]
type functionToolCallFunctionJSON struct {
Arguments apijson.Field
Name apijson.Field
Output apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FunctionToolCallFunction) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r functionToolCallFunctionJSON) RawJSON() string {
return r.raw
}
// The type of tool call. This is always going to be `function` for this type of
// tool call.
type FunctionToolCallType string
const (
FunctionToolCallTypeFunction FunctionToolCallType = "function"
)
func (r FunctionToolCallType) IsKnown() bool {
switch r {
case FunctionToolCallTypeFunction:
return true
}
return false
}
type FunctionToolCallDelta struct {
// The index of the tool call in the tool calls array.
Index int64 `json:"index,required"`
// The type of tool call. This is always going to be `function` for this type of
// tool call.
Type FunctionToolCallDeltaType `json:"type,required"`
// The ID of the tool call object.
ID string `json:"id"`
// The definition of the function that was called.
Function FunctionToolCallDeltaFunction `json:"function"`
JSON functionToolCallDeltaJSON `json:"-"`
}
// functionToolCallDeltaJSON contains the JSON metadata for the struct
// [FunctionToolCallDelta]
type functionToolCallDeltaJSON struct {
Index apijson.Field
Type apijson.Field
ID apijson.Field
Function apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FunctionToolCallDelta) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r functionToolCallDeltaJSON) RawJSON() string {
return r.raw
}
func (r FunctionToolCallDelta) implementsToolCallDelta() {}
// The type of tool call. This is always going to be `function` for this type of
// tool call.
type FunctionToolCallDeltaType string
const (