1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3package openai
4
5import (
6 "encoding/json"
7
8 "github.com/openai/openai-go/internal/apijson"
9 "github.com/openai/openai-go/option"
10 "github.com/openai/openai-go/packages/param"
11 "github.com/openai/openai-go/packages/respjson"
12 "github.com/openai/openai-go/shared/constant"
13)
14
15// FineTuningMethodService contains methods and other services that help with
16// interacting with the openai API.
17//
18// Note, unlike clients, this service does not read variables from the environment
19// automatically. You should not instantiate this service directly, and instead use
20// the [NewFineTuningMethodService] method instead.
21type FineTuningMethodService struct {
22 Options []option.RequestOption
23}
24
25// NewFineTuningMethodService generates a new service that applies the given
26// options to each request. These options are applied after the parent client's
27// options (if there is one), and before any request-specific options.
28func NewFineTuningMethodService(opts ...option.RequestOption) (r FineTuningMethodService) {
29 r = FineTuningMethodService{}
30 r.Options = opts
31 return
32}
33
34// The hyperparameters used for the DPO fine-tuning job.
35type DpoHyperparametersResp struct {
36 // Number of examples in each batch. A larger batch size means that model
37 // parameters are updated less frequently, but with lower variance.
38 BatchSize DpoHyperparametersBatchSizeUnionResp `json:"batch_size"`
39 // The beta value for the DPO method. A higher beta value will increase the weight
40 // of the penalty between the policy and reference model.
41 Beta DpoHyperparametersBetaUnionResp `json:"beta"`
42 // Scaling factor for the learning rate. A smaller learning rate may be useful to
43 // avoid overfitting.
44 LearningRateMultiplier DpoHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
45 // The number of epochs to train the model for. An epoch refers to one full cycle
46 // through the training dataset.
47 NEpochs DpoHyperparametersNEpochsUnionResp `json:"n_epochs"`
48 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
49 JSON struct {
50 BatchSize respjson.Field
51 Beta respjson.Field
52 LearningRateMultiplier respjson.Field
53 NEpochs respjson.Field
54 ExtraFields map[string]respjson.Field
55 raw string
56 } `json:"-"`
57}
58
59// Returns the unmodified JSON received from the API
60func (r DpoHyperparametersResp) RawJSON() string { return r.JSON.raw }
61func (r *DpoHyperparametersResp) UnmarshalJSON(data []byte) error {
62 return apijson.UnmarshalRoot(data, r)
63}
64
65// ToParam converts this DpoHyperparametersResp to a DpoHyperparameters.
66//
67// Warning: the fields of the param type will not be present. ToParam should only
68// be used at the last possible moment before sending a request. Test for this with
69// DpoHyperparameters.Overrides()
70func (r DpoHyperparametersResp) ToParam() DpoHyperparameters {
71 return param.Override[DpoHyperparameters](json.RawMessage(r.RawJSON()))
72}
73
74// DpoHyperparametersBatchSizeUnionResp contains all possible properties and values
75// from [constant.Auto], [int64].
76//
77// Use the methods beginning with 'As' to cast the union to one of its variants.
78//
79// If the underlying value is not a json object, one of the following properties
80// will be valid: OfAuto OfInt]
81type DpoHyperparametersBatchSizeUnionResp struct {
82 // This field will be present if the value is a [constant.Auto] instead of an
83 // object.
84 OfAuto constant.Auto `json:",inline"`
85 // This field will be present if the value is a [int64] instead of an object.
86 OfInt int64 `json:",inline"`
87 JSON struct {
88 OfAuto respjson.Field
89 OfInt respjson.Field
90 raw string
91 } `json:"-"`
92}
93
94func (u DpoHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto) {
95 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
96 return
97}
98
99func (u DpoHyperparametersBatchSizeUnionResp) AsInt() (v int64) {
100 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
101 return
102}
103
104// Returns the unmodified JSON received from the API
105func (u DpoHyperparametersBatchSizeUnionResp) RawJSON() string { return u.JSON.raw }
106
107func (r *DpoHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error {
108 return apijson.UnmarshalRoot(data, r)
109}
110
111// DpoHyperparametersBetaUnionResp contains all possible properties and values from
112// [constant.Auto], [float64].
113//
114// Use the methods beginning with 'As' to cast the union to one of its variants.
115//
116// If the underlying value is not a json object, one of the following properties
117// will be valid: OfAuto OfFloat]
118type DpoHyperparametersBetaUnionResp struct {
119 // This field will be present if the value is a [constant.Auto] instead of an
120 // object.
121 OfAuto constant.Auto `json:",inline"`
122 // This field will be present if the value is a [float64] instead of an object.
123 OfFloat float64 `json:",inline"`
124 JSON struct {
125 OfAuto respjson.Field
126 OfFloat respjson.Field
127 raw string
128 } `json:"-"`
129}
130
131func (u DpoHyperparametersBetaUnionResp) AsAuto() (v constant.Auto) {
132 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
133 return
134}
135
136func (u DpoHyperparametersBetaUnionResp) AsFloat() (v float64) {
137 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
138 return
139}
140
141// Returns the unmodified JSON received from the API
142func (u DpoHyperparametersBetaUnionResp) RawJSON() string { return u.JSON.raw }
143
144func (r *DpoHyperparametersBetaUnionResp) UnmarshalJSON(data []byte) error {
145 return apijson.UnmarshalRoot(data, r)
146}
147
148// DpoHyperparametersLearningRateMultiplierUnionResp contains all possible
149// properties and values from [constant.Auto], [float64].
150//
151// Use the methods beginning with 'As' to cast the union to one of its variants.
152//
153// If the underlying value is not a json object, one of the following properties
154// will be valid: OfAuto OfFloat]
155type DpoHyperparametersLearningRateMultiplierUnionResp struct {
156 // This field will be present if the value is a [constant.Auto] instead of an
157 // object.
158 OfAuto constant.Auto `json:",inline"`
159 // This field will be present if the value is a [float64] instead of an object.
160 OfFloat float64 `json:",inline"`
161 JSON struct {
162 OfAuto respjson.Field
163 OfFloat respjson.Field
164 raw string
165 } `json:"-"`
166}
167
168func (u DpoHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto) {
169 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
170 return
171}
172
173func (u DpoHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64) {
174 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
175 return
176}
177
178// Returns the unmodified JSON received from the API
179func (u DpoHyperparametersLearningRateMultiplierUnionResp) RawJSON() string { return u.JSON.raw }
180
181func (r *DpoHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error {
182 return apijson.UnmarshalRoot(data, r)
183}
184
185// DpoHyperparametersNEpochsUnionResp contains all possible properties and values
186// from [constant.Auto], [int64].
187//
188// Use the methods beginning with 'As' to cast the union to one of its variants.
189//
190// If the underlying value is not a json object, one of the following properties
191// will be valid: OfAuto OfInt]
192type DpoHyperparametersNEpochsUnionResp struct {
193 // This field will be present if the value is a [constant.Auto] instead of an
194 // object.
195 OfAuto constant.Auto `json:",inline"`
196 // This field will be present if the value is a [int64] instead of an object.
197 OfInt int64 `json:",inline"`
198 JSON struct {
199 OfAuto respjson.Field
200 OfInt respjson.Field
201 raw string
202 } `json:"-"`
203}
204
205func (u DpoHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto) {
206 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
207 return
208}
209
210func (u DpoHyperparametersNEpochsUnionResp) AsInt() (v int64) {
211 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
212 return
213}
214
215// Returns the unmodified JSON received from the API
216func (u DpoHyperparametersNEpochsUnionResp) RawJSON() string { return u.JSON.raw }
217
218func (r *DpoHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error {
219 return apijson.UnmarshalRoot(data, r)
220}
221
222// The hyperparameters used for the DPO fine-tuning job.
223type DpoHyperparameters struct {
224 // Number of examples in each batch. A larger batch size means that model
225 // parameters are updated less frequently, but with lower variance.
226 BatchSize DpoHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
227 // The beta value for the DPO method. A higher beta value will increase the weight
228 // of the penalty between the policy and reference model.
229 Beta DpoHyperparametersBetaUnion `json:"beta,omitzero"`
230 // Scaling factor for the learning rate. A smaller learning rate may be useful to
231 // avoid overfitting.
232 LearningRateMultiplier DpoHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
233 // The number of epochs to train the model for. An epoch refers to one full cycle
234 // through the training dataset.
235 NEpochs DpoHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
236 paramObj
237}
238
239func (r DpoHyperparameters) MarshalJSON() (data []byte, err error) {
240 type shadow DpoHyperparameters
241 return param.MarshalObject(r, (*shadow)(&r))
242}
243func (r *DpoHyperparameters) UnmarshalJSON(data []byte) error {
244 return apijson.UnmarshalRoot(data, r)
245}
246
247// Only one field can be non-zero.
248//
249// Use [param.IsOmitted] to confirm if a field is set.
250type DpoHyperparametersBatchSizeUnion struct {
251 // Construct this variant with constant.ValueOf[constant.Auto]()
252 OfAuto constant.Auto `json:",omitzero,inline"`
253 OfInt param.Opt[int64] `json:",omitzero,inline"`
254 paramUnion
255}
256
257func (u DpoHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error) {
258 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
259}
260func (u *DpoHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error {
261 return apijson.UnmarshalRoot(data, u)
262}
263
264func (u *DpoHyperparametersBatchSizeUnion) asAny() any {
265 if !param.IsOmitted(u.OfAuto) {
266 return &u.OfAuto
267 } else if !param.IsOmitted(u.OfInt) {
268 return &u.OfInt.Value
269 }
270 return nil
271}
272
273// Only one field can be non-zero.
274//
275// Use [param.IsOmitted] to confirm if a field is set.
276type DpoHyperparametersBetaUnion struct {
277 // Construct this variant with constant.ValueOf[constant.Auto]()
278 OfAuto constant.Auto `json:",omitzero,inline"`
279 OfFloat param.Opt[float64] `json:",omitzero,inline"`
280 paramUnion
281}
282
283func (u DpoHyperparametersBetaUnion) MarshalJSON() ([]byte, error) {
284 return param.MarshalUnion(u, u.OfAuto, u.OfFloat)
285}
286func (u *DpoHyperparametersBetaUnion) UnmarshalJSON(data []byte) error {
287 return apijson.UnmarshalRoot(data, u)
288}
289
290func (u *DpoHyperparametersBetaUnion) asAny() any {
291 if !param.IsOmitted(u.OfAuto) {
292 return &u.OfAuto
293 } else if !param.IsOmitted(u.OfFloat) {
294 return &u.OfFloat.Value
295 }
296 return nil
297}
298
299// Only one field can be non-zero.
300//
301// Use [param.IsOmitted] to confirm if a field is set.
302type DpoHyperparametersLearningRateMultiplierUnion struct {
303 // Construct this variant with constant.ValueOf[constant.Auto]()
304 OfAuto constant.Auto `json:",omitzero,inline"`
305 OfFloat param.Opt[float64] `json:",omitzero,inline"`
306 paramUnion
307}
308
309func (u DpoHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error) {
310 return param.MarshalUnion(u, u.OfAuto, u.OfFloat)
311}
312func (u *DpoHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error {
313 return apijson.UnmarshalRoot(data, u)
314}
315
316func (u *DpoHyperparametersLearningRateMultiplierUnion) asAny() any {
317 if !param.IsOmitted(u.OfAuto) {
318 return &u.OfAuto
319 } else if !param.IsOmitted(u.OfFloat) {
320 return &u.OfFloat.Value
321 }
322 return nil
323}
324
325// Only one field can be non-zero.
326//
327// Use [param.IsOmitted] to confirm if a field is set.
328type DpoHyperparametersNEpochsUnion struct {
329 // Construct this variant with constant.ValueOf[constant.Auto]()
330 OfAuto constant.Auto `json:",omitzero,inline"`
331 OfInt param.Opt[int64] `json:",omitzero,inline"`
332 paramUnion
333}
334
335func (u DpoHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error) {
336 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
337}
338func (u *DpoHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error {
339 return apijson.UnmarshalRoot(data, u)
340}
341
342func (u *DpoHyperparametersNEpochsUnion) asAny() any {
343 if !param.IsOmitted(u.OfAuto) {
344 return &u.OfAuto
345 } else if !param.IsOmitted(u.OfInt) {
346 return &u.OfInt.Value
347 }
348 return nil
349}
350
351// Configuration for the DPO fine-tuning method.
352type DpoMethod struct {
353 // The hyperparameters used for the DPO fine-tuning job.
354 Hyperparameters DpoHyperparametersResp `json:"hyperparameters"`
355 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
356 JSON struct {
357 Hyperparameters respjson.Field
358 ExtraFields map[string]respjson.Field
359 raw string
360 } `json:"-"`
361}
362
363// Returns the unmodified JSON received from the API
364func (r DpoMethod) RawJSON() string { return r.JSON.raw }
365func (r *DpoMethod) UnmarshalJSON(data []byte) error {
366 return apijson.UnmarshalRoot(data, r)
367}
368
369// ToParam converts this DpoMethod to a DpoMethodParam.
370//
371// Warning: the fields of the param type will not be present. ToParam should only
372// be used at the last possible moment before sending a request. Test for this with
373// DpoMethodParam.Overrides()
374func (r DpoMethod) ToParam() DpoMethodParam {
375 return param.Override[DpoMethodParam](json.RawMessage(r.RawJSON()))
376}
377
378// Configuration for the DPO fine-tuning method.
379type DpoMethodParam struct {
380 // The hyperparameters used for the DPO fine-tuning job.
381 Hyperparameters DpoHyperparameters `json:"hyperparameters,omitzero"`
382 paramObj
383}
384
385func (r DpoMethodParam) MarshalJSON() (data []byte, err error) {
386 type shadow DpoMethodParam
387 return param.MarshalObject(r, (*shadow)(&r))
388}
389func (r *DpoMethodParam) UnmarshalJSON(data []byte) error {
390 return apijson.UnmarshalRoot(data, r)
391}
392
393// The hyperparameters used for the reinforcement fine-tuning job.
394type ReinforcementHyperparametersResp struct {
395 // Number of examples in each batch. A larger batch size means that model
396 // parameters are updated less frequently, but with lower variance.
397 BatchSize ReinforcementHyperparametersBatchSizeUnionResp `json:"batch_size"`
398 // Multiplier on amount of compute used for exploring search space during training.
399 ComputeMultiplier ReinforcementHyperparametersComputeMultiplierUnionResp `json:"compute_multiplier"`
400 // The number of training steps between evaluation runs.
401 EvalInterval ReinforcementHyperparametersEvalIntervalUnionResp `json:"eval_interval"`
402 // Number of evaluation samples to generate per training step.
403 EvalSamples ReinforcementHyperparametersEvalSamplesUnionResp `json:"eval_samples"`
404 // Scaling factor for the learning rate. A smaller learning rate may be useful to
405 // avoid overfitting.
406 LearningRateMultiplier ReinforcementHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
407 // The number of epochs to train the model for. An epoch refers to one full cycle
408 // through the training dataset.
409 NEpochs ReinforcementHyperparametersNEpochsUnionResp `json:"n_epochs"`
410 // Level of reasoning effort.
411 //
412 // Any of "default", "low", "medium", "high".
413 ReasoningEffort ReinforcementHyperparametersReasoningEffort `json:"reasoning_effort"`
414 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
415 JSON struct {
416 BatchSize respjson.Field
417 ComputeMultiplier respjson.Field
418 EvalInterval respjson.Field
419 EvalSamples respjson.Field
420 LearningRateMultiplier respjson.Field
421 NEpochs respjson.Field
422 ReasoningEffort respjson.Field
423 ExtraFields map[string]respjson.Field
424 raw string
425 } `json:"-"`
426}
427
428// Returns the unmodified JSON received from the API
429func (r ReinforcementHyperparametersResp) RawJSON() string { return r.JSON.raw }
430func (r *ReinforcementHyperparametersResp) UnmarshalJSON(data []byte) error {
431 return apijson.UnmarshalRoot(data, r)
432}
433
434// ToParam converts this ReinforcementHyperparametersResp to a
435// ReinforcementHyperparameters.
436//
437// Warning: the fields of the param type will not be present. ToParam should only
438// be used at the last possible moment before sending a request. Test for this with
439// ReinforcementHyperparameters.Overrides()
440func (r ReinforcementHyperparametersResp) ToParam() ReinforcementHyperparameters {
441 return param.Override[ReinforcementHyperparameters](json.RawMessage(r.RawJSON()))
442}
443
444// ReinforcementHyperparametersBatchSizeUnionResp contains all possible properties
445// and values from [constant.Auto], [int64].
446//
447// Use the methods beginning with 'As' to cast the union to one of its variants.
448//
449// If the underlying value is not a json object, one of the following properties
450// will be valid: OfAuto OfInt]
451type ReinforcementHyperparametersBatchSizeUnionResp struct {
452 // This field will be present if the value is a [constant.Auto] instead of an
453 // object.
454 OfAuto constant.Auto `json:",inline"`
455 // This field will be present if the value is a [int64] instead of an object.
456 OfInt int64 `json:",inline"`
457 JSON struct {
458 OfAuto respjson.Field
459 OfInt respjson.Field
460 raw string
461 } `json:"-"`
462}
463
464func (u ReinforcementHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto) {
465 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
466 return
467}
468
469func (u ReinforcementHyperparametersBatchSizeUnionResp) AsInt() (v int64) {
470 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
471 return
472}
473
474// Returns the unmodified JSON received from the API
475func (u ReinforcementHyperparametersBatchSizeUnionResp) RawJSON() string { return u.JSON.raw }
476
477func (r *ReinforcementHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error {
478 return apijson.UnmarshalRoot(data, r)
479}
480
481// ReinforcementHyperparametersComputeMultiplierUnionResp contains all possible
482// properties and values from [constant.Auto], [float64].
483//
484// Use the methods beginning with 'As' to cast the union to one of its variants.
485//
486// If the underlying value is not a json object, one of the following properties
487// will be valid: OfAuto OfFloat]
488type ReinforcementHyperparametersComputeMultiplierUnionResp struct {
489 // This field will be present if the value is a [constant.Auto] instead of an
490 // object.
491 OfAuto constant.Auto `json:",inline"`
492 // This field will be present if the value is a [float64] instead of an object.
493 OfFloat float64 `json:",inline"`
494 JSON struct {
495 OfAuto respjson.Field
496 OfFloat respjson.Field
497 raw string
498 } `json:"-"`
499}
500
501func (u ReinforcementHyperparametersComputeMultiplierUnionResp) AsAuto() (v constant.Auto) {
502 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
503 return
504}
505
506func (u ReinforcementHyperparametersComputeMultiplierUnionResp) AsFloat() (v float64) {
507 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
508 return
509}
510
511// Returns the unmodified JSON received from the API
512func (u ReinforcementHyperparametersComputeMultiplierUnionResp) RawJSON() string { return u.JSON.raw }
513
514func (r *ReinforcementHyperparametersComputeMultiplierUnionResp) UnmarshalJSON(data []byte) error {
515 return apijson.UnmarshalRoot(data, r)
516}
517
518// ReinforcementHyperparametersEvalIntervalUnionResp contains all possible
519// properties and values from [constant.Auto], [int64].
520//
521// Use the methods beginning with 'As' to cast the union to one of its variants.
522//
523// If the underlying value is not a json object, one of the following properties
524// will be valid: OfAuto OfInt]
525type ReinforcementHyperparametersEvalIntervalUnionResp struct {
526 // This field will be present if the value is a [constant.Auto] instead of an
527 // object.
528 OfAuto constant.Auto `json:",inline"`
529 // This field will be present if the value is a [int64] instead of an object.
530 OfInt int64 `json:",inline"`
531 JSON struct {
532 OfAuto respjson.Field
533 OfInt respjson.Field
534 raw string
535 } `json:"-"`
536}
537
538func (u ReinforcementHyperparametersEvalIntervalUnionResp) AsAuto() (v constant.Auto) {
539 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
540 return
541}
542
543func (u ReinforcementHyperparametersEvalIntervalUnionResp) AsInt() (v int64) {
544 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
545 return
546}
547
548// Returns the unmodified JSON received from the API
549func (u ReinforcementHyperparametersEvalIntervalUnionResp) RawJSON() string { return u.JSON.raw }
550
551func (r *ReinforcementHyperparametersEvalIntervalUnionResp) UnmarshalJSON(data []byte) error {
552 return apijson.UnmarshalRoot(data, r)
553}
554
555// ReinforcementHyperparametersEvalSamplesUnionResp contains all possible
556// properties and values from [constant.Auto], [int64].
557//
558// Use the methods beginning with 'As' to cast the union to one of its variants.
559//
560// If the underlying value is not a json object, one of the following properties
561// will be valid: OfAuto OfInt]
562type ReinforcementHyperparametersEvalSamplesUnionResp struct {
563 // This field will be present if the value is a [constant.Auto] instead of an
564 // object.
565 OfAuto constant.Auto `json:",inline"`
566 // This field will be present if the value is a [int64] instead of an object.
567 OfInt int64 `json:",inline"`
568 JSON struct {
569 OfAuto respjson.Field
570 OfInt respjson.Field
571 raw string
572 } `json:"-"`
573}
574
575func (u ReinforcementHyperparametersEvalSamplesUnionResp) AsAuto() (v constant.Auto) {
576 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
577 return
578}
579
580func (u ReinforcementHyperparametersEvalSamplesUnionResp) AsInt() (v int64) {
581 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
582 return
583}
584
585// Returns the unmodified JSON received from the API
586func (u ReinforcementHyperparametersEvalSamplesUnionResp) RawJSON() string { return u.JSON.raw }
587
588func (r *ReinforcementHyperparametersEvalSamplesUnionResp) UnmarshalJSON(data []byte) error {
589 return apijson.UnmarshalRoot(data, r)
590}
591
592// ReinforcementHyperparametersLearningRateMultiplierUnionResp contains all
593// possible properties and values from [constant.Auto], [float64].
594//
595// Use the methods beginning with 'As' to cast the union to one of its variants.
596//
597// If the underlying value is not a json object, one of the following properties
598// will be valid: OfAuto OfFloat]
599type ReinforcementHyperparametersLearningRateMultiplierUnionResp struct {
600 // This field will be present if the value is a [constant.Auto] instead of an
601 // object.
602 OfAuto constant.Auto `json:",inline"`
603 // This field will be present if the value is a [float64] instead of an object.
604 OfFloat float64 `json:",inline"`
605 JSON struct {
606 OfAuto respjson.Field
607 OfFloat respjson.Field
608 raw string
609 } `json:"-"`
610}
611
612func (u ReinforcementHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto) {
613 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
614 return
615}
616
617func (u ReinforcementHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64) {
618 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
619 return
620}
621
622// Returns the unmodified JSON received from the API
623func (u ReinforcementHyperparametersLearningRateMultiplierUnionResp) RawJSON() string {
624 return u.JSON.raw
625}
626
627func (r *ReinforcementHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error {
628 return apijson.UnmarshalRoot(data, r)
629}
630
631// ReinforcementHyperparametersNEpochsUnionResp contains all possible properties
632// and values from [constant.Auto], [int64].
633//
634// Use the methods beginning with 'As' to cast the union to one of its variants.
635//
636// If the underlying value is not a json object, one of the following properties
637// will be valid: OfAuto OfInt]
638type ReinforcementHyperparametersNEpochsUnionResp struct {
639 // This field will be present if the value is a [constant.Auto] instead of an
640 // object.
641 OfAuto constant.Auto `json:",inline"`
642 // This field will be present if the value is a [int64] instead of an object.
643 OfInt int64 `json:",inline"`
644 JSON struct {
645 OfAuto respjson.Field
646 OfInt respjson.Field
647 raw string
648 } `json:"-"`
649}
650
651func (u ReinforcementHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto) {
652 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
653 return
654}
655
656func (u ReinforcementHyperparametersNEpochsUnionResp) AsInt() (v int64) {
657 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
658 return
659}
660
661// Returns the unmodified JSON received from the API
662func (u ReinforcementHyperparametersNEpochsUnionResp) RawJSON() string { return u.JSON.raw }
663
664func (r *ReinforcementHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error {
665 return apijson.UnmarshalRoot(data, r)
666}
667
668// Level of reasoning effort.
669type ReinforcementHyperparametersReasoningEffort string
670
671const (
672 ReinforcementHyperparametersReasoningEffortDefault ReinforcementHyperparametersReasoningEffort = "default"
673 ReinforcementHyperparametersReasoningEffortLow ReinforcementHyperparametersReasoningEffort = "low"
674 ReinforcementHyperparametersReasoningEffortMedium ReinforcementHyperparametersReasoningEffort = "medium"
675 ReinforcementHyperparametersReasoningEffortHigh ReinforcementHyperparametersReasoningEffort = "high"
676)
677
678// The hyperparameters used for the reinforcement fine-tuning job.
679type ReinforcementHyperparameters struct {
680 // Number of examples in each batch. A larger batch size means that model
681 // parameters are updated less frequently, but with lower variance.
682 BatchSize ReinforcementHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
683 // Multiplier on amount of compute used for exploring search space during training.
684 ComputeMultiplier ReinforcementHyperparametersComputeMultiplierUnion `json:"compute_multiplier,omitzero"`
685 // The number of training steps between evaluation runs.
686 EvalInterval ReinforcementHyperparametersEvalIntervalUnion `json:"eval_interval,omitzero"`
687 // Number of evaluation samples to generate per training step.
688 EvalSamples ReinforcementHyperparametersEvalSamplesUnion `json:"eval_samples,omitzero"`
689 // Scaling factor for the learning rate. A smaller learning rate may be useful to
690 // avoid overfitting.
691 LearningRateMultiplier ReinforcementHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
692 // The number of epochs to train the model for. An epoch refers to one full cycle
693 // through the training dataset.
694 NEpochs ReinforcementHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
695 // Level of reasoning effort.
696 //
697 // Any of "default", "low", "medium", "high".
698 ReasoningEffort ReinforcementHyperparametersReasoningEffort `json:"reasoning_effort,omitzero"`
699 paramObj
700}
701
702func (r ReinforcementHyperparameters) MarshalJSON() (data []byte, err error) {
703 type shadow ReinforcementHyperparameters
704 return param.MarshalObject(r, (*shadow)(&r))
705}
706func (r *ReinforcementHyperparameters) UnmarshalJSON(data []byte) error {
707 return apijson.UnmarshalRoot(data, r)
708}
709
710// Only one field can be non-zero.
711//
712// Use [param.IsOmitted] to confirm if a field is set.
713type ReinforcementHyperparametersBatchSizeUnion struct {
714 // Construct this variant with constant.ValueOf[constant.Auto]()
715 OfAuto constant.Auto `json:",omitzero,inline"`
716 OfInt param.Opt[int64] `json:",omitzero,inline"`
717 paramUnion
718}
719
720func (u ReinforcementHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error) {
721 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
722}
723func (u *ReinforcementHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error {
724 return apijson.UnmarshalRoot(data, u)
725}
726
727func (u *ReinforcementHyperparametersBatchSizeUnion) asAny() any {
728 if !param.IsOmitted(u.OfAuto) {
729 return &u.OfAuto
730 } else if !param.IsOmitted(u.OfInt) {
731 return &u.OfInt.Value
732 }
733 return nil
734}
735
736// Only one field can be non-zero.
737//
738// Use [param.IsOmitted] to confirm if a field is set.
739type ReinforcementHyperparametersComputeMultiplierUnion struct {
740 // Construct this variant with constant.ValueOf[constant.Auto]()
741 OfAuto constant.Auto `json:",omitzero,inline"`
742 OfFloat param.Opt[float64] `json:",omitzero,inline"`
743 paramUnion
744}
745
746func (u ReinforcementHyperparametersComputeMultiplierUnion) MarshalJSON() ([]byte, error) {
747 return param.MarshalUnion(u, u.OfAuto, u.OfFloat)
748}
749func (u *ReinforcementHyperparametersComputeMultiplierUnion) UnmarshalJSON(data []byte) error {
750 return apijson.UnmarshalRoot(data, u)
751}
752
753func (u *ReinforcementHyperparametersComputeMultiplierUnion) asAny() any {
754 if !param.IsOmitted(u.OfAuto) {
755 return &u.OfAuto
756 } else if !param.IsOmitted(u.OfFloat) {
757 return &u.OfFloat.Value
758 }
759 return nil
760}
761
762// Only one field can be non-zero.
763//
764// Use [param.IsOmitted] to confirm if a field is set.
765type ReinforcementHyperparametersEvalIntervalUnion struct {
766 // Construct this variant with constant.ValueOf[constant.Auto]()
767 OfAuto constant.Auto `json:",omitzero,inline"`
768 OfInt param.Opt[int64] `json:",omitzero,inline"`
769 paramUnion
770}
771
772func (u ReinforcementHyperparametersEvalIntervalUnion) MarshalJSON() ([]byte, error) {
773 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
774}
775func (u *ReinforcementHyperparametersEvalIntervalUnion) UnmarshalJSON(data []byte) error {
776 return apijson.UnmarshalRoot(data, u)
777}
778
779func (u *ReinforcementHyperparametersEvalIntervalUnion) asAny() any {
780 if !param.IsOmitted(u.OfAuto) {
781 return &u.OfAuto
782 } else if !param.IsOmitted(u.OfInt) {
783 return &u.OfInt.Value
784 }
785 return nil
786}
787
788// Only one field can be non-zero.
789//
790// Use [param.IsOmitted] to confirm if a field is set.
791type ReinforcementHyperparametersEvalSamplesUnion struct {
792 // Construct this variant with constant.ValueOf[constant.Auto]()
793 OfAuto constant.Auto `json:",omitzero,inline"`
794 OfInt param.Opt[int64] `json:",omitzero,inline"`
795 paramUnion
796}
797
798func (u ReinforcementHyperparametersEvalSamplesUnion) MarshalJSON() ([]byte, error) {
799 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
800}
801func (u *ReinforcementHyperparametersEvalSamplesUnion) UnmarshalJSON(data []byte) error {
802 return apijson.UnmarshalRoot(data, u)
803}
804
805func (u *ReinforcementHyperparametersEvalSamplesUnion) asAny() any {
806 if !param.IsOmitted(u.OfAuto) {
807 return &u.OfAuto
808 } else if !param.IsOmitted(u.OfInt) {
809 return &u.OfInt.Value
810 }
811 return nil
812}
813
814// Only one field can be non-zero.
815//
816// Use [param.IsOmitted] to confirm if a field is set.
817type ReinforcementHyperparametersLearningRateMultiplierUnion struct {
818 // Construct this variant with constant.ValueOf[constant.Auto]()
819 OfAuto constant.Auto `json:",omitzero,inline"`
820 OfFloat param.Opt[float64] `json:",omitzero,inline"`
821 paramUnion
822}
823
824func (u ReinforcementHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error) {
825 return param.MarshalUnion(u, u.OfAuto, u.OfFloat)
826}
827func (u *ReinforcementHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error {
828 return apijson.UnmarshalRoot(data, u)
829}
830
831func (u *ReinforcementHyperparametersLearningRateMultiplierUnion) asAny() any {
832 if !param.IsOmitted(u.OfAuto) {
833 return &u.OfAuto
834 } else if !param.IsOmitted(u.OfFloat) {
835 return &u.OfFloat.Value
836 }
837 return nil
838}
839
840// Only one field can be non-zero.
841//
842// Use [param.IsOmitted] to confirm if a field is set.
843type ReinforcementHyperparametersNEpochsUnion struct {
844 // Construct this variant with constant.ValueOf[constant.Auto]()
845 OfAuto constant.Auto `json:",omitzero,inline"`
846 OfInt param.Opt[int64] `json:",omitzero,inline"`
847 paramUnion
848}
849
850func (u ReinforcementHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error) {
851 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
852}
853func (u *ReinforcementHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error {
854 return apijson.UnmarshalRoot(data, u)
855}
856
857func (u *ReinforcementHyperparametersNEpochsUnion) asAny() any {
858 if !param.IsOmitted(u.OfAuto) {
859 return &u.OfAuto
860 } else if !param.IsOmitted(u.OfInt) {
861 return &u.OfInt.Value
862 }
863 return nil
864}
865
866// Configuration for the reinforcement fine-tuning method.
867type ReinforcementMethod struct {
868 // The grader used for the fine-tuning job.
869 Grader ReinforcementMethodGraderUnion `json:"grader,required"`
870 // The hyperparameters used for the reinforcement fine-tuning job.
871 Hyperparameters ReinforcementHyperparametersResp `json:"hyperparameters"`
872 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
873 JSON struct {
874 Grader respjson.Field
875 Hyperparameters respjson.Field
876 ExtraFields map[string]respjson.Field
877 raw string
878 } `json:"-"`
879}
880
881// Returns the unmodified JSON received from the API
882func (r ReinforcementMethod) RawJSON() string { return r.JSON.raw }
883func (r *ReinforcementMethod) UnmarshalJSON(data []byte) error {
884 return apijson.UnmarshalRoot(data, r)
885}
886
887// ToParam converts this ReinforcementMethod to a ReinforcementMethodParam.
888//
889// Warning: the fields of the param type will not be present. ToParam should only
890// be used at the last possible moment before sending a request. Test for this with
891// ReinforcementMethodParam.Overrides()
892func (r ReinforcementMethod) ToParam() ReinforcementMethodParam {
893 return param.Override[ReinforcementMethodParam](json.RawMessage(r.RawJSON()))
894}
895
896// ReinforcementMethodGraderUnion contains all possible properties and values from
897// [StringCheckGrader], [TextSimilarityGrader], [PythonGrader], [ScoreModelGrader],
898// [MultiGrader].
899//
900// Use the methods beginning with 'As' to cast the union to one of its variants.
901type ReinforcementMethodGraderUnion struct {
902 // This field is a union of [string], [string], [[]ScoreModelGraderInput]
903 Input ReinforcementMethodGraderUnionInput `json:"input"`
904 Name string `json:"name"`
905 // This field is from variant [StringCheckGrader].
906 Operation StringCheckGraderOperation `json:"operation"`
907 Reference string `json:"reference"`
908 Type string `json:"type"`
909 // This field is from variant [TextSimilarityGrader].
910 EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric"`
911 // This field is from variant [PythonGrader].
912 Source string `json:"source"`
913 // This field is from variant [PythonGrader].
914 ImageTag string `json:"image_tag"`
915 // This field is from variant [ScoreModelGrader].
916 Model string `json:"model"`
917 // This field is from variant [ScoreModelGrader].
918 Range []float64 `json:"range"`
919 // This field is from variant [ScoreModelGrader].
920 SamplingParams any `json:"sampling_params"`
921 // This field is from variant [MultiGrader].
922 CalculateOutput string `json:"calculate_output"`
923 // This field is from variant [MultiGrader].
924 Graders MultiGraderGradersUnion `json:"graders"`
925 JSON struct {
926 Input respjson.Field
927 Name respjson.Field
928 Operation respjson.Field
929 Reference respjson.Field
930 Type respjson.Field
931 EvaluationMetric respjson.Field
932 Source respjson.Field
933 ImageTag respjson.Field
934 Model respjson.Field
935 Range respjson.Field
936 SamplingParams respjson.Field
937 CalculateOutput respjson.Field
938 Graders respjson.Field
939 raw string
940 } `json:"-"`
941}
942
943func (u ReinforcementMethodGraderUnion) AsStringCheckGrader() (v StringCheckGrader) {
944 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
945 return
946}
947
948func (u ReinforcementMethodGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader) {
949 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
950 return
951}
952
953func (u ReinforcementMethodGraderUnion) AsPythonGrader() (v PythonGrader) {
954 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
955 return
956}
957
958func (u ReinforcementMethodGraderUnion) AsScoreModelGrader() (v ScoreModelGrader) {
959 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
960 return
961}
962
963func (u ReinforcementMethodGraderUnion) AsMultiGrader() (v MultiGrader) {
964 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
965 return
966}
967
968// Returns the unmodified JSON received from the API
969func (u ReinforcementMethodGraderUnion) RawJSON() string { return u.JSON.raw }
970
971func (r *ReinforcementMethodGraderUnion) UnmarshalJSON(data []byte) error {
972 return apijson.UnmarshalRoot(data, r)
973}
974
975// ReinforcementMethodGraderUnionInput is an implicit subunion of
976// [ReinforcementMethodGraderUnion]. ReinforcementMethodGraderUnionInput provides
977// convenient access to the sub-properties of the union.
978//
979// For type safety it is recommended to directly use a variant of the
980// [ReinforcementMethodGraderUnion].
981//
982// If the underlying value is not a json object, one of the following properties
983// will be valid: OfString OfScoreModelGraderInputArray]
984type ReinforcementMethodGraderUnionInput struct {
985 // This field will be present if the value is a [string] instead of an object.
986 OfString string `json:",inline"`
987 // This field will be present if the value is a [[]ScoreModelGraderInput] instead
988 // of an object.
989 OfScoreModelGraderInputArray []ScoreModelGraderInput `json:",inline"`
990 JSON struct {
991 OfString respjson.Field
992 OfScoreModelGraderInputArray respjson.Field
993 raw string
994 } `json:"-"`
995}
996
997func (r *ReinforcementMethodGraderUnionInput) UnmarshalJSON(data []byte) error {
998 return apijson.UnmarshalRoot(data, r)
999}
1000
1001// Configuration for the reinforcement fine-tuning method.
1002//
1003// The property Grader is required.
1004type ReinforcementMethodParam struct {
1005 // The grader used for the fine-tuning job.
1006 Grader ReinforcementMethodGraderUnionParam `json:"grader,omitzero,required"`
1007 // The hyperparameters used for the reinforcement fine-tuning job.
1008 Hyperparameters ReinforcementHyperparameters `json:"hyperparameters,omitzero"`
1009 paramObj
1010}
1011
1012func (r ReinforcementMethodParam) MarshalJSON() (data []byte, err error) {
1013 type shadow ReinforcementMethodParam
1014 return param.MarshalObject(r, (*shadow)(&r))
1015}
1016func (r *ReinforcementMethodParam) UnmarshalJSON(data []byte) error {
1017 return apijson.UnmarshalRoot(data, r)
1018}
1019
1020// Only one field can be non-zero.
1021//
1022// Use [param.IsOmitted] to confirm if a field is set.
1023type ReinforcementMethodGraderUnionParam struct {
1024 OfStringCheckGrader *StringCheckGraderParam `json:",omitzero,inline"`
1025 OfTextSimilarityGrader *TextSimilarityGraderParam `json:",omitzero,inline"`
1026 OfPythonGrader *PythonGraderParam `json:",omitzero,inline"`
1027 OfScoreModelGrader *ScoreModelGraderParam `json:",omitzero,inline"`
1028 OfMultiGrader *MultiGraderParam `json:",omitzero,inline"`
1029 paramUnion
1030}
1031
1032func (u ReinforcementMethodGraderUnionParam) MarshalJSON() ([]byte, error) {
1033 return param.MarshalUnion(u, u.OfStringCheckGrader,
1034 u.OfTextSimilarityGrader,
1035 u.OfPythonGrader,
1036 u.OfScoreModelGrader,
1037 u.OfMultiGrader)
1038}
1039func (u *ReinforcementMethodGraderUnionParam) UnmarshalJSON(data []byte) error {
1040 return apijson.UnmarshalRoot(data, u)
1041}
1042
1043func (u *ReinforcementMethodGraderUnionParam) asAny() any {
1044 if !param.IsOmitted(u.OfStringCheckGrader) {
1045 return u.OfStringCheckGrader
1046 } else if !param.IsOmitted(u.OfTextSimilarityGrader) {
1047 return u.OfTextSimilarityGrader
1048 } else if !param.IsOmitted(u.OfPythonGrader) {
1049 return u.OfPythonGrader
1050 } else if !param.IsOmitted(u.OfScoreModelGrader) {
1051 return u.OfScoreModelGrader
1052 } else if !param.IsOmitted(u.OfMultiGrader) {
1053 return u.OfMultiGrader
1054 }
1055 return nil
1056}
1057
1058// Returns a pointer to the underlying variant's property, if present.
1059func (u ReinforcementMethodGraderUnionParam) GetOperation() *string {
1060 if vt := u.OfStringCheckGrader; vt != nil {
1061 return (*string)(&vt.Operation)
1062 }
1063 return nil
1064}
1065
1066// Returns a pointer to the underlying variant's property, if present.
1067func (u ReinforcementMethodGraderUnionParam) GetEvaluationMetric() *string {
1068 if vt := u.OfTextSimilarityGrader; vt != nil {
1069 return (*string)(&vt.EvaluationMetric)
1070 }
1071 return nil
1072}
1073
1074// Returns a pointer to the underlying variant's property, if present.
1075func (u ReinforcementMethodGraderUnionParam) GetSource() *string {
1076 if vt := u.OfPythonGrader; vt != nil {
1077 return &vt.Source
1078 }
1079 return nil
1080}
1081
1082// Returns a pointer to the underlying variant's property, if present.
1083func (u ReinforcementMethodGraderUnionParam) GetImageTag() *string {
1084 if vt := u.OfPythonGrader; vt != nil && vt.ImageTag.Valid() {
1085 return &vt.ImageTag.Value
1086 }
1087 return nil
1088}
1089
1090// Returns a pointer to the underlying variant's property, if present.
1091func (u ReinforcementMethodGraderUnionParam) GetModel() *string {
1092 if vt := u.OfScoreModelGrader; vt != nil {
1093 return &vt.Model
1094 }
1095 return nil
1096}
1097
1098// Returns a pointer to the underlying variant's property, if present.
1099func (u ReinforcementMethodGraderUnionParam) GetRange() []float64 {
1100 if vt := u.OfScoreModelGrader; vt != nil {
1101 return vt.Range
1102 }
1103 return nil
1104}
1105
1106// Returns a pointer to the underlying variant's property, if present.
1107func (u ReinforcementMethodGraderUnionParam) GetSamplingParams() *any {
1108 if vt := u.OfScoreModelGrader; vt != nil {
1109 return &vt.SamplingParams
1110 }
1111 return nil
1112}
1113
1114// Returns a pointer to the underlying variant's property, if present.
1115func (u ReinforcementMethodGraderUnionParam) GetCalculateOutput() *string {
1116 if vt := u.OfMultiGrader; vt != nil {
1117 return &vt.CalculateOutput
1118 }
1119 return nil
1120}
1121
1122// Returns a pointer to the underlying variant's property, if present.
1123func (u ReinforcementMethodGraderUnionParam) GetGraders() *MultiGraderGradersUnionParam {
1124 if vt := u.OfMultiGrader; vt != nil {
1125 return &vt.Graders
1126 }
1127 return nil
1128}
1129
1130// Returns a pointer to the underlying variant's property, if present.
1131func (u ReinforcementMethodGraderUnionParam) GetName() *string {
1132 if vt := u.OfStringCheckGrader; vt != nil {
1133 return (*string)(&vt.Name)
1134 } else if vt := u.OfTextSimilarityGrader; vt != nil {
1135 return (*string)(&vt.Name)
1136 } else if vt := u.OfPythonGrader; vt != nil {
1137 return (*string)(&vt.Name)
1138 } else if vt := u.OfScoreModelGrader; vt != nil {
1139 return (*string)(&vt.Name)
1140 } else if vt := u.OfMultiGrader; vt != nil {
1141 return (*string)(&vt.Name)
1142 }
1143 return nil
1144}
1145
1146// Returns a pointer to the underlying variant's property, if present.
1147func (u ReinforcementMethodGraderUnionParam) GetReference() *string {
1148 if vt := u.OfStringCheckGrader; vt != nil {
1149 return (*string)(&vt.Reference)
1150 } else if vt := u.OfTextSimilarityGrader; vt != nil {
1151 return (*string)(&vt.Reference)
1152 }
1153 return nil
1154}
1155
1156// Returns a pointer to the underlying variant's property, if present.
1157func (u ReinforcementMethodGraderUnionParam) GetType() *string {
1158 if vt := u.OfStringCheckGrader; vt != nil {
1159 return (*string)(&vt.Type)
1160 } else if vt := u.OfTextSimilarityGrader; vt != nil {
1161 return (*string)(&vt.Type)
1162 } else if vt := u.OfPythonGrader; vt != nil {
1163 return (*string)(&vt.Type)
1164 } else if vt := u.OfScoreModelGrader; vt != nil {
1165 return (*string)(&vt.Type)
1166 } else if vt := u.OfMultiGrader; vt != nil {
1167 return (*string)(&vt.Type)
1168 }
1169 return nil
1170}
1171
1172// Returns a subunion which exports methods to access subproperties
1173//
1174// Or use AsAny() to get the underlying value
1175func (u ReinforcementMethodGraderUnionParam) GetInput() (res reinforcementMethodGraderUnionParamInput) {
1176 if vt := u.OfStringCheckGrader; vt != nil {
1177 res.any = &vt.Input
1178 } else if vt := u.OfTextSimilarityGrader; vt != nil {
1179 res.any = &vt.Input
1180 } else if vt := u.OfScoreModelGrader; vt != nil {
1181 res.any = &vt.Input
1182 }
1183 return
1184}
1185
1186// Can have the runtime types [*string], [\*[]ScoreModelGraderInputParam]
1187type reinforcementMethodGraderUnionParamInput struct{ any }
1188
1189// Use the following switch statement to get the type of the union:
1190//
1191// switch u.AsAny().(type) {
1192// case *string:
1193// case *[]openai.ScoreModelGraderInputParam:
1194// default:
1195// fmt.Errorf("not present")
1196// }
1197func (u reinforcementMethodGraderUnionParamInput) AsAny() any { return u.any }
1198
1199// The hyperparameters used for the fine-tuning job.
1200type SupervisedHyperparametersResp struct {
1201 // Number of examples in each batch. A larger batch size means that model
1202 // parameters are updated less frequently, but with lower variance.
1203 BatchSize SupervisedHyperparametersBatchSizeUnionResp `json:"batch_size"`
1204 // Scaling factor for the learning rate. A smaller learning rate may be useful to
1205 // avoid overfitting.
1206 LearningRateMultiplier SupervisedHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
1207 // The number of epochs to train the model for. An epoch refers to one full cycle
1208 // through the training dataset.
1209 NEpochs SupervisedHyperparametersNEpochsUnionResp `json:"n_epochs"`
1210 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1211 JSON struct {
1212 BatchSize respjson.Field
1213 LearningRateMultiplier respjson.Field
1214 NEpochs respjson.Field
1215 ExtraFields map[string]respjson.Field
1216 raw string
1217 } `json:"-"`
1218}
1219
1220// Returns the unmodified JSON received from the API
1221func (r SupervisedHyperparametersResp) RawJSON() string { return r.JSON.raw }
1222func (r *SupervisedHyperparametersResp) UnmarshalJSON(data []byte) error {
1223 return apijson.UnmarshalRoot(data, r)
1224}
1225
1226// ToParam converts this SupervisedHyperparametersResp to a
1227// SupervisedHyperparameters.
1228//
1229// Warning: the fields of the param type will not be present. ToParam should only
1230// be used at the last possible moment before sending a request. Test for this with
1231// SupervisedHyperparameters.Overrides()
1232func (r SupervisedHyperparametersResp) ToParam() SupervisedHyperparameters {
1233 return param.Override[SupervisedHyperparameters](json.RawMessage(r.RawJSON()))
1234}
1235
1236// SupervisedHyperparametersBatchSizeUnionResp contains all possible properties and
1237// values from [constant.Auto], [int64].
1238//
1239// Use the methods beginning with 'As' to cast the union to one of its variants.
1240//
1241// If the underlying value is not a json object, one of the following properties
1242// will be valid: OfAuto OfInt]
1243type SupervisedHyperparametersBatchSizeUnionResp struct {
1244 // This field will be present if the value is a [constant.Auto] instead of an
1245 // object.
1246 OfAuto constant.Auto `json:",inline"`
1247 // This field will be present if the value is a [int64] instead of an object.
1248 OfInt int64 `json:",inline"`
1249 JSON struct {
1250 OfAuto respjson.Field
1251 OfInt respjson.Field
1252 raw string
1253 } `json:"-"`
1254}
1255
1256func (u SupervisedHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto) {
1257 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1258 return
1259}
1260
1261func (u SupervisedHyperparametersBatchSizeUnionResp) AsInt() (v int64) {
1262 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1263 return
1264}
1265
1266// Returns the unmodified JSON received from the API
1267func (u SupervisedHyperparametersBatchSizeUnionResp) RawJSON() string { return u.JSON.raw }
1268
1269func (r *SupervisedHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error {
1270 return apijson.UnmarshalRoot(data, r)
1271}
1272
1273// SupervisedHyperparametersLearningRateMultiplierUnionResp contains all possible
1274// properties and values from [constant.Auto], [float64].
1275//
1276// Use the methods beginning with 'As' to cast the union to one of its variants.
1277//
1278// If the underlying value is not a json object, one of the following properties
1279// will be valid: OfAuto OfFloat]
1280type SupervisedHyperparametersLearningRateMultiplierUnionResp struct {
1281 // This field will be present if the value is a [constant.Auto] instead of an
1282 // object.
1283 OfAuto constant.Auto `json:",inline"`
1284 // This field will be present if the value is a [float64] instead of an object.
1285 OfFloat float64 `json:",inline"`
1286 JSON struct {
1287 OfAuto respjson.Field
1288 OfFloat respjson.Field
1289 raw string
1290 } `json:"-"`
1291}
1292
1293func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto) {
1294 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1295 return
1296}
1297
1298func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64) {
1299 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1300 return
1301}
1302
1303// Returns the unmodified JSON received from the API
1304func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) RawJSON() string { return u.JSON.raw }
1305
1306func (r *SupervisedHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error {
1307 return apijson.UnmarshalRoot(data, r)
1308}
1309
1310// SupervisedHyperparametersNEpochsUnionResp contains all possible properties and
1311// values from [constant.Auto], [int64].
1312//
1313// Use the methods beginning with 'As' to cast the union to one of its variants.
1314//
1315// If the underlying value is not a json object, one of the following properties
1316// will be valid: OfAuto OfInt]
1317type SupervisedHyperparametersNEpochsUnionResp struct {
1318 // This field will be present if the value is a [constant.Auto] instead of an
1319 // object.
1320 OfAuto constant.Auto `json:",inline"`
1321 // This field will be present if the value is a [int64] instead of an object.
1322 OfInt int64 `json:",inline"`
1323 JSON struct {
1324 OfAuto respjson.Field
1325 OfInt respjson.Field
1326 raw string
1327 } `json:"-"`
1328}
1329
1330func (u SupervisedHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto) {
1331 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1332 return
1333}
1334
1335func (u SupervisedHyperparametersNEpochsUnionResp) AsInt() (v int64) {
1336 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1337 return
1338}
1339
1340// Returns the unmodified JSON received from the API
1341func (u SupervisedHyperparametersNEpochsUnionResp) RawJSON() string { return u.JSON.raw }
1342
1343func (r *SupervisedHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error {
1344 return apijson.UnmarshalRoot(data, r)
1345}
1346
1347// The hyperparameters used for the fine-tuning job.
1348type SupervisedHyperparameters struct {
1349 // Number of examples in each batch. A larger batch size means that model
1350 // parameters are updated less frequently, but with lower variance.
1351 BatchSize SupervisedHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
1352 // Scaling factor for the learning rate. A smaller learning rate may be useful to
1353 // avoid overfitting.
1354 LearningRateMultiplier SupervisedHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
1355 // The number of epochs to train the model for. An epoch refers to one full cycle
1356 // through the training dataset.
1357 NEpochs SupervisedHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
1358 paramObj
1359}
1360
1361func (r SupervisedHyperparameters) MarshalJSON() (data []byte, err error) {
1362 type shadow SupervisedHyperparameters
1363 return param.MarshalObject(r, (*shadow)(&r))
1364}
1365func (r *SupervisedHyperparameters) UnmarshalJSON(data []byte) error {
1366 return apijson.UnmarshalRoot(data, r)
1367}
1368
1369// Only one field can be non-zero.
1370//
1371// Use [param.IsOmitted] to confirm if a field is set.
1372type SupervisedHyperparametersBatchSizeUnion struct {
1373 // Construct this variant with constant.ValueOf[constant.Auto]()
1374 OfAuto constant.Auto `json:",omitzero,inline"`
1375 OfInt param.Opt[int64] `json:",omitzero,inline"`
1376 paramUnion
1377}
1378
1379func (u SupervisedHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error) {
1380 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
1381}
1382func (u *SupervisedHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error {
1383 return apijson.UnmarshalRoot(data, u)
1384}
1385
1386func (u *SupervisedHyperparametersBatchSizeUnion) asAny() any {
1387 if !param.IsOmitted(u.OfAuto) {
1388 return &u.OfAuto
1389 } else if !param.IsOmitted(u.OfInt) {
1390 return &u.OfInt.Value
1391 }
1392 return nil
1393}
1394
1395// Only one field can be non-zero.
1396//
1397// Use [param.IsOmitted] to confirm if a field is set.
1398type SupervisedHyperparametersLearningRateMultiplierUnion struct {
1399 // Construct this variant with constant.ValueOf[constant.Auto]()
1400 OfAuto constant.Auto `json:",omitzero,inline"`
1401 OfFloat param.Opt[float64] `json:",omitzero,inline"`
1402 paramUnion
1403}
1404
1405func (u SupervisedHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error) {
1406 return param.MarshalUnion(u, u.OfAuto, u.OfFloat)
1407}
1408func (u *SupervisedHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error {
1409 return apijson.UnmarshalRoot(data, u)
1410}
1411
1412func (u *SupervisedHyperparametersLearningRateMultiplierUnion) asAny() any {
1413 if !param.IsOmitted(u.OfAuto) {
1414 return &u.OfAuto
1415 } else if !param.IsOmitted(u.OfFloat) {
1416 return &u.OfFloat.Value
1417 }
1418 return nil
1419}
1420
1421// Only one field can be non-zero.
1422//
1423// Use [param.IsOmitted] to confirm if a field is set.
1424type SupervisedHyperparametersNEpochsUnion struct {
1425 // Construct this variant with constant.ValueOf[constant.Auto]()
1426 OfAuto constant.Auto `json:",omitzero,inline"`
1427 OfInt param.Opt[int64] `json:",omitzero,inline"`
1428 paramUnion
1429}
1430
1431func (u SupervisedHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error) {
1432 return param.MarshalUnion(u, u.OfAuto, u.OfInt)
1433}
1434func (u *SupervisedHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error {
1435 return apijson.UnmarshalRoot(data, u)
1436}
1437
1438func (u *SupervisedHyperparametersNEpochsUnion) asAny() any {
1439 if !param.IsOmitted(u.OfAuto) {
1440 return &u.OfAuto
1441 } else if !param.IsOmitted(u.OfInt) {
1442 return &u.OfInt.Value
1443 }
1444 return nil
1445}
1446
1447// Configuration for the supervised fine-tuning method.
1448type SupervisedMethod struct {
1449 // The hyperparameters used for the fine-tuning job.
1450 Hyperparameters SupervisedHyperparametersResp `json:"hyperparameters"`
1451 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1452 JSON struct {
1453 Hyperparameters respjson.Field
1454 ExtraFields map[string]respjson.Field
1455 raw string
1456 } `json:"-"`
1457}
1458
1459// Returns the unmodified JSON received from the API
1460func (r SupervisedMethod) RawJSON() string { return r.JSON.raw }
1461func (r *SupervisedMethod) UnmarshalJSON(data []byte) error {
1462 return apijson.UnmarshalRoot(data, r)
1463}
1464
1465// ToParam converts this SupervisedMethod to a SupervisedMethodParam.
1466//
1467// Warning: the fields of the param type will not be present. ToParam should only
1468// be used at the last possible moment before sending a request. Test for this with
1469// SupervisedMethodParam.Overrides()
1470func (r SupervisedMethod) ToParam() SupervisedMethodParam {
1471 return param.Override[SupervisedMethodParam](json.RawMessage(r.RawJSON()))
1472}
1473
1474// Configuration for the supervised fine-tuning method.
1475type SupervisedMethodParam struct {
1476 // The hyperparameters used for the fine-tuning job.
1477 Hyperparameters SupervisedHyperparameters `json:"hyperparameters,omitzero"`
1478 paramObj
1479}
1480
1481func (r SupervisedMethodParam) MarshalJSON() (data []byte, err error) {
1482 type shadow SupervisedMethodParam
1483 return param.MarshalObject(r, (*shadow)(&r))
1484}
1485func (r *SupervisedMethodParam) UnmarshalJSON(data []byte) error {
1486 return apijson.UnmarshalRoot(data, r)
1487}