forked from openai/openai-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradergradermodel.go
More file actions
1753 lines (1596 loc) · 66.1 KB
/
gradergradermodel.go
File metadata and controls
1753 lines (1596 loc) · 66.1 KB
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 (
"encoding/json"
"github.com/openai/openai-go/v3/internal/apijson"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/packages/param"
"github.com/openai/openai-go/v3/packages/respjson"
"github.com/openai/openai-go/v3/responses"
"github.com/openai/openai-go/v3/shared"
"github.com/openai/openai-go/v3/shared/constant"
)
// GraderGraderModelService 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 [NewGraderGraderModelService] method instead.
type GraderGraderModelService struct {
Options []option.RequestOption
}
// NewGraderGraderModelService 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 NewGraderGraderModelService(opts ...option.RequestOption) (r GraderGraderModelService) {
r = GraderGraderModelService{}
r.Options = opts
return
}
type GraderInputs []GraderInputUnion
// GraderInputUnion contains all possible properties and values from [string],
// [responses.ResponseInputText], [GraderInputOutputText], [GraderInputInputImage],
// [responses.ResponseInputAudio].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString]
type GraderInputUnion struct {
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
Text string `json:"text"`
Type string `json:"type"`
// This field is from variant [GraderInputInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [GraderInputInputImage].
Detail string `json:"detail"`
// This field is from variant [responses.ResponseInputAudio].
InputAudio responses.ResponseInputAudioInputAudio `json:"input_audio"`
JSON struct {
OfString respjson.Field
Text respjson.Field
Type respjson.Field
ImageURL respjson.Field
Detail respjson.Field
InputAudio respjson.Field
raw string
} `json:"-"`
}
func (u GraderInputUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u GraderInputUnion) AsInputText() (v responses.ResponseInputText) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u GraderInputUnion) AsOutputText() (v GraderInputOutputText) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u GraderInputUnion) AsInputImage() (v GraderInputInputImage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u GraderInputUnion) AsInputAudio() (v responses.ResponseInputAudio) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u GraderInputUnion) RawJSON() string { return u.JSON.raw }
func (r *GraderInputUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A text output from the model.
type GraderInputOutputText struct {
// The text output from the model.
Text string `json:"text" api:"required"`
// The type of the output text. Always `output_text`.
Type constant.OutputText `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Text respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r GraderInputOutputText) RawJSON() string { return r.JSON.raw }
func (r *GraderInputOutputText) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An image input block used within EvalItem content arrays.
type GraderInputInputImage struct {
// The URL of the image input.
ImageURL string `json:"image_url" api:"required"`
// The type of the image input. Always `input_image`.
Type constant.InputImage `json:"type" api:"required"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail string `json:"detail"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ImageURL respjson.Field
Type respjson.Field
Detail respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r GraderInputInputImage) RawJSON() string { return r.JSON.raw }
func (r *GraderInputInputImage) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type GraderInputsParam []GraderInputUnionParam
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type GraderInputUnionParam struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfInputText *responses.ResponseInputTextParam `json:",omitzero,inline"`
OfOutputText *GraderInputOutputTextParam `json:",omitzero,inline"`
OfInputImage *GraderInputInputImageParam `json:",omitzero,inline"`
OfInputAudio *responses.ResponseInputAudioParam `json:",omitzero,inline"`
paramUnion
}
func (u GraderInputUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfString,
u.OfInputText,
u.OfOutputText,
u.OfInputImage,
u.OfInputAudio)
}
func (u *GraderInputUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *GraderInputUnionParam) asAny() any {
if !param.IsOmitted(u.OfString) {
return &u.OfString.Value
} else if !param.IsOmitted(u.OfInputText) {
return u.OfInputText
} else if !param.IsOmitted(u.OfOutputText) {
return u.OfOutputText
} else if !param.IsOmitted(u.OfInputImage) {
return u.OfInputImage
} else if !param.IsOmitted(u.OfInputAudio) {
return u.OfInputAudio
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetImageURL() *string {
if vt := u.OfInputImage; vt != nil {
return &vt.ImageURL
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetDetail() *string {
if vt := u.OfInputImage; vt != nil && vt.Detail.Valid() {
return &vt.Detail.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetInputAudio() *responses.ResponseInputAudioInputAudioParam {
if vt := u.OfInputAudio; vt != nil {
return &vt.InputAudio
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetText() *string {
if vt := u.OfInputText; vt != nil {
return (*string)(&vt.Text)
} else if vt := u.OfOutputText; vt != nil {
return (*string)(&vt.Text)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u GraderInputUnionParam) GetType() *string {
if vt := u.OfInputText; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfOutputText; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfInputImage; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfInputAudio; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
// A text output from the model.
//
// The properties Text, Type are required.
type GraderInputOutputTextParam struct {
// The text output from the model.
Text string `json:"text" api:"required"`
// The type of the output text. Always `output_text`.
//
// This field can be elided, and will marshal its zero value as "output_text".
Type constant.OutputText `json:"type" api:"required"`
paramObj
}
func (r GraderInputOutputTextParam) MarshalJSON() (data []byte, err error) {
type shadow GraderInputOutputTextParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *GraderInputOutputTextParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An image input block used within EvalItem content arrays.
//
// The properties ImageURL, Type are required.
type GraderInputInputImageParam struct {
// The URL of the image input.
ImageURL string `json:"image_url" api:"required"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail param.Opt[string] `json:"detail,omitzero"`
// The type of the image input. Always `input_image`.
//
// This field can be elided, and will marshal its zero value as "input_image".
Type constant.InputImage `json:"type" api:"required"`
paramObj
}
func (r GraderInputInputImageParam) MarshalJSON() (data []byte, err error) {
type shadow GraderInputInputImageParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *GraderInputInputImageParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A LabelModelGrader object which uses a model to assign labels to each item in
// the evaluation.
type LabelModelGrader struct {
Input []LabelModelGraderInput `json:"input" api:"required"`
// The labels to assign to each item in the evaluation.
Labels []string `json:"labels" api:"required"`
// The model to use for the evaluation. Must support structured outputs.
Model string `json:"model" api:"required"`
// The name of the grader.
Name string `json:"name" api:"required"`
// The labels that indicate a passing result. Must be a subset of labels.
PassingLabels []string `json:"passing_labels" api:"required"`
// The object type, which is always `label_model`.
Type constant.LabelModel `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Input respjson.Field
Labels respjson.Field
Model respjson.Field
Name respjson.Field
PassingLabels respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r LabelModelGrader) RawJSON() string { return r.JSON.raw }
func (r *LabelModelGrader) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ToParam converts this LabelModelGrader to a LabelModelGraderParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// LabelModelGraderParam.Overrides()
func (r LabelModelGrader) ToParam() LabelModelGraderParam {
return param.Override[LabelModelGraderParam](json.RawMessage(r.RawJSON()))
}
// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role. Messages with the
// `assistant` role are presumed to have been generated by the model in previous
// interactions.
type LabelModelGraderInput struct {
// Inputs to the model - can contain template strings. Supports text, output text,
// input images, and input audio, either as a single item or an array of items.
Content LabelModelGraderInputContentUnion `json:"content" api:"required"`
// The role of the message input. One of `user`, `assistant`, `system`, or
// `developer`.
//
// Any of "user", "assistant", "system", "developer".
Role string `json:"role" api:"required"`
// The type of the message input. Always `message`.
//
// Any of "message".
Type string `json:"type"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Content respjson.Field
Role respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r LabelModelGraderInput) RawJSON() string { return r.JSON.raw }
func (r *LabelModelGraderInput) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// LabelModelGraderInputContentUnion contains all possible properties and values
// from [string], [responses.ResponseInputText],
// [LabelModelGraderInputContentOutputText],
// [LabelModelGraderInputContentInputImage], [responses.ResponseInputAudio],
// [GraderInputs].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfAnArrayOfInputTextOutputTextInputImageAndInputAudio]
type LabelModelGraderInputContentUnion struct {
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [GraderInputs] instead of an
// object.
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio GraderInputs `json:",inline"`
Text string `json:"text"`
Type string `json:"type"`
// This field is from variant [LabelModelGraderInputContentInputImage].
ImageURL string `json:"image_url"`
// This field is from variant [LabelModelGraderInputContentInputImage].
Detail string `json:"detail"`
// This field is from variant [responses.ResponseInputAudio].
InputAudio responses.ResponseInputAudioInputAudio `json:"input_audio"`
JSON struct {
OfString respjson.Field
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio respjson.Field
Text respjson.Field
Type respjson.Field
ImageURL respjson.Field
Detail respjson.Field
InputAudio respjson.Field
raw string
} `json:"-"`
}
func (u LabelModelGraderInputContentUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u LabelModelGraderInputContentUnion) AsInputText() (v responses.ResponseInputText) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u LabelModelGraderInputContentUnion) AsOutputText() (v LabelModelGraderInputContentOutputText) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u LabelModelGraderInputContentUnion) AsInputImage() (v LabelModelGraderInputContentInputImage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u LabelModelGraderInputContentUnion) AsInputAudio() (v responses.ResponseInputAudio) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u LabelModelGraderInputContentUnion) AsAnArrayOfInputTextOutputTextInputImageAndInputAudio() (v GraderInputs) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u LabelModelGraderInputContentUnion) RawJSON() string { return u.JSON.raw }
func (r *LabelModelGraderInputContentUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A text output from the model.
type LabelModelGraderInputContentOutputText struct {
// The text output from the model.
Text string `json:"text" api:"required"`
// The type of the output text. Always `output_text`.
Type constant.OutputText `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Text respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r LabelModelGraderInputContentOutputText) RawJSON() string { return r.JSON.raw }
func (r *LabelModelGraderInputContentOutputText) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An image input block used within EvalItem content arrays.
type LabelModelGraderInputContentInputImage struct {
// The URL of the image input.
ImageURL string `json:"image_url" api:"required"`
// The type of the image input. Always `input_image`.
Type constant.InputImage `json:"type" api:"required"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail string `json:"detail"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ImageURL respjson.Field
Type respjson.Field
Detail respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r LabelModelGraderInputContentInputImage) RawJSON() string { return r.JSON.raw }
func (r *LabelModelGraderInputContentInputImage) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A LabelModelGrader object which uses a model to assign labels to each item in
// the evaluation.
//
// The properties Input, Labels, Model, Name, PassingLabels, Type are required.
type LabelModelGraderParam struct {
Input []LabelModelGraderInputParam `json:"input,omitzero" api:"required"`
// The labels to assign to each item in the evaluation.
Labels []string `json:"labels,omitzero" api:"required"`
// The model to use for the evaluation. Must support structured outputs.
Model string `json:"model" api:"required"`
// The name of the grader.
Name string `json:"name" api:"required"`
// The labels that indicate a passing result. Must be a subset of labels.
PassingLabels []string `json:"passing_labels,omitzero" api:"required"`
// The object type, which is always `label_model`.
//
// This field can be elided, and will marshal its zero value as "label_model".
Type constant.LabelModel `json:"type" api:"required"`
paramObj
}
func (r LabelModelGraderParam) MarshalJSON() (data []byte, err error) {
type shadow LabelModelGraderParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *LabelModelGraderParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A message input to the model with a role indicating instruction following
// hierarchy. Instructions given with the `developer` or `system` role take
// precedence over instructions given with the `user` role. Messages with the
// `assistant` role are presumed to have been generated by the model in previous
// interactions.
//
// The properties Content, Role are required.
type LabelModelGraderInputParam struct {
// Inputs to the model - can contain template strings. Supports text, output text,
// input images, and input audio, either as a single item or an array of items.
Content LabelModelGraderInputContentUnionParam `json:"content,omitzero" api:"required"`
// The role of the message input. One of `user`, `assistant`, `system`, or
// `developer`.
//
// Any of "user", "assistant", "system", "developer".
Role string `json:"role,omitzero" api:"required"`
// The type of the message input. Always `message`.
//
// Any of "message".
Type string `json:"type,omitzero"`
paramObj
}
func (r LabelModelGraderInputParam) MarshalJSON() (data []byte, err error) {
type shadow LabelModelGraderInputParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *LabelModelGraderInputParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[LabelModelGraderInputParam](
"role", "user", "assistant", "system", "developer",
)
apijson.RegisterFieldValidator[LabelModelGraderInputParam](
"type", "message",
)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type LabelModelGraderInputContentUnionParam struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfInputText *responses.ResponseInputTextParam `json:",omitzero,inline"`
OfOutputText *LabelModelGraderInputContentOutputTextParam `json:",omitzero,inline"`
OfInputImage *LabelModelGraderInputContentInputImageParam `json:",omitzero,inline"`
OfInputAudio *responses.ResponseInputAudioParam `json:",omitzero,inline"`
OfAnArrayOfInputTextOutputTextInputImageAndInputAudio GraderInputsParam `json:",omitzero,inline"`
paramUnion
}
func (u LabelModelGraderInputContentUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfString,
u.OfInputText,
u.OfOutputText,
u.OfInputImage,
u.OfInputAudio,
u.OfAnArrayOfInputTextOutputTextInputImageAndInputAudio)
}
func (u *LabelModelGraderInputContentUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *LabelModelGraderInputContentUnionParam) asAny() any {
if !param.IsOmitted(u.OfString) {
return &u.OfString.Value
} else if !param.IsOmitted(u.OfInputText) {
return u.OfInputText
} else if !param.IsOmitted(u.OfOutputText) {
return u.OfOutputText
} else if !param.IsOmitted(u.OfInputImage) {
return u.OfInputImage
} else if !param.IsOmitted(u.OfInputAudio) {
return u.OfInputAudio
} else if !param.IsOmitted(u.OfAnArrayOfInputTextOutputTextInputImageAndInputAudio) {
return &u.OfAnArrayOfInputTextOutputTextInputImageAndInputAudio
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetImageURL() *string {
if vt := u.OfInputImage; vt != nil {
return &vt.ImageURL
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetDetail() *string {
if vt := u.OfInputImage; vt != nil && vt.Detail.Valid() {
return &vt.Detail.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetInputAudio() *responses.ResponseInputAudioInputAudioParam {
if vt := u.OfInputAudio; vt != nil {
return &vt.InputAudio
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetText() *string {
if vt := u.OfInputText; vt != nil {
return (*string)(&vt.Text)
} else if vt := u.OfOutputText; vt != nil {
return (*string)(&vt.Text)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u LabelModelGraderInputContentUnionParam) GetType() *string {
if vt := u.OfInputText; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfOutputText; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfInputImage; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfInputAudio; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
// A text output from the model.
//
// The properties Text, Type are required.
type LabelModelGraderInputContentOutputTextParam struct {
// The text output from the model.
Text string `json:"text" api:"required"`
// The type of the output text. Always `output_text`.
//
// This field can be elided, and will marshal its zero value as "output_text".
Type constant.OutputText `json:"type" api:"required"`
paramObj
}
func (r LabelModelGraderInputContentOutputTextParam) MarshalJSON() (data []byte, err error) {
type shadow LabelModelGraderInputContentOutputTextParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *LabelModelGraderInputContentOutputTextParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An image input block used within EvalItem content arrays.
//
// The properties ImageURL, Type are required.
type LabelModelGraderInputContentInputImageParam struct {
// The URL of the image input.
ImageURL string `json:"image_url" api:"required"`
// The detail level of the image to be sent to the model. One of `high`, `low`, or
// `auto`. Defaults to `auto`.
Detail param.Opt[string] `json:"detail,omitzero"`
// The type of the image input. Always `input_image`.
//
// This field can be elided, and will marshal its zero value as "input_image".
Type constant.InputImage `json:"type" api:"required"`
paramObj
}
func (r LabelModelGraderInputContentInputImageParam) MarshalJSON() (data []byte, err error) {
type shadow LabelModelGraderInputContentInputImageParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *LabelModelGraderInputContentInputImageParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A MultiGrader object combines the output of multiple graders to produce a single
// score.
type MultiGrader struct {
// A formula to calculate the output based on grader results.
CalculateOutput string `json:"calculate_output" api:"required"`
// A StringCheckGrader object that performs a string comparison between input and
// reference using a specified operation.
Graders MultiGraderGradersUnion `json:"graders" api:"required"`
// The name of the grader.
Name string `json:"name" api:"required"`
// The object type, which is always `multi`.
Type constant.Multi `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CalculateOutput respjson.Field
Graders respjson.Field
Name respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r MultiGrader) RawJSON() string { return r.JSON.raw }
func (r *MultiGrader) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ToParam converts this MultiGrader to a MultiGraderParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// MultiGraderParam.Overrides()
func (r MultiGrader) ToParam() MultiGraderParam {
return param.Override[MultiGraderParam](json.RawMessage(r.RawJSON()))
}
// MultiGraderGradersUnion contains all possible properties and values from
// [StringCheckGrader], [TextSimilarityGrader], [PythonGrader], [ScoreModelGrader],
// [LabelModelGrader].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type MultiGraderGradersUnion struct {
// This field is a union of [string], [string], [[]ScoreModelGraderInput],
// [[]LabelModelGraderInput]
Input MultiGraderGradersUnionInput `json:"input"`
Name string `json:"name"`
// This field is from variant [StringCheckGrader].
Operation StringCheckGraderOperation `json:"operation"`
Reference string `json:"reference"`
Type string `json:"type"`
// This field is from variant [TextSimilarityGrader].
EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric"`
// This field is from variant [PythonGrader].
Source string `json:"source"`
// This field is from variant [PythonGrader].
ImageTag string `json:"image_tag"`
Model string `json:"model"`
// This field is from variant [ScoreModelGrader].
Range []float64 `json:"range"`
// This field is from variant [ScoreModelGrader].
SamplingParams ScoreModelGraderSamplingParams `json:"sampling_params"`
// This field is from variant [LabelModelGrader].
Labels []string `json:"labels"`
// This field is from variant [LabelModelGrader].
PassingLabels []string `json:"passing_labels"`
JSON struct {
Input respjson.Field
Name respjson.Field
Operation respjson.Field
Reference respjson.Field
Type respjson.Field
EvaluationMetric respjson.Field
Source respjson.Field
ImageTag respjson.Field
Model respjson.Field
Range respjson.Field
SamplingParams respjson.Field
Labels respjson.Field
PassingLabels respjson.Field
raw string
} `json:"-"`
}
func (u MultiGraderGradersUnion) AsStringCheckGrader() (v StringCheckGrader) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u MultiGraderGradersUnion) AsTextSimilarityGrader() (v TextSimilarityGrader) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u MultiGraderGradersUnion) AsPythonGrader() (v PythonGrader) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u MultiGraderGradersUnion) AsScoreModelGrader() (v ScoreModelGrader) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u MultiGraderGradersUnion) AsLabelModelGrader() (v LabelModelGrader) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u MultiGraderGradersUnion) RawJSON() string { return u.JSON.raw }
func (r *MultiGraderGradersUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// MultiGraderGradersUnionInput is an implicit subunion of
// [MultiGraderGradersUnion]. MultiGraderGradersUnionInput provides convenient
// access to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [MultiGraderGradersUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfScoreModelGraderInputArray
// OfLabelModelGraderInputArray]
type MultiGraderGradersUnionInput struct {
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [[]ScoreModelGraderInput] instead
// of an object.
OfScoreModelGraderInputArray []ScoreModelGraderInput `json:",inline"`
// This field will be present if the value is a [[]LabelModelGraderInput] instead
// of an object.
OfLabelModelGraderInputArray []LabelModelGraderInput `json:",inline"`
JSON struct {
OfString respjson.Field
OfScoreModelGraderInputArray respjson.Field
OfLabelModelGraderInputArray respjson.Field
raw string
} `json:"-"`
}
func (r *MultiGraderGradersUnionInput) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A MultiGrader object combines the output of multiple graders to produce a single
// score.
//
// The properties CalculateOutput, Graders, Name, Type are required.
type MultiGraderParam struct {
// A formula to calculate the output based on grader results.
CalculateOutput string `json:"calculate_output" api:"required"`
// A StringCheckGrader object that performs a string comparison between input and
// reference using a specified operation.
Graders MultiGraderGradersUnionParam `json:"graders,omitzero" api:"required"`
// The name of the grader.
Name string `json:"name" api:"required"`
// The object type, which is always `multi`.
//
// This field can be elided, and will marshal its zero value as "multi".
Type constant.Multi `json:"type" api:"required"`
paramObj
}
func (r MultiGraderParam) MarshalJSON() (data []byte, err error) {
type shadow MultiGraderParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *MultiGraderParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type MultiGraderGradersUnionParam struct {
OfStringCheckGrader *StringCheckGraderParam `json:",omitzero,inline"`
OfTextSimilarityGrader *TextSimilarityGraderParam `json:",omitzero,inline"`
OfPythonGrader *PythonGraderParam `json:",omitzero,inline"`
OfScoreModelGrader *ScoreModelGraderParam `json:",omitzero,inline"`
OfLabelModelGrader *LabelModelGraderParam `json:",omitzero,inline"`
paramUnion
}
func (u MultiGraderGradersUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfStringCheckGrader,
u.OfTextSimilarityGrader,
u.OfPythonGrader,
u.OfScoreModelGrader,
u.OfLabelModelGrader)
}
func (u *MultiGraderGradersUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *MultiGraderGradersUnionParam) asAny() any {
if !param.IsOmitted(u.OfStringCheckGrader) {
return u.OfStringCheckGrader
} else if !param.IsOmitted(u.OfTextSimilarityGrader) {
return u.OfTextSimilarityGrader
} else if !param.IsOmitted(u.OfPythonGrader) {
return u.OfPythonGrader
} else if !param.IsOmitted(u.OfScoreModelGrader) {
return u.OfScoreModelGrader
} else if !param.IsOmitted(u.OfLabelModelGrader) {
return u.OfLabelModelGrader
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetOperation() *string {
if vt := u.OfStringCheckGrader; vt != nil {
return (*string)(&vt.Operation)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetEvaluationMetric() *string {
if vt := u.OfTextSimilarityGrader; vt != nil {
return (*string)(&vt.EvaluationMetric)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetSource() *string {
if vt := u.OfPythonGrader; vt != nil {
return &vt.Source
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetImageTag() *string {
if vt := u.OfPythonGrader; vt != nil && vt.ImageTag.Valid() {
return &vt.ImageTag.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetRange() []float64 {
if vt := u.OfScoreModelGrader; vt != nil {
return vt.Range
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetSamplingParams() *ScoreModelGraderSamplingParamsParam {
if vt := u.OfScoreModelGrader; vt != nil {
return &vt.SamplingParams
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetLabels() []string {
if vt := u.OfLabelModelGrader; vt != nil {
return vt.Labels
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetPassingLabels() []string {
if vt := u.OfLabelModelGrader; vt != nil {
return vt.PassingLabels
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetName() *string {
if vt := u.OfStringCheckGrader; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfTextSimilarityGrader; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfPythonGrader; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfScoreModelGrader; vt != nil {
return (*string)(&vt.Name)
} else if vt := u.OfLabelModelGrader; vt != nil {
return (*string)(&vt.Name)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetReference() *string {
if vt := u.OfStringCheckGrader; vt != nil {
return (*string)(&vt.Reference)
} else if vt := u.OfTextSimilarityGrader; vt != nil {
return (*string)(&vt.Reference)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetType() *string {
if vt := u.OfStringCheckGrader; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfTextSimilarityGrader; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfPythonGrader; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfScoreModelGrader; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfLabelModelGrader; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u MultiGraderGradersUnionParam) GetModel() *string {
if vt := u.OfScoreModelGrader; vt != nil {
return (*string)(&vt.Model)