Skip to content

Commit e927fb0

Browse files
refactor: sort fields for squashed union structs (#111)
1 parent 73c798a commit e927fb0

File tree

6 files changed

+110
-110
lines changed

6 files changed

+110
-110
lines changed

betaassistant.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,22 @@ 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-
// Whether to enable input audio transcription.
339-
Enabled bool `json:"enabled"`
340-
Event AssistantStreamEventEvent `json:"event,required"`
338+
Event AssistantStreamEventEvent `json:"event,required"`
341339
// This field can have the runtime type of [Thread], [Run], [RunStep],
342340
// [RunStepDeltaEvent], [Message], [MessageDeltaEvent], [shared.ErrorObject].
343-
Data interface{} `json:"data"`
344-
JSON assistantStreamEventJSON `json:"-"`
345-
union AssistantStreamEventUnion
341+
Data interface{} `json:"data"`
342+
// Whether to enable input audio transcription.
343+
Enabled bool `json:"enabled"`
344+
JSON assistantStreamEventJSON `json:"-"`
345+
union AssistantStreamEventUnion
346346
}
347347

348348
// assistantStreamEventJSON contains the JSON metadata for the struct
349349
// [AssistantStreamEvent]
350350
type assistantStreamEventJSON struct {
351-
Enabled apijson.Field
352351
Event apijson.Field
353352
Data apijson.Field
353+
Enabled apijson.Field
354354
raw string
355355
ExtraFields map[string]apijson.Field
356356
}
@@ -1651,19 +1651,19 @@ func (r AssistantStreamEventEvent) IsKnown() bool {
16511651
}
16521652

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

16631663
// assistantToolJSON contains the JSON metadata for the struct [AssistantTool]
16641664
type assistantToolJSON struct {
1665-
Type apijson.Field
16661665
FileSearch apijson.Field
1666+
Type 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"`
17391740
// The type of tool being defined: `code_interpreter`
1740-
Type param.Field[AssistantToolType] `json:"type,required"`
1741-
FileSearch param.Field[interface{}] `json:"file_search,required"`
1742-
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
1741+
Type param.Field[AssistantToolType] `json:"type,required"`
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"`
10101011
// The type of tool being defined: `code_interpreter`
1011-
Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"`
1012-
FileSearch param.Field[interface{}] `json:"file_search,required"`
1013-
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
1012+
Type param.Field[BetaThreadNewAndRunParamsToolsType] `json:"type,required"`
1013+
Function param.Field[shared.FunctionDefinitionParam] `json:"function"`
10141014
}
10151015

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

betathreadmessage.go

Lines changed: 34 additions & 34 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-
// Always `file_citation`.
137-
Type AnnotationType `json:"type,required"`
138-
// The text in the message content that needs to be replaced.
139-
Text string `json:"text,required"`
136+
EndIndex int64 `json:"end_index,required"`
140137
// This field can have the runtime type of [FileCitationAnnotationFileCitation].
141138
FileCitation interface{} `json:"file_citation,required"`
142-
StartIndex int64 `json:"start_index,required"`
143-
EndIndex int64 `json:"end_index,required"`
144139
// This field can have the runtime type of [FilePathAnnotationFilePath].
145-
FilePath interface{} `json:"file_path,required"`
146-
JSON annotationJSON `json:"-"`
147-
union AnnotationUnion
140+
FilePath interface{} `json:"file_path,required"`
141+
StartIndex int64 `json:"start_index,required"`
142+
// The text in the message content that needs to be replaced.
143+
Text string `json:"text,required"`
144+
// Always `file_citation`.
145+
Type AnnotationType `json:"type,required"`
146+
JSON annotationJSON `json:"-"`
147+
union AnnotationUnion
148148
}
149149

150150
// annotationJSON contains the JSON metadata for the struct [Annotation]
151151
type annotationJSON struct {
152-
Type apijson.Field
153-
Text apijson.Field
154-
FileCitation apijson.Field
155-
StartIndex apijson.Field
156152
EndIndex apijson.Field
153+
FileCitation apijson.Field
157154
FilePath apijson.Field
155+
StartIndex apijson.Field
156+
Text apijson.Field
157+
Type apijson.Field
158158
raw string
159159
ExtraFields map[string]apijson.Field
160160
}
@@ -227,32 +227,32 @@ 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-
// The index of the annotation in the text content part.
231-
Index int64 `json:"index,required"`
232-
// Always `file_citation`.
233-
Type AnnotationDeltaType `json:"type,required"`
234-
// The text in the message content that needs to be replaced.
235-
Text string `json:"text"`
236230
// This field can have the runtime type of
237231
// [FileCitationDeltaAnnotationFileCitation].
238232
FileCitation interface{} `json:"file_citation,required"`
239-
StartIndex int64 `json:"start_index"`
240-
EndIndex int64 `json:"end_index"`
241233
// This field can have the runtime type of [FilePathDeltaAnnotationFilePath].
242-
FilePath interface{} `json:"file_path,required"`
243-
JSON annotationDeltaJSON `json:"-"`
244-
union AnnotationDeltaUnion
234+
FilePath interface{} `json:"file_path,required"`
235+
// The index of the annotation in the text content part.
236+
Index int64 `json:"index,required"`
237+
// Always `file_citation`.
238+
Type AnnotationDeltaType `json:"type,required"`
239+
EndIndex int64 `json:"end_index"`
240+
StartIndex int64 `json:"start_index"`
241+
// The text in the message content that needs to be replaced.
242+
Text string `json:"text"`
243+
JSON annotationDeltaJSON `json:"-"`
244+
union AnnotationDeltaUnion
245245
}
246246

247247
// annotationDeltaJSON contains the JSON metadata for the struct [AnnotationDelta]
248248
type annotationDeltaJSON struct {
249+
FileCitation apijson.Field
250+
FilePath apijson.Field
249251
Index apijson.Field
250252
Type apijson.Field
251-
Text apijson.Field
252-
FileCitation apijson.Field
253-
StartIndex apijson.Field
254253
EndIndex apijson.Field
255-
FilePath apijson.Field
254+
StartIndex apijson.Field
255+
Text apijson.Field
256256
raw string
257257
ExtraFields map[string]apijson.Field
258258
}
@@ -1336,8 +1336,8 @@ type MessageContent struct {
13361336
Type MessageContentType `json:"type,required"`
13371337
ImageFile ImageFile `json:"image_file"`
13381338
ImageURL ImageURL `json:"image_url"`
1339-
Text Text `json:"text"`
13401339
Refusal string `json:"refusal"`
1340+
Text Text `json:"text"`
13411341
JSON messageContentJSON `json:"-"`
13421342
union MessageContentUnion
13431343
}
@@ -1347,8 +1347,8 @@ type messageContentJSON struct {
13471347
Type apijson.Field
13481348
ImageFile apijson.Field
13491349
ImageURL apijson.Field
1350-
Text apijson.Field
13511350
Refusal apijson.Field
1351+
Text apijson.Field
13521352
raw string
13531353
ExtraFields map[string]apijson.Field
13541354
}
@@ -1437,9 +1437,9 @@ type MessageContentDelta struct {
14371437
// Always `image_file`.
14381438
Type MessageContentDeltaType `json:"type,required"`
14391439
ImageFile ImageFileDelta `json:"image_file"`
1440-
Text TextDelta `json:"text"`
1441-
Refusal string `json:"refusal"`
14421440
ImageURL ImageURLDelta `json:"image_url"`
1441+
Refusal string `json:"refusal"`
1442+
Text TextDelta `json:"text"`
14431443
JSON messageContentDeltaJSON `json:"-"`
14441444
union MessageContentDeltaUnion
14451445
}
@@ -1450,9 +1450,9 @@ type messageContentDeltaJSON struct {
14501450
Index apijson.Field
14511451
Type apijson.Field
14521452
ImageFile apijson.Field
1453-
Text apijson.Field
1454-
Refusal apijson.Field
14551453
ImageURL apijson.Field
1454+
Refusal apijson.Field
1455+
Text apijson.Field
14561456
raw string
14571457
ExtraFields map[string]apijson.Field
14581458
}

0 commit comments

Comments
 (0)