A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/openai/openai-go@v1.12.0/packages/param below:

param package - github.com/openai/openai-go/packages/param - Go Packages

Omit can be used with [metadata.SetExtraFields] to ensure that a required field is omitted. This is useful as an escape hatch for when a required is unwanted for some unexpected reason.

This section is empty.

IsNull returns true if v was set to the JSON value null.

To set a param to null use NullStruct, Null, NullMap, or NullSlice depending on the type of v.

IsNull returns false if the value is omitted.

IsOmitted returns true if v is the zero value of its type.

If IsOmitted is true, and the field uses a `json:"...,omitzero"` tag, the field will be omitted from the request.

If v is set explicitly to the JSON value "null", IsOmitted returns false.

MarshalObject uses a shimmed 'encoding/json' from Go 1.24, to support the 'omitzero' tag

Stability for the API of MarshalObject is not guaranteed.

MarshalUnion uses a shimmed 'encoding/json' from Go 1.24, to support the 'omitzero' tag

Stability for the API of MarshalUnion is not guaranteed.

MarshalWithExtras is used to marshal a struct with additional properties.

Stability for the API of MarshalWithExtras is not guaranteed.

func NullMap[MapT ~map[string]T, T any]() MapT

NullMap returns a non-nil map with a length of 0. When used with MarshalObject or MarshalUnion, it will be marshaled as null.

It is unspecified behavior to mutate the map returned by NullMap.

func NullSlice[SliceT ~[]T, T any]() SliceT

NullSlice returns a non-nil slice with a length of 0. When used with MarshalObject or MarshalUnion, it will be marshaled as null.

It is unspecified behavior to mutate the slice returned by NullSlice.

NullStruct is used to set a struct to the JSON value null. Check for null structs with IsNull.

Only the first type parameter should be provided, the type PtrT will be inferred.

json.Marshal(param.NullStruct[MyStruct]()) -> 'null'

To send null to an Opt field use Null.

Override replaces the value of a struct with any type.

Only the first type parameter should be provided, the type PtrT will be inferred.

It's often useful for providing raw JSON

param.Override[MyStruct](json.RawMessage(`{"foo": "bar"}`))

The public fields of the returned struct T will be unset.

To override a specific field in a struct, use its [SetExtraFields] method.

type APIObject struct {
	
}

APIObject should be embedded in api object fields, preferably using an alias to make private

func (m APIObject) ExtraFields() map[string]any

ExtraFields returns the extra fields added to the JSON object.

func (m APIObject) Overrides() (any, bool)

Overrides returns the value of the struct when it is created with Override, the second argument helps differentiate an explicit null.

func (m *APIObject) SetExtraFields(extraFields map[string]any)

SetExtraFields adds extra fields to the JSON object.

SetExtraFields will override any existing fields with the same key. For security reasons, ensure this is only used with trusted input data.

To intentionally omit a required field, use Omit.

foo.SetExtraFields(map[string]any{"bar": Omit})

If the struct already contains the field ExtraFields, then this method will have no effect.

APIUnion should be embedded in all api unions fields, preferably using an alias to make private

func (m APIUnion) ExtraFields() map[string]any

ExtraFields returns the extra fields added to the JSON object.

func (m APIUnion) Overrides() (any, bool)

Overrides returns the value of the struct when it is created with Override, the second argument helps differentiate an explicit null.

func (m *APIUnion) SetExtraFields(extraFields map[string]any)

SetExtraFields adds extra fields to the JSON object.

SetExtraFields will override any existing fields with the same key. For security reasons, ensure this is only used with trusted input data.

To intentionally omit a required field, use Omit.

foo.SetExtraFields(map[string]any{"bar": Omit})

If the struct already contains the field ExtraFields, then this method will have no effect.

EncodedAsDate is not be stable and shouldn't be relied upon

This is an implementation detail and should never be explicitly set.

Opt represents an optional parameter of type T. Use the Opt.Valid method to confirm.

Null creates optional field with the JSON value "null".

To set a struct to null, use NullStruct.

MarshalJSONWithTimeLayout is necessary to bypass the internal caching performed by json.Marshal. Prefer to use Opt.MarshalJSON instead.

This function requires that the generic type parameter of Opt is not time.Time.

func (o Opt[T]) Or(v T) T

Valid returns true if the value is not "null" or omitted.

To check if explicitly null, use [Opt.Null].

type Optional interface {
	Valid() bool
	
}

This interface is useful for internal purposes.

type ParamNullable interface {
	
}

ParamNullable encapsulates all structs in parameters, and all Opt types in parameters.

type ParamStruct interface {
	Overrides() (any, bool)
	
}

ParamStruct represents the set of all structs that are used in API parameters, by convention these usually end in "Params" or "Param".


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4