mirror of
https://github.com/openai/openai-go.git
synced 2026-04-01 17:17:14 +09:00
fix(client)!: improve union variant names
This commit is contained in:
@@ -926,7 +926,7 @@ func (r *MessageAttachment) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
// MessageAttachmentToolUnion contains all possible properties and values from
|
||||
// [CodeInterpreterTool], [MessageAttachmentToolAssistantToolsFileSearchTypeOnly].
|
||||
// [CodeInterpreterTool], [MessageAttachmentToolFileSearchTool].
|
||||
//
|
||||
// Use the methods beginning with 'As' to cast the union to one of its variants.
|
||||
type MessageAttachmentToolUnion struct {
|
||||
@@ -942,7 +942,7 @@ func (u MessageAttachmentToolUnion) AsCodeInterpreterTool() (v CodeInterpreterTo
|
||||
return
|
||||
}
|
||||
|
||||
func (u MessageAttachmentToolUnion) AsFileSearchTool() (v MessageAttachmentToolAssistantToolsFileSearchTypeOnly) {
|
||||
func (u MessageAttachmentToolUnion) AsFileSearchTool() (v MessageAttachmentToolFileSearchTool) {
|
||||
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
|
||||
return
|
||||
}
|
||||
@@ -954,7 +954,7 @@ func (r *MessageAttachmentToolUnion) UnmarshalJSON(data []byte) error {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct {
|
||||
type MessageAttachmentToolFileSearchTool struct {
|
||||
// The type of tool being defined: `file_search`
|
||||
Type constant.FileSearch `json:"type,required"`
|
||||
// Metadata for the response, check the presence of optional fields with the
|
||||
@@ -967,8 +967,8 @@ type MessageAttachmentToolAssistantToolsFileSearchTypeOnly struct {
|
||||
}
|
||||
|
||||
// Returns the unmodified JSON received from the API
|
||||
func (r MessageAttachmentToolAssistantToolsFileSearchTypeOnly) RawJSON() string { return r.JSON.raw }
|
||||
func (r *MessageAttachmentToolAssistantToolsFileSearchTypeOnly) UnmarshalJSON(data []byte) error {
|
||||
func (r MessageAttachmentToolFileSearchTool) RawJSON() string { return r.JSON.raw }
|
||||
func (r *MessageAttachmentToolFileSearchTool) UnmarshalJSON(data []byte) error {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
|
||||
@@ -2518,8 +2518,8 @@ const (
|
||||
//
|
||||
// Use [param.IsOmitted] to confirm if a field is set.
|
||||
type ChatCompletionNewParamsStopUnion struct {
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfChatCompletionNewsStopArray []string `json:",omitzero,inline"`
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfStringArray []string `json:",omitzero,inline"`
|
||||
paramUnion
|
||||
}
|
||||
|
||||
@@ -2527,14 +2527,14 @@ type ChatCompletionNewParamsStopUnion struct {
|
||||
// "null". To check if this field is omitted, use [param.IsOmitted].
|
||||
func (u ChatCompletionNewParamsStopUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
|
||||
func (u ChatCompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) {
|
||||
return param.MarshalUnion[ChatCompletionNewParamsStopUnion](u.OfString, u.OfChatCompletionNewsStopArray)
|
||||
return param.MarshalUnion[ChatCompletionNewParamsStopUnion](u.OfString, u.OfStringArray)
|
||||
}
|
||||
|
||||
func (u *ChatCompletionNewParamsStopUnion) asAny() any {
|
||||
if !param.IsOmitted(u.OfString) {
|
||||
return &u.OfString.Value
|
||||
} else if !param.IsOmitted(u.OfChatCompletionNewsStopArray) {
|
||||
return &u.OfChatCompletionNewsStopArray
|
||||
} else if !param.IsOmitted(u.OfStringArray) {
|
||||
return &u.OfStringArray
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -411,8 +411,8 @@ func (u *CompletionNewParamsPromptUnion) asAny() any {
|
||||
//
|
||||
// Use [param.IsOmitted] to confirm if a field is set.
|
||||
type CompletionNewParamsStopUnion struct {
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfCompletionNewsStopArray []string `json:",omitzero,inline"`
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfStringArray []string `json:",omitzero,inline"`
|
||||
paramUnion
|
||||
}
|
||||
|
||||
@@ -420,14 +420,14 @@ type CompletionNewParamsStopUnion struct {
|
||||
// "null". To check if this field is omitted, use [param.IsOmitted].
|
||||
func (u CompletionNewParamsStopUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
|
||||
func (u CompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) {
|
||||
return param.MarshalUnion[CompletionNewParamsStopUnion](u.OfString, u.OfCompletionNewsStopArray)
|
||||
return param.MarshalUnion[CompletionNewParamsStopUnion](u.OfString, u.OfStringArray)
|
||||
}
|
||||
|
||||
func (u *CompletionNewParamsStopUnion) asAny() any {
|
||||
if !param.IsOmitted(u.OfString) {
|
||||
return &u.OfString.Value
|
||||
} else if !param.IsOmitted(u.OfCompletionNewsStopArray) {
|
||||
return &u.OfCompletionNewsStopArray
|
||||
} else if !param.IsOmitted(u.OfStringArray) {
|
||||
return &u.OfStringArray
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
10
image.go
10
image.go
@@ -309,8 +309,8 @@ func (r ImageEditParams) MarshalMultipart() (data []byte, contentType string, er
|
||||
//
|
||||
// Use [param.IsOmitted] to confirm if a field is set.
|
||||
type ImageEditParamsImageUnion struct {
|
||||
OfFile io.Reader `json:",omitzero,inline"`
|
||||
OfImageEditsImageArray []io.Reader `json:",omitzero,inline"`
|
||||
OfFile io.Reader `json:",omitzero,inline"`
|
||||
OfBinaryArray []io.Reader `json:",omitzero,inline"`
|
||||
paramUnion
|
||||
}
|
||||
|
||||
@@ -318,14 +318,14 @@ type ImageEditParamsImageUnion struct {
|
||||
// "null". To check if this field is omitted, use [param.IsOmitted].
|
||||
func (u ImageEditParamsImageUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
|
||||
func (u ImageEditParamsImageUnion) MarshalJSON() ([]byte, error) {
|
||||
return param.MarshalUnion[ImageEditParamsImageUnion](u.OfFile, u.OfImageEditsImageArray)
|
||||
return param.MarshalUnion[ImageEditParamsImageUnion](u.OfFile, u.OfBinaryArray)
|
||||
}
|
||||
|
||||
func (u *ImageEditParamsImageUnion) asAny() any {
|
||||
if !param.IsOmitted(u.OfFile) {
|
||||
return &u.OfFile
|
||||
} else if !param.IsOmitted(u.OfImageEditsImageArray) {
|
||||
return &u.OfImageEditsImageArray
|
||||
} else if !param.IsOmitted(u.OfBinaryArray) {
|
||||
return &u.OfBinaryArray
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ func (r ModerationNewParams) MarshalJSON() (data []byte, err error) {
|
||||
// Use [param.IsOmitted] to confirm if a field is set.
|
||||
type ModerationNewParamsInputUnion struct {
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfModerationNewsInputArray []string `json:",omitzero,inline"`
|
||||
OfStringArray []string `json:",omitzero,inline"`
|
||||
OfModerationMultiModalArray []ModerationMultiModalInputUnionParam `json:",omitzero,inline"`
|
||||
paramUnion
|
||||
}
|
||||
@@ -490,14 +490,14 @@ type ModerationNewParamsInputUnion struct {
|
||||
// "null". To check if this field is omitted, use [param.IsOmitted].
|
||||
func (u ModerationNewParamsInputUnion) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
|
||||
func (u ModerationNewParamsInputUnion) MarshalJSON() ([]byte, error) {
|
||||
return param.MarshalUnion[ModerationNewParamsInputUnion](u.OfString, u.OfModerationNewsInputArray, u.OfModerationMultiModalArray)
|
||||
return param.MarshalUnion[ModerationNewParamsInputUnion](u.OfString, u.OfStringArray, u.OfModerationMultiModalArray)
|
||||
}
|
||||
|
||||
func (u *ModerationNewParamsInputUnion) asAny() any {
|
||||
if !param.IsOmitted(u.OfString) {
|
||||
return &u.OfString.Value
|
||||
} else if !param.IsOmitted(u.OfModerationNewsInputArray) {
|
||||
return &u.OfModerationNewsInputArray
|
||||
} else if !param.IsOmitted(u.OfStringArray) {
|
||||
return &u.OfStringArray
|
||||
} else if !param.IsOmitted(u.OfModerationMultiModalArray) {
|
||||
return &u.OfModerationMultiModalArray
|
||||
}
|
||||
|
||||
@@ -832,8 +832,8 @@ func (r VectorStoreSearchParams) MarshalJSON() (data []byte, err error) {
|
||||
//
|
||||
// Use [param.IsOmitted] to confirm if a field is set.
|
||||
type VectorStoreSearchParamsQueryUnion struct {
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfVectorStoreSearchsQueryArray []string `json:",omitzero,inline"`
|
||||
OfString param.Opt[string] `json:",omitzero,inline"`
|
||||
OfStringArray []string `json:",omitzero,inline"`
|
||||
paramUnion
|
||||
}
|
||||
|
||||
@@ -843,14 +843,14 @@ func (u VectorStoreSearchParamsQueryUnion) IsPresent() bool {
|
||||
return !param.IsOmitted(u) && !u.IsNull()
|
||||
}
|
||||
func (u VectorStoreSearchParamsQueryUnion) MarshalJSON() ([]byte, error) {
|
||||
return param.MarshalUnion[VectorStoreSearchParamsQueryUnion](u.OfString, u.OfVectorStoreSearchsQueryArray)
|
||||
return param.MarshalUnion[VectorStoreSearchParamsQueryUnion](u.OfString, u.OfStringArray)
|
||||
}
|
||||
|
||||
func (u *VectorStoreSearchParamsQueryUnion) asAny() any {
|
||||
if !param.IsOmitted(u.OfString) {
|
||||
return &u.OfString.Value
|
||||
} else if !param.IsOmitted(u.OfVectorStoreSearchsQueryArray) {
|
||||
return &u.OfVectorStoreSearchsQueryArray
|
||||
} else if !param.IsOmitted(u.OfStringArray) {
|
||||
return &u.OfStringArray
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user