Skip to content

Commit

Permalink
fix: correct required fields for flattened unions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Nov 11, 2024
1 parent 2af88cb commit 9d6e6f2
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 93 deletions.
26 changes: 13 additions & 13 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ 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 {
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"`
Data interface{} `json:"data,required"`
Event AssistantStreamEventEvent `json:"event,required"`
// Whether to enable input audio transcription.
Enabled bool `json:"enabled"`
JSON assistantStreamEventJSON `json:"-"`
Expand All @@ -348,8 +348,8 @@ type AssistantStreamEvent struct {
// assistantStreamEventJSON contains the JSON metadata for the struct
// [AssistantStreamEvent]
type assistantStreamEventJSON struct {
Event apijson.Field
Data apijson.Field
Event apijson.Field
Enabled apijson.Field
raw string
ExtraFields map[string]apijson.Field
Expand Down Expand Up @@ -1651,19 +1651,19 @@ func (r AssistantStreamEventEvent) IsKnown() bool {
}

type AssistantTool struct {
// This field can have the runtime type of [FileSearchToolFileSearch].
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
Type AssistantToolType `json:"type,required"`
// This field can have the runtime type of [FileSearchToolFileSearch].
FileSearch interface{} `json:"file_search"`
Function shared.FunctionDefinition `json:"function"`
JSON assistantToolJSON `json:"-"`
union AssistantToolUnion
}

// assistantToolJSON contains the JSON metadata for the struct [AssistantTool]
type assistantToolJSON struct {
FileSearch apijson.Field
Type apijson.Field
FileSearch apijson.Field
Function apijson.Field
raw string
ExtraFields map[string]apijson.Field
Expand Down Expand Up @@ -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"`
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
Type param.Field[AssistantToolType] `json:"type,required"`
FileSearch param.Field[interface{}] `json:"file_search"`
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
}

func (r AssistantToolParam) MarshalJSON() (data []byte, err error) {
Expand Down
6 changes: 3 additions & 3 deletions betathread.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,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"`
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"`
FileSearch param.Field[interface{}] `json:"file_search"`
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
}

func (r BetaThreadNewAndRunParamsTool) MarshalJSON() (data []byte, err error) {
Expand Down
42 changes: 21 additions & 21 deletions betathreadmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
EndIndex int64 `json:"end_index,required"`
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
FileCitation interface{} `json:"file_citation,required"`
// This field can have the runtime type of [FilePathAnnotationFilePath].
FilePath interface{} `json:"file_path,required"`
StartIndex int64 `json:"start_index,required"`
EndIndex int64 `json:"end_index,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
Type AnnotationType `json:"type,required"`
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
FileCitation interface{} `json:"file_citation"`
// This field can have the runtime type of [FilePathAnnotationFilePath].
FilePath interface{} `json:"file_path"`
JSON annotationJSON `json:"-"`
union AnnotationUnion
}

// annotationJSON contains the JSON metadata for the struct [Annotation]
type annotationJSON struct {
EndIndex apijson.Field
FileCitation apijson.Field
FilePath apijson.Field
StartIndex apijson.Field
Text apijson.Field
Type apijson.Field
FileCitation apijson.Field
FilePath apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -227,17 +227,17 @@ 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 {
// This field can have the runtime type of
// [FileCitationDeltaAnnotationFileCitation].
FileCitation interface{} `json:"file_citation,required"`
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
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"`
Type AnnotationDeltaType `json:"type,required"`
EndIndex int64 `json:"end_index"`
// This field can have the runtime type of
// [FileCitationDeltaAnnotationFileCitation].
FileCitation interface{} `json:"file_citation"`
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
FilePath interface{} `json:"file_path"`
StartIndex int64 `json:"start_index"`
// The text in the message content that needs to be replaced.
Text string `json:"text"`
JSON annotationDeltaJSON `json:"-"`
Expand All @@ -246,11 +246,11 @@ type AnnotationDelta struct {

// annotationDeltaJSON contains the JSON metadata for the struct [AnnotationDelta]
type annotationDeltaJSON struct {
FileCitation apijson.Field
FilePath apijson.Field
Index apijson.Field
Type apijson.Field
EndIndex apijson.Field
FileCitation apijson.Field
FilePath apijson.Field
StartIndex apijson.Field
Text apijson.Field
raw string
Expand Down
86 changes: 43 additions & 43 deletions betathreadrunstep.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ 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"`
// This field can have the runtime type of
// [CodeInterpreterToolCallCodeInterpreterOutputsImageImage].
Image interface{} `json:"image"`
// The text output from the Code Interpreter tool call.
Logs string `json:"logs"`
JSON codeInterpreterToolCallCodeInterpreterOutputJSON `json:"-"`
Expand All @@ -279,8 +279,8 @@ type CodeInterpreterToolCallCodeInterpreterOutput struct {
// codeInterpreterToolCallCodeInterpreterOutputJSON contains the JSON metadata for
// the struct [CodeInterpreterToolCallCodeInterpreterOutput]
type codeInterpreterToolCallCodeInterpreterOutputJSON struct {
Image apijson.Field
Type apijson.Field
Image apijson.Field
Logs apijson.Field
raw string
ExtraFields map[string]apijson.Field
Expand Down Expand Up @@ -557,12 +557,12 @@ 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"`
// This field can have the runtime type of [CodeInterpreterOutputImageImage].
Image interface{} `json:"image"`
// The text output from the Code Interpreter tool call.
Logs string `json:"logs"`
JSON codeInterpreterToolCallDeltaCodeInterpreterOutputJSON `json:"-"`
Expand All @@ -572,9 +572,9 @@ type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct {
// codeInterpreterToolCallDeltaCodeInterpreterOutputJSON contains the JSON metadata
// for the struct [CodeInterpreterToolCallDeltaCodeInterpreterOutput]
type codeInterpreterToolCallDeltaCodeInterpreterOutputJSON struct {
Image apijson.Field
Index apijson.Field
Type apijson.Field
Image apijson.Field
Logs apijson.Field
raw string
ExtraFields map[string]apijson.Field
Expand Down Expand Up @@ -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"`
MessageCreation interface{} `json:"message_creation"`
// This field can have the runtime type of [[]ToolCall].
ToolCalls interface{} `json:"tool_calls,required"`
// Always `message_creation`.
Type RunStepStepDetailsType `json:"type,required"`
JSON runStepStepDetailsJSON `json:"-"`
union RunStepStepDetailsUnion
ToolCalls interface{} `json:"tool_calls"`
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
}
Expand Down Expand Up @@ -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"`
MessageCreation interface{} `json:"message_creation"`
// This field can have the runtime type of [[]ToolCallDelta].
ToolCalls interface{} `json:"tool_calls,required"`
// Always `message_creation`.
Type RunStepDeltaStepDetailsType `json:"type,required"`
JSON runStepDeltaStepDetailsJSON `json:"-"`
union RunStepDeltaStepDetailsUnion
ToolCalls interface{} `json:"tool_calls"`
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
}
Expand Down Expand Up @@ -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"`
CodeInterpreter interface{} `json:"code_interpreter"`
// This field can have the runtime type of [FileSearchToolCallFileSearch].
FileSearch interface{} `json:"file_search,required"`
FileSearch interface{} `json:"file_search"`
// This field can have the runtime type of [FunctionToolCallFunction].
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
Function interface{} `json:"function"`
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
}
Expand Down Expand Up @@ -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 {
// 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"`
// 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
ID string `json:"id"`
// This field can have the runtime type of
// [CodeInterpreterToolCallDeltaCodeInterpreter].
CodeInterpreter interface{} `json:"code_interpreter"`
// This field can have the runtime type of [interface{}].
FileSearch interface{} `json:"file_search"`
// This field can have the runtime type of [FunctionToolCallDeltaFunction].
Function interface{} `json:"function"`
JSON toolCallDeltaJSON `json:"-"`
union ToolCallDeltaUnion
}

// toolCallDeltaJSON contains the JSON metadata for the struct [ToolCallDelta]
type toolCallDeltaJSON struct {
CodeInterpreter apijson.Field
FileSearch apijson.Field
Function apijson.Field
Index apijson.Field
Type apijson.Field
ID apijson.Field
CodeInterpreter apijson.Field
FileSearch apijson.Field
Function apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down
Loading

0 comments on commit 9d6e6f2

Please sign in to comment.