Skip to content

Commit 9d6e6f2

Browse files
fix: correct required fields for flattened unions (openai#120)
1 parent 2af88cb commit 9d6e6f2

File tree

6 files changed

+93
-93
lines changed

6 files changed

+93
-93
lines changed

betaassistant.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ func (r AssistantDeletedObject) IsKnown() bool {
335335
// [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview)
336336
// to learn how to integrate the Assistants API with streaming.
337337
type AssistantStreamEvent struct {
338-
Event AssistantStreamEventEvent `json:"event,required"`
339338
// This field can have the runtime type of [Thread], [Run], [RunStep],
340339
// [RunStepDeltaEvent], [Message], [MessageDeltaEvent], [shared.ErrorObject].
341-
Data interface{} `json:"data"`
340+
Data interface{} `json:"data,required"`
341+
Event AssistantStreamEventEvent `json:"event,required"`
342342
// Whether to enable input audio transcription.
343343
Enabled bool `json:"enabled"`
344344
JSON assistantStreamEventJSON `json:"-"`
@@ -348,8 +348,8 @@ type AssistantStreamEvent struct {
348348
// assistantStreamEventJSON contains the JSON metadata for the struct
349349
// [AssistantStreamEvent]
350350
type assistantStreamEventJSON struct {
351-
Event apijson.Field
352351
Data apijson.Field
352+
Event apijson.Field
353353
Enabled apijson.Field
354354
raw string
355355
ExtraFields map[string]apijson.Field
@@ -1651,19 +1651,19 @@ func (r AssistantStreamEventEvent) IsKnown() bool {
16511651
}
16521652

16531653
type AssistantTool struct {
1654-
// This field can have the runtime type of [FileSearchToolFileSearch].
1655-
FileSearch interface{} `json:"file_search,required"`
16561654
// The type of tool being defined: `code_interpreter`
1657-
Type AssistantToolType `json:"type,required"`
1658-
Function shared.FunctionDefinition `json:"function"`
1659-
JSON assistantToolJSON `json:"-"`
1660-
union AssistantToolUnion
1655+
Type AssistantToolType `json:"type,required"`
1656+
// This field can have the runtime type of [FileSearchToolFileSearch].
1657+
FileSearch interface{} `json:"file_search"`
1658+
Function shared.FunctionDefinition `json:"function"`
1659+
JSON assistantToolJSON `json:"-"`
1660+
union AssistantToolUnion
16611661
}
16621662

16631663
// assistantToolJSON contains the JSON metadata for the struct [AssistantTool]
16641664
type assistantToolJSON struct {
1665-
FileSearch apijson.Field
16661665
Type apijson.Field
1666+
FileSearch apijson.Field
16671667
Function apijson.Field
16681668
raw string
16691669
ExtraFields map[string]apijson.Field
@@ -1736,10 +1736,10 @@ func (r AssistantToolType) IsKnown() bool {
17361736
}
17371737

17381738
type AssistantToolParam struct {
1739-
FileSearch param.Field[interface{}] `json:"file_search,required"`
17401739
// The type of tool being defined: `code_interpreter`
1741-
Type param.Field[AssistantToolType] `json:"type,required"`
1742-
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
1740+
Type param.Field[AssistantToolType] `json:"type,required"`
1741+
FileSearch param.Field[interface{}] `json:"file_search"`
1742+
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
17431743
}
17441744

17451745
func (r AssistantToolParam) MarshalJSON() (data []byte, err error) {

betathread.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,10 @@ func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data []
10071007
}
10081008

10091009
type BetaThreadNewAndRunParamsTool struct {
1010-
FileSearch param.Field[interface{}] `json:"file_search,required"`
10111010
// The type of tool being defined: `code_interpreter`
1012-
Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"`
1013-
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
1011+
Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"`
1012+
FileSearch param.Field[interface{}] `json:"file_search"`
1013+
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
10141014
}
10151015

10161016
func (r BetaThreadNewAndRunParamsTool) MarshalJSON() (data []byte, err error) {

betathreadmessage.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,28 @@ func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string,
133133
// File associated with the assistant or the message. Generated when the assistant
134134
// uses the "file_search" tool to search files.
135135
type Annotation struct {
136-
EndIndex int64 `json:"end_index,required"`
137-
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
138-
FileCitation interface{} `json:"file_citation,required"`
139-
// This field can have the runtime type of [FilePathAnnotationFilePath].
140-
FilePath interface{} `json:"file_path,required"`
141-
StartIndex int64 `json:"start_index,required"`
136+
EndIndex int64 `json:"end_index,required"`
137+
StartIndex int64 `json:"start_index,required"`
142138
// The text in the message content that needs to be replaced.
143139
Text string `json:"text,required"`
144140
// Always `file_citation`.
145-
Type AnnotationType `json:"type,required"`
146-
JSON annotationJSON `json:"-"`
147-
union AnnotationUnion
141+
Type AnnotationType `json:"type,required"`
142+
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
143+
FileCitation interface{} `json:"file_citation"`
144+
// This field can have the runtime type of [FilePathAnnotationFilePath].
145+
FilePath interface{} `json:"file_path"`
146+
JSON annotationJSON `json:"-"`
147+
union AnnotationUnion
148148
}
149149

150150
// annotationJSON contains the JSON metadata for the struct [Annotation]
151151
type annotationJSON struct {
152152
EndIndex apijson.Field
153-
FileCitation apijson.Field
154-
FilePath apijson.Field
155153
StartIndex apijson.Field
156154
Text apijson.Field
157155
Type apijson.Field
156+
FileCitation apijson.Field
157+
FilePath apijson.Field
158158
raw string
159159
ExtraFields map[string]apijson.Field
160160
}
@@ -227,17 +227,17 @@ func (r AnnotationType) IsKnown() bool {
227227
// File associated with the assistant or the message. Generated when the assistant
228228
// uses the "file_search" tool to search files.
229229
type AnnotationDelta struct {
230-
// This field can have the runtime type of
231-
// [FileCitationDeltaAnnotationFileCitation].
232-
FileCitation interface{} `json:"file_citation,required"`
233-
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
234-
FilePath interface{} `json:"file_path,required"`
235230
// The index of the annotation in the text content part.
236231
Index int64 `json:"index,required"`
237232
// Always `file_citation`.
238-
Type AnnotationDeltaType `json:"type,required"`
239-
EndIndex int64 `json:"end_index"`
240-
StartIndex int64 `json:"start_index"`
233+
Type AnnotationDeltaType `json:"type,required"`
234+
EndIndex int64 `json:"end_index"`
235+
// This field can have the runtime type of
236+
// [FileCitationDeltaAnnotationFileCitation].
237+
FileCitation interface{} `json:"file_citation"`
238+
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
239+
FilePath interface{} `json:"file_path"`
240+
StartIndex int64 `json:"start_index"`
241241
// The text in the message content that needs to be replaced.
242242
Text string `json:"text"`
243243
JSON annotationDeltaJSON `json:"-"`
@@ -246,11 +246,11 @@ type AnnotationDelta struct {
246246

247247
// annotationDeltaJSON contains the JSON metadata for the struct [AnnotationDelta]
248248
type annotationDeltaJSON struct {
249-
FileCitation apijson.Field
250-
FilePath apijson.Field
251249
Index apijson.Field
252250
Type apijson.Field
253251
EndIndex apijson.Field
252+
FileCitation apijson.Field
253+
FilePath apijson.Field
254254
StartIndex apijson.Field
255255
Text apijson.Field
256256
raw string

betathreadrunstep.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ func (r codeInterpreterToolCallCodeInterpreterJSON) RawJSON() string {
265265

266266
// Text output from the Code Interpreter tool call as part of a run step.
267267
type CodeInterpreterToolCallCodeInterpreterOutput struct {
268-
// This field can have the runtime type of
269-
// [CodeInterpreterToolCallCodeInterpreterOutputsImageImage].
270-
Image interface{} `json:"image,required"`
271268
// Always `logs`.
272269
Type CodeInterpreterToolCallCodeInterpreterOutputsType `json:"type,required"`
270+
// This field can have the runtime type of
271+
// [CodeInterpreterToolCallCodeInterpreterOutputsImageImage].
272+
Image interface{} `json:"image"`
273273
// The text output from the Code Interpreter tool call.
274274
Logs string `json:"logs"`
275275
JSON codeInterpreterToolCallCodeInterpreterOutputJSON `json:"-"`
@@ -279,8 +279,8 @@ type CodeInterpreterToolCallCodeInterpreterOutput struct {
279279
// codeInterpreterToolCallCodeInterpreterOutputJSON contains the JSON metadata for
280280
// the struct [CodeInterpreterToolCallCodeInterpreterOutput]
281281
type codeInterpreterToolCallCodeInterpreterOutputJSON struct {
282-
Image apijson.Field
283282
Type apijson.Field
283+
Image apijson.Field
284284
Logs apijson.Field
285285
raw string
286286
ExtraFields map[string]apijson.Field
@@ -557,12 +557,12 @@ func (r codeInterpreterToolCallDeltaCodeInterpreterJSON) RawJSON() string {
557557

558558
// Text output from the Code Interpreter tool call as part of a run step.
559559
type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct {
560-
// This field can have the runtime type of [CodeInterpreterOutputImageImage].
561-
Image interface{} `json:"image,required"`
562560
// The index of the output in the outputs array.
563561
Index int64 `json:"index,required"`
564562
// Always `logs`.
565563
Type CodeInterpreterToolCallDeltaCodeInterpreterOutputsType `json:"type,required"`
564+
// This field can have the runtime type of [CodeInterpreterOutputImageImage].
565+
Image interface{} `json:"image"`
566566
// The text output from the Code Interpreter tool call.
567567
Logs string `json:"logs"`
568568
JSON codeInterpreterToolCallDeltaCodeInterpreterOutputJSON `json:"-"`
@@ -572,9 +572,9 @@ type CodeInterpreterToolCallDeltaCodeInterpreterOutput struct {
572572
// codeInterpreterToolCallDeltaCodeInterpreterOutputJSON contains the JSON metadata
573573
// for the struct [CodeInterpreterToolCallDeltaCodeInterpreterOutput]
574574
type codeInterpreterToolCallDeltaCodeInterpreterOutputJSON struct {
575-
Image apijson.Field
576575
Index apijson.Field
577576
Type apijson.Field
577+
Image apijson.Field
578578
Logs apijson.Field
579579
raw string
580580
ExtraFields map[string]apijson.Field
@@ -1262,23 +1262,23 @@ func (r RunStepStatus) IsKnown() bool {
12621262

12631263
// The details of the run step.
12641264
type RunStepStepDetails struct {
1265+
// Always `message_creation`.
1266+
Type RunStepStepDetailsType `json:"type,required"`
12651267
// This field can have the runtime type of
12661268
// [MessageCreationStepDetailsMessageCreation].
1267-
MessageCreation interface{} `json:"message_creation,required"`
1269+
MessageCreation interface{} `json:"message_creation"`
12681270
// This field can have the runtime type of [[]ToolCall].
1269-
ToolCalls interface{} `json:"tool_calls,required"`
1270-
// Always `message_creation`.
1271-
Type RunStepStepDetailsType `json:"type,required"`
1272-
JSON runStepStepDetailsJSON `json:"-"`
1273-
union RunStepStepDetailsUnion
1271+
ToolCalls interface{} `json:"tool_calls"`
1272+
JSON runStepStepDetailsJSON `json:"-"`
1273+
union RunStepStepDetailsUnion
12741274
}
12751275

12761276
// runStepStepDetailsJSON contains the JSON metadata for the struct
12771277
// [RunStepStepDetails]
12781278
type runStepStepDetailsJSON struct {
1279+
Type apijson.Field
12791280
MessageCreation apijson.Field
12801281
ToolCalls apijson.Field
1281-
Type apijson.Field
12821282
raw string
12831283
ExtraFields map[string]apijson.Field
12841284
}
@@ -1414,23 +1414,23 @@ func (r runStepDeltaJSON) RawJSON() string {
14141414

14151415
// The details of the run step.
14161416
type RunStepDeltaStepDetails struct {
1417+
// Always `message_creation`.
1418+
Type RunStepDeltaStepDetailsType `json:"type,required"`
14171419
// This field can have the runtime type of
14181420
// [RunStepDeltaMessageDeltaMessageCreation].
1419-
MessageCreation interface{} `json:"message_creation,required"`
1421+
MessageCreation interface{} `json:"message_creation"`
14201422
// This field can have the runtime type of [[]ToolCallDelta].
1421-
ToolCalls interface{} `json:"tool_calls,required"`
1422-
// Always `message_creation`.
1423-
Type RunStepDeltaStepDetailsType `json:"type,required"`
1424-
JSON runStepDeltaStepDetailsJSON `json:"-"`
1425-
union RunStepDeltaStepDetailsUnion
1423+
ToolCalls interface{} `json:"tool_calls"`
1424+
JSON runStepDeltaStepDetailsJSON `json:"-"`
1425+
union RunStepDeltaStepDetailsUnion
14261426
}
14271427

14281428
// runStepDeltaStepDetailsJSON contains the JSON metadata for the struct
14291429
// [RunStepDeltaStepDetails]
14301430
type runStepDeltaStepDetailsJSON struct {
1431+
Type apijson.Field
14311432
MessageCreation apijson.Field
14321433
ToolCalls apijson.Field
1433-
Type apijson.Field
14341434
raw string
14351435
ExtraFields map[string]apijson.Field
14361436
}
@@ -1624,27 +1624,27 @@ func (r RunStepInclude) IsKnown() bool {
16241624
type ToolCall struct {
16251625
// The ID of the tool call.
16261626
ID string `json:"id,required"`
1627+
// The type of tool call. This is always going to be `code_interpreter` for this
1628+
// type of tool call.
1629+
Type ToolCallType `json:"type,required"`
16271630
// This field can have the runtime type of
16281631
// [CodeInterpreterToolCallCodeInterpreter].
1629-
CodeInterpreter interface{} `json:"code_interpreter,required"`
1632+
CodeInterpreter interface{} `json:"code_interpreter"`
16301633
// This field can have the runtime type of [FileSearchToolCallFileSearch].
1631-
FileSearch interface{} `json:"file_search,required"`
1634+
FileSearch interface{} `json:"file_search"`
16321635
// This field can have the runtime type of [FunctionToolCallFunction].
1633-
Function interface{} `json:"function,required"`
1634-
// The type of tool call. This is always going to be `code_interpreter` for this
1635-
// type of tool call.
1636-
Type ToolCallType `json:"type,required"`
1637-
JSON toolCallJSON `json:"-"`
1638-
union ToolCallUnion
1636+
Function interface{} `json:"function"`
1637+
JSON toolCallJSON `json:"-"`
1638+
union ToolCallUnion
16391639
}
16401640

16411641
// toolCallJSON contains the JSON metadata for the struct [ToolCall]
16421642
type toolCallJSON struct {
16431643
ID apijson.Field
1644+
Type apijson.Field
16441645
CodeInterpreter apijson.Field
16451646
FileSearch apijson.Field
16461647
Function apijson.Field
1647-
Type apijson.Field
16481648
raw string
16491649
ExtraFields map[string]apijson.Field
16501650
}
@@ -1721,32 +1721,32 @@ func (r ToolCallType) IsKnown() bool {
17211721

17221722
// Details of the Code Interpreter tool call the run step was involved in.
17231723
type ToolCallDelta struct {
1724-
// This field can have the runtime type of
1725-
// [CodeInterpreterToolCallDeltaCodeInterpreter].
1726-
CodeInterpreter interface{} `json:"code_interpreter,required"`
1727-
// This field can have the runtime type of [interface{}].
1728-
FileSearch interface{} `json:"file_search,required"`
1729-
// This field can have the runtime type of [FunctionToolCallDeltaFunction].
1730-
Function interface{} `json:"function,required"`
17311724
// The index of the tool call in the tool calls array.
17321725
Index int64 `json:"index,required"`
17331726
// The type of tool call. This is always going to be `code_interpreter` for this
17341727
// type of tool call.
17351728
Type ToolCallDeltaType `json:"type,required"`
17361729
// The ID of the tool call.
1737-
ID string `json:"id"`
1738-
JSON toolCallDeltaJSON `json:"-"`
1739-
union ToolCallDeltaUnion
1730+
ID string `json:"id"`
1731+
// This field can have the runtime type of
1732+
// [CodeInterpreterToolCallDeltaCodeInterpreter].
1733+
CodeInterpreter interface{} `json:"code_interpreter"`
1734+
// This field can have the runtime type of [interface{}].
1735+
FileSearch interface{} `json:"file_search"`
1736+
// This field can have the runtime type of [FunctionToolCallDeltaFunction].
1737+
Function interface{} `json:"function"`
1738+
JSON toolCallDeltaJSON `json:"-"`
1739+
union ToolCallDeltaUnion
17401740
}
17411741

17421742
// toolCallDeltaJSON contains the JSON metadata for the struct [ToolCallDelta]
17431743
type toolCallDeltaJSON struct {
1744-
CodeInterpreter apijson.Field
1745-
FileSearch apijson.Field
1746-
Function apijson.Field
17471744
Index apijson.Field
17481745
Type apijson.Field
17491746
ID apijson.Field
1747+
CodeInterpreter apijson.Field
1748+
FileSearch apijson.Field
1749+
Function apijson.Field
17501750
raw string
17511751
ExtraFields map[string]apijson.Field
17521752
}

0 commit comments

Comments
 (0)