From 59579a2d0fa7f2dacdc813f139c6f79dbf209490 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Tue, 5 Nov 2024 18:06:36 +0000 Subject: [PATCH] refactor: sort fields for squashed union structs --- betaassistant.go | 34 +++++++++--------- betathread.go | 6 ++-- betathreadmessage.go | 68 ++++++++++++++++++------------------ betathreadrunstep.go | 82 ++++++++++++++++++++++---------------------- chatcompletion.go | 26 +++++++------- moderation.go | 4 +-- 6 files changed, 110 insertions(+), 110 deletions(-) diff --git a/betaassistant.go b/betaassistant.go index 6fd30698..99272e9a 100644 --- a/betaassistant.go +++ b/betaassistant.go @@ -335,22 +335,22 @@ func (r AssistantDeletedObject) IsKnown() bool { // [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview) // to learn how to integrate the Assistants API with streaming. type AssistantStreamEvent struct { - // Whether to enable input audio transcription. - Enabled bool `json:"enabled"` - Event AssistantStreamEventEvent `json:"event,required"` + Event AssistantStreamEventEvent `json:"event,required"` // This field can have the runtime type of [Thread], [Run], [RunStep], // [RunStepDeltaEvent], [Message], [MessageDeltaEvent], [shared.ErrorObject]. - Data interface{} `json:"data"` - JSON assistantStreamEventJSON `json:"-"` - union AssistantStreamEventUnion + Data interface{} `json:"data"` + // Whether to enable input audio transcription. + Enabled bool `json:"enabled"` + JSON assistantStreamEventJSON `json:"-"` + union AssistantStreamEventUnion } // assistantStreamEventJSON contains the JSON metadata for the struct // [AssistantStreamEvent] type assistantStreamEventJSON struct { - Enabled apijson.Field Event apijson.Field Data apijson.Field + Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1651,19 +1651,19 @@ func (r AssistantStreamEventEvent) IsKnown() bool { } type AssistantTool struct { - // The type of tool being defined: `code_interpreter` - Type AssistantToolType `json:"type,required"` // This field can have the runtime type of [FileSearchToolFileSearch]. - FileSearch interface{} `json:"file_search,required"` - Function shared.FunctionDefinition `json:"function"` - JSON assistantToolJSON `json:"-"` - union AssistantToolUnion + FileSearch interface{} `json:"file_search,required"` + // The type of tool being defined: `code_interpreter` + Type AssistantToolType `json:"type,required"` + Function shared.FunctionDefinition `json:"function"` + JSON assistantToolJSON `json:"-"` + union AssistantToolUnion } // assistantToolJSON contains the JSON metadata for the struct [AssistantTool] type assistantToolJSON struct { - Type apijson.Field FileSearch apijson.Field + Type apijson.Field Function apijson.Field raw string ExtraFields map[string]apijson.Field @@ -1736,10 +1736,10 @@ func (r AssistantToolType) IsKnown() bool { } type AssistantToolParam struct { + FileSearch param.Field[interface{}] `json:"file_search,required"` // The type of tool being defined: `code_interpreter` - Type param.Field[AssistantToolType] `json:"type,required"` - FileSearch param.Field[interface{}] `json:"file_search,required"` - Function param.Field[shared.FunctionDefinitionParam] `json:"function"` + Type param.Field[AssistantToolType] `json:"type,required"` + Function param.Field[shared.FunctionDefinitionParam] `json:"function"` } func (r AssistantToolParam) MarshalJSON() (data []byte, err error) { diff --git a/betathread.go b/betathread.go index c9561c3b..dc057660 100644 --- a/betathread.go +++ b/betathread.go @@ -998,10 +998,10 @@ func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data [] } type BetaThreadNewAndRunParamsTool struct { + FileSearch param.Field[interface{}] `json:"file_search,required"` // The type of tool being defined: `code_interpreter` - Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"` - FileSearch param.Field[interface{}] `json:"file_search,required"` - Function param.Field[shared.FunctionDefinitionParam] `json:"function"` + Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"` + Function param.Field[shared.FunctionDefinitionParam] `json:"function"` } func (r BetaThreadNewAndRunParamsTool) MarshalJSON() (data []byte, err error) { diff --git a/betathreadmessage.go b/betathreadmessage.go index 9d99decc..27f2e0a1 100644 --- a/betathreadmessage.go +++ b/betathreadmessage.go @@ -133,28 +133,28 @@ func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, // File associated with the assistant or the message. Generated when the assistant // uses the "file_search" tool to search files. type Annotation struct { - // Always `file_citation`. - Type AnnotationType `json:"type,required"` - // The text in the message content that needs to be replaced. - Text string `json:"text,required"` + EndIndex int64 `json:"end_index,required"` // This field can have the runtime type of [FileCitationAnnotationFileCitation]. FileCitation interface{} `json:"file_citation,required"` - StartIndex int64 `json:"start_index,required"` - EndIndex int64 `json:"end_index,required"` // This field can have the runtime type of [FilePathAnnotationFilePath]. - FilePath interface{} `json:"file_path,required"` - JSON annotationJSON `json:"-"` - union AnnotationUnion + FilePath interface{} `json:"file_path,required"` + StartIndex int64 `json:"start_index,required"` + // The text in the message content that needs to be replaced. + Text string `json:"text,required"` + // Always `file_citation`. + Type AnnotationType `json:"type,required"` + JSON annotationJSON `json:"-"` + union AnnotationUnion } // annotationJSON contains the JSON metadata for the struct [Annotation] type annotationJSON struct { - Type apijson.Field - Text apijson.Field - FileCitation apijson.Field - StartIndex apijson.Field EndIndex apijson.Field + FileCitation apijson.Field FilePath apijson.Field + StartIndex apijson.Field + Text apijson.Field + Type apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -227,32 +227,32 @@ func (r AnnotationType) IsKnown() bool { // File associated with the assistant or the message. Generated when the assistant // uses the "file_search" tool to search files. type AnnotationDelta struct { - // The index of the annotation in the text content part. - Index int64 `json:"index,required"` - // Always `file_citation`. - Type AnnotationDeltaType `json:"type,required"` - // The text in the message content that needs to be replaced. - Text string `json:"text"` // This field can have the runtime type of // [FileCitationDeltaAnnotationFileCitation]. FileCitation interface{} `json:"file_citation,required"` - StartIndex int64 `json:"start_index"` - EndIndex int64 `json:"end_index"` // This field can have the runtime type of [FilePathDeltaAnnotationFilePath]. - FilePath interface{} `json:"file_path,required"` - JSON annotationDeltaJSON `json:"-"` - union AnnotationDeltaUnion + FilePath interface{} `json:"file_path,required"` + // The index of the annotation in the text content part. + Index int64 `json:"index,required"` + // Always `file_citation`. + Type AnnotationDeltaType `json:"type,required"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // The text in the message content that needs to be replaced. + Text string `json:"text"` + JSON annotationDeltaJSON `json:"-"` + union AnnotationDeltaUnion } // annotationDeltaJSON contains the JSON metadata for the struct [AnnotationDelta] type annotationDeltaJSON struct { + FileCitation apijson.Field + FilePath apijson.Field Index apijson.Field Type apijson.Field - Text apijson.Field - FileCitation apijson.Field - StartIndex apijson.Field EndIndex apijson.Field - FilePath apijson.Field + StartIndex apijson.Field + Text apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1336,8 +1336,8 @@ type MessageContent struct { Type MessageContentType `json:"type,required"` ImageFile ImageFile `json:"image_file"` ImageURL ImageURL `json:"image_url"` - Text Text `json:"text"` Refusal string `json:"refusal"` + Text Text `json:"text"` JSON messageContentJSON `json:"-"` union MessageContentUnion } @@ -1347,8 +1347,8 @@ type messageContentJSON struct { Type apijson.Field ImageFile apijson.Field ImageURL apijson.Field - Text apijson.Field Refusal apijson.Field + Text apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1437,9 +1437,9 @@ type MessageContentDelta struct { // Always `image_file`. Type MessageContentDeltaType `json:"type,required"` ImageFile ImageFileDelta `json:"image_file"` - Text TextDelta `json:"text"` - Refusal string `json:"refusal"` ImageURL ImageURLDelta `json:"image_url"` + Refusal string `json:"refusal"` + Text TextDelta `json:"text"` JSON messageContentDeltaJSON `json:"-"` union MessageContentDeltaUnion } @@ -1450,9 +1450,9 @@ type messageContentDeltaJSON struct { Index apijson.Field Type apijson.Field ImageFile apijson.Field - Text apijson.Field - Refusal apijson.Field ImageURL apijson.Field + Refusal apijson.Field + Text apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/betathreadrunstep.go b/betathreadrunstep.go index bb77de71..9fbf03cd 100644 --- a/betathreadrunstep.go +++ b/betathreadrunstep.go @@ -265,13 +265,13 @@ func (r codeInterpreterToolCallCodeInterpreterJSON) RawJSON() string { // Text output from the Code Interpreter tool call as part of a run step. type CodeInterpreterToolCallCodeInterpreterOutput struct { + // This field can have the runtime type of + // [CodeInterpreterToolCallCodeInterpreterOutputsImageImage]. + Image interface{} `json:"image,required"` // Always `logs`. Type CodeInterpreterToolCallCodeInterpreterOutputsType `json:"type,required"` // The text output from the Code Interpreter tool call. - Logs string `json:"logs"` - // This field can have the runtime type of - // [CodeInterpreterToolCallCodeInterpreterOutputsImageImage]. - Image interface{} `json:"image,required"` + Logs string `json:"logs"` JSON codeInterpreterToolCallCodeInterpreterOutputJSON `json:"-"` union CodeInterpreterToolCallCodeInterpreterOutputsUnion } @@ -279,9 +279,9 @@ type CodeInterpreterToolCallCodeInterpreterOutput struct { // codeInterpreterToolCallCodeInterpreterOutputJSON contains the JSON metadata for // the struct [CodeInterpreterToolCallCodeInterpreterOutput] type codeInterpreterToolCallCodeInterpreterOutputJSON struct { + Image apijson.Field Type apijson.Field Logs apijson.Field - Image apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -557,14 +557,14 @@ func (r codeInterpreterToolCallDeltaCodeInterpreterJSON) RawJSON() string { // Text output from the Code Interpreter tool call as part of a run step. type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct { + // This field can have the runtime type of [CodeInterpreterOutputImageImage]. + Image interface{} `json:"image,required"` // The index of the output in the outputs array. Index int64 `json:"index,required"` // Always `logs`. Type CodeInterpreterToolCallDeltaCodeInterpreterOutputsType `json:"type,required"` // The text output from the Code Interpreter tool call. - Logs string `json:"logs"` - // This field can have the runtime type of [CodeInterpreterOutputImageImage]. - Image interface{} `json:"image,required"` + Logs string `json:"logs"` JSON codeInterpreterToolCallDeltaCodeInterpreterOutputJSON `json:"-"` union CodeInterpreterToolCallDeltaCodeInterpreterOutputsUnion } @@ -572,10 +572,10 @@ type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct { // codeInterpreterToolCallDeltaCodeInterpreterOutputJSON contains the JSON metadata // for the struct [CodeInterpreterToolCallDeltaCodeInterpreterOutput] type codeInterpreterToolCallDeltaCodeInterpreterOutputJSON struct { + Image apijson.Field Index apijson.Field Type apijson.Field Logs apijson.Field - Image apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1262,23 +1262,23 @@ func (r RunStepStatus) IsKnown() bool { // The details of the run step. type RunStepStepDetails struct { - // Always `message_creation`. - Type RunStepStepDetailsType `json:"type,required"` // This field can have the runtime type of // [MessageCreationStepDetailsMessageCreation]. MessageCreation interface{} `json:"message_creation,required"` // This field can have the runtime type of [[]ToolCall]. - ToolCalls interface{} `json:"tool_calls,required"` - JSON runStepStepDetailsJSON `json:"-"` - union RunStepStepDetailsUnion + ToolCalls interface{} `json:"tool_calls,required"` + // Always `message_creation`. + Type RunStepStepDetailsType `json:"type,required"` + JSON runStepStepDetailsJSON `json:"-"` + union RunStepStepDetailsUnion } // runStepStepDetailsJSON contains the JSON metadata for the struct // [RunStepStepDetails] type runStepStepDetailsJSON struct { - Type apijson.Field MessageCreation apijson.Field ToolCalls apijson.Field + Type apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1414,23 +1414,23 @@ func (r runStepDeltaJSON) RawJSON() string { // The details of the run step. type RunStepDeltaStepDetails struct { - // Always `message_creation`. - Type RunStepDeltaStepDetailsType `json:"type,required"` // This field can have the runtime type of // [RunStepDeltaMessageDeltaMessageCreation]. MessageCreation interface{} `json:"message_creation,required"` // This field can have the runtime type of [[]ToolCallDelta]. - ToolCalls interface{} `json:"tool_calls,required"` - JSON runStepDeltaStepDetailsJSON `json:"-"` - union RunStepDeltaStepDetailsUnion + ToolCalls interface{} `json:"tool_calls,required"` + // Always `message_creation`. + Type RunStepDeltaStepDetailsType `json:"type,required"` + JSON runStepDeltaStepDetailsJSON `json:"-"` + union RunStepDeltaStepDetailsUnion } // runStepDeltaStepDetailsJSON contains the JSON metadata for the struct // [RunStepDeltaStepDetails] type runStepDeltaStepDetailsJSON struct { - Type apijson.Field MessageCreation apijson.Field ToolCalls apijson.Field + Type apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1624,27 +1624,27 @@ func (r RunStepInclude) IsKnown() bool { type ToolCall struct { // The ID of the tool call. ID string `json:"id,required"` - // The type of tool call. This is always going to be `code_interpreter` for this - // type of tool call. - Type ToolCallType `json:"type,required"` // This field can have the runtime type of // [CodeInterpreterToolCallCodeInterpreter]. CodeInterpreter interface{} `json:"code_interpreter,required"` // This field can have the runtime type of [FileSearchToolCallFileSearch]. FileSearch interface{} `json:"file_search,required"` // This field can have the runtime type of [FunctionToolCallFunction]. - Function interface{} `json:"function,required"` - JSON toolCallJSON `json:"-"` - union ToolCallUnion + Function interface{} `json:"function,required"` + // The type of tool call. This is always going to be `code_interpreter` for this + // type of tool call. + Type ToolCallType `json:"type,required"` + JSON toolCallJSON `json:"-"` + union ToolCallUnion } // toolCallJSON contains the JSON metadata for the struct [ToolCall] type toolCallJSON struct { ID apijson.Field - Type apijson.Field CodeInterpreter apijson.Field FileSearch apijson.Field Function apijson.Field + Type apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1721,32 +1721,32 @@ func (r ToolCallType) IsKnown() bool { // Details of the Code Interpreter tool call the run step was involved in. type ToolCallDelta struct { - // The index of the tool call in the tool calls array. - Index int64 `json:"index,required"` - // The ID of the tool call. - ID string `json:"id"` - // The type of tool call. This is always going to be `code_interpreter` for this - // type of tool call. - Type ToolCallDeltaType `json:"type,required"` // This field can have the runtime type of // [CodeInterpreterToolCallDeltaCodeInterpreter]. CodeInterpreter interface{} `json:"code_interpreter,required"` // This field can have the runtime type of [interface{}]. FileSearch interface{} `json:"file_search,required"` // This field can have the runtime type of [FunctionToolCallDeltaFunction]. - Function interface{} `json:"function,required"` - JSON toolCallDeltaJSON `json:"-"` - union ToolCallDeltaUnion + Function interface{} `json:"function,required"` + // The index of the tool call in the tool calls array. + Index int64 `json:"index,required"` + // The type of tool call. This is always going to be `code_interpreter` for this + // type of tool call. + Type ToolCallDeltaType `json:"type,required"` + // The ID of the tool call. + ID string `json:"id"` + JSON toolCallDeltaJSON `json:"-"` + union ToolCallDeltaUnion } // toolCallDeltaJSON contains the JSON metadata for the struct [ToolCallDelta] type toolCallDeltaJSON struct { - Index apijson.Field - ID apijson.Field - Type apijson.Field CodeInterpreter apijson.Field FileSearch apijson.Field Function apijson.Field + Index apijson.Field + Type apijson.Field + ID apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/chatcompletion.go b/chatcompletion.go index f696d6df..e503e6db 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -285,10 +285,10 @@ func (r ChatCompletionAssistantMessageParamAudio) MarshalJSON() (data []byte, er type ChatCompletionAssistantMessageParamContent struct { // The type of the content part. Type param.Field[ChatCompletionAssistantMessageParamContentType] `json:"type,required"` - // The text content. - Text param.Field[string] `json:"text"` // The refusal message generated by the model. Refusal param.Field[string] `json:"refusal"` + // The text content. + Text param.Field[string] `json:"text"` } func (r ChatCompletionAssistantMessageParamContent) MarshalJSON() (data []byte, err error) { @@ -765,12 +765,12 @@ func (r ChatCompletionChunkServiceTier) IsKnown() bool { // Learn about // [text inputs](https://platform.openai.com/docs/guides/text-generation). type ChatCompletionContentPartParam struct { + ImageURL param.Field[interface{}] `json:"image_url,required"` + InputAudio param.Field[interface{}] `json:"input_audio,required"` // The type of the content part. Type param.Field[ChatCompletionContentPartType] `json:"type,required"` // The text content. - Text param.Field[string] `json:"text"` - ImageURL param.Field[interface{}] `json:"image_url,required"` - InputAudio param.Field[interface{}] `json:"input_audio,required"` + Text param.Field[string] `json:"text"` } func (r ChatCompletionContentPartParam) MarshalJSON() (data []byte, err error) { @@ -1111,17 +1111,17 @@ func (r chatCompletionMessageFunctionCallJSON) RawJSON() string { } type ChatCompletionMessageParam struct { - Content param.Field[interface{}] `json:"content,required"` + Audio param.Field[interface{}] `json:"audio,required"` + Content param.Field[interface{}] `json:"content,required"` + FunctionCall param.Field[interface{}] `json:"function_call,required"` // The role of the messages author, in this case `system`. - Role param.Field[ChatCompletionMessageParamRole] `json:"role,required"` + Role param.Field[ChatCompletionMessageParamRole] `json:"role,required"` + ToolCalls param.Field[interface{}] `json:"tool_calls,required"` // An optional name for the participant. Provides the model information to // differentiate between participants of the same role. Name param.Field[string] `json:"name"` // The refusal message by the assistant. - Refusal param.Field[string] `json:"refusal"` - Audio param.Field[interface{}] `json:"audio,required"` - ToolCalls param.Field[interface{}] `json:"tool_calls,required"` - FunctionCall param.Field[interface{}] `json:"function_call,required"` + Refusal param.Field[string] `json:"refusal"` // Tool call that this message is responding to. ToolCallID param.Field[string] `json:"tool_call_id"` } @@ -1848,9 +1848,9 @@ func (r ChatCompletionNewParamsFunction) MarshalJSON() (data []byte, err error) // indicates the generation exceeded `max_tokens` or the conversation exceeded the // max context length. type ChatCompletionNewParamsResponseFormat struct { + JSONSchema param.Field[interface{}] `json:"json_schema,required"` // The type of response format being defined: `text` - Type param.Field[ChatCompletionNewParamsResponseFormatType] `json:"type,required"` - JSONSchema param.Field[interface{}] `json:"json_schema,required"` + Type param.Field[ChatCompletionNewParamsResponseFormatType] `json:"type,required"` } func (r ChatCompletionNewParamsResponseFormat) MarshalJSON() (data []byte, err error) { diff --git a/moderation.go b/moderation.go index c7d0905c..56c6e1b5 100644 --- a/moderation.go +++ b/moderation.go @@ -502,9 +502,9 @@ const ( // An object describing an image to classify. type ModerationMultiModalInputParam struct { + ImageURL param.Field[interface{}] `json:"image_url,required"` // Always `image_url`. - Type param.Field[ModerationMultiModalInputType] `json:"type,required"` - ImageURL param.Field[interface{}] `json:"image_url,required"` + Type param.Field[ModerationMultiModalInputType] `json:"type,required"` // A string of text to classify. Text param.Field[string] `json:"text"` }