Skip to content

Commit f92a25c

Browse files
feat(api): updates (#5)
- This commit removes the `AssistantResponseFormat` type
1 parent a559359 commit f92a25c

24 files changed

+508
-319
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b04761ffd2adad3cc19a6dc6fc696ac445878219972f891881a967340fa9a6b0.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-4097c2f86beb3f3bb021775cd1dfa240e960caf842aeefc2e08da4dc0851ea79.yml

aliases.go

+36
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,39 @@ type FunctionDefinitionParam = shared.FunctionDefinitionParam
2828
//
2929
// This is an alias to an internal type.
3030
type FunctionParameters = shared.FunctionParameters
31+
32+
// This is an alias to an internal type.
33+
type ResponseFormatJSONObjectParam = shared.ResponseFormatJSONObjectParam
34+
35+
// The type of response format being defined: `json_object`
36+
//
37+
// This is an alias to an internal type.
38+
type ResponseFormatJSONObjectType = shared.ResponseFormatJSONObjectType
39+
40+
// This is an alias to an internal value.
41+
const ResponseFormatJSONObjectTypeJSONObject = shared.ResponseFormatJSONObjectTypeJSONObject
42+
43+
// This is an alias to an internal type.
44+
type ResponseFormatJSONSchemaParam = shared.ResponseFormatJSONSchemaParam
45+
46+
// This is an alias to an internal type.
47+
type ResponseFormatJSONSchemaJSONSchemaParam = shared.ResponseFormatJSONSchemaJSONSchemaParam
48+
49+
// The type of response format being defined: `json_schema`
50+
//
51+
// This is an alias to an internal type.
52+
type ResponseFormatJSONSchemaType = shared.ResponseFormatJSONSchemaType
53+
54+
// This is an alias to an internal value.
55+
const ResponseFormatJSONSchemaTypeJSONSchema = shared.ResponseFormatJSONSchemaTypeJSONSchema
56+
57+
// This is an alias to an internal type.
58+
type ResponseFormatTextParam = shared.ResponseFormatTextParam
59+
60+
// The type of response format being defined: `text`
61+
//
62+
// This is an alias to an internal type.
63+
type ResponseFormatTextType = shared.ResponseFormatTextType
64+
65+
// This is an alias to an internal value.
66+
const ResponseFormatTextTypeText = shared.ResponseFormatTextTypeText

api.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionDefinitionParam">FunctionDefinitionParam</a>
44
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionParameters">FunctionParameters</a>
5+
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ResponseFormatJSONObjectParam">ResponseFormatJSONObjectParam</a>
6+
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ResponseFormatJSONSchemaParam">ResponseFormatJSONSchemaParam</a>
7+
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ResponseFormatTextParam">ResponseFormatTextParam</a>
58

69
# Shared Response Types
710

@@ -34,6 +37,7 @@ Params Types:
3437
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionAssistantMessageParam">ChatCompletionAssistantMessageParam</a>
3538
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionContentPartUnionParam">ChatCompletionContentPartUnionParam</a>
3639
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionContentPartImageParam">ChatCompletionContentPartImageParam</a>
40+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionContentPartRefusalParam">ChatCompletionContentPartRefusalParam</a>
3741
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionContentPartTextParam">ChatCompletionContentPartTextParam</a>
3842
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionFunctionCallOptionParam">ChatCompletionFunctionCallOptionParam</a>
3943
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ChatCompletionFunctionMessageParam">ChatCompletionFunctionMessageParam</a>
@@ -270,16 +274,12 @@ Methods:
270274

271275
Params Types:
272276

273-
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantResponseFormatParam">AssistantResponseFormatParam</a>
274-
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantResponseFormatOptionUnionParam">AssistantResponseFormatOptionUnionParam</a>
275277
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceParam">AssistantToolChoiceParam</a>
276278
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceFunctionParam">AssistantToolChoiceFunctionParam</a>
277279
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceOptionUnionParam">AssistantToolChoiceOptionUnionParam</a>
278280

279281
Response Types:
280282

281-
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantResponseFormat">AssistantResponseFormat</a>
282-
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantResponseFormatOptionUnion">AssistantResponseFormatOptionUnion</a>
283283
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoice">AssistantToolChoice</a>
284284
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceFunction">AssistantToolChoiceFunction</a>
285285
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceOptionUnion">AssistantToolChoiceOptionUnion</a>
@@ -371,6 +371,8 @@ Response Types:
371371
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#MessageDeleted">MessageDeleted</a>
372372
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#MessageDelta">MessageDelta</a>
373373
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#MessageDeltaEvent">MessageDeltaEvent</a>
374+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RefusalContentBlock">RefusalContentBlock</a>
375+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RefusalDeltaBlock">RefusalDeltaBlock</a>
374376
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Text">Text</a>
375377
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#TextContentBlock">TextContentBlock</a>
376378
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#TextDelta">TextDelta</a>

batch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ type BatchListParams struct {
368368
// URLQuery serializes [BatchListParams]'s query parameters as `url.Values`.
369369
func (r BatchListParams) URLQuery() (v url.Values) {
370370
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
371-
ArrayFormat: apiquery.ArrayQueryFormatComma,
371+
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
372372
NestedFormat: apiquery.NestedQueryFormatBrackets,
373373
})
374374
}

betaassistant.go

+19-68
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,6 @@ type Assistant struct {
136136
// assistant. Tools can be of types `code_interpreter`, `file_search`, or
137137
// `function`.
138138
Tools []AssistantTool `json:"tools,required"`
139-
// Specifies the format that the model must output. Compatible with
140-
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
141-
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
142-
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
143-
//
144-
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
145-
// message the model generates is valid JSON.
146-
//
147-
// **Important:** when using JSON mode, you **must** also instruct the model to
148-
// produce JSON yourself via a system or user message. Without this, the model may
149-
// generate an unending stream of whitespace until the generation reaches the token
150-
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
151-
// the message content may be partially cut off if `finish_reason="length"`, which
152-
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
153-
// max context length.
154-
ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,nullable"`
155139
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
156140
// make the output more random, while lower values like 0.2 will make it more
157141
// focused and deterministic.
@@ -172,21 +156,20 @@ type Assistant struct {
172156

173157
// assistantJSON contains the JSON metadata for the struct [Assistant]
174158
type assistantJSON struct {
175-
ID apijson.Field
176-
CreatedAt apijson.Field
177-
Description apijson.Field
178-
Instructions apijson.Field
179-
Metadata apijson.Field
180-
Model apijson.Field
181-
Name apijson.Field
182-
Object apijson.Field
183-
Tools apijson.Field
184-
ResponseFormat apijson.Field
185-
Temperature apijson.Field
186-
ToolResources apijson.Field
187-
TopP apijson.Field
188-
raw string
189-
ExtraFields map[string]apijson.Field
159+
ID apijson.Field
160+
CreatedAt apijson.Field
161+
Description apijson.Field
162+
Instructions apijson.Field
163+
Metadata apijson.Field
164+
Model apijson.Field
165+
Name apijson.Field
166+
Object apijson.Field
167+
Tools apijson.Field
168+
Temperature apijson.Field
169+
ToolResources apijson.Field
170+
TopP apijson.Field
171+
raw string
172+
ExtraFields map[string]apijson.Field
190173
}
191174

192175
func (r *Assistant) UnmarshalJSON(data []byte) (err error) {
@@ -1869,8 +1852,8 @@ func (r FileSearchToolType) IsKnown() bool {
18691852
// Overrides for the file search tool.
18701853
type FileSearchToolFileSearch struct {
18711854
// The maximum number of results the file search tool should output. The default is
1872-
// 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
1873-
// and 50 inclusive.
1855+
// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1856+
// 1 and 50 inclusive.
18741857
//
18751858
// Note that the file search tool may output fewer than `max_num_results` results.
18761859
// See the
@@ -1914,8 +1897,8 @@ func (r FileSearchToolParam) implementsBetaThreadNewAndRunParamsToolUnion() {}
19141897
// Overrides for the file search tool.
19151898
type FileSearchToolFileSearchParam struct {
19161899
// The maximum number of results the file search tool should output. The default is
1917-
// 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
1918-
// and 50 inclusive.
1900+
// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1901+
// 1 and 50 inclusive.
19191902
//
19201903
// Note that the file search tool may output fewer than `max_num_results` results.
19211904
// See the
@@ -2001,22 +1984,6 @@ type BetaAssistantNewParams struct {
20011984
Metadata param.Field[interface{}] `json:"metadata"`
20021985
// The name of the assistant. The maximum length is 256 characters.
20031986
Name param.Field[string] `json:"name"`
2004-
// Specifies the format that the model must output. Compatible with
2005-
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
2006-
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
2007-
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
2008-
//
2009-
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
2010-
// message the model generates is valid JSON.
2011-
//
2012-
// **Important:** when using JSON mode, you **must** also instruct the model to
2013-
// produce JSON yourself via a system or user message. Without this, the model may
2014-
// generate an unending stream of whitespace until the generation reaches the token
2015-
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
2016-
// the message content may be partially cut off if `finish_reason="length"`, which
2017-
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
2018-
// max context length.
2019-
ResponseFormat param.Field[AssistantResponseFormatOptionUnionParam] `json:"response_format"`
20201987
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
20211988
// make the output more random, while lower values like 0.2 will make it more
20221989
// focused and deterministic.
@@ -2234,22 +2201,6 @@ type BetaAssistantUpdateParams struct {
22342201
Model param.Field[string] `json:"model"`
22352202
// The name of the assistant. The maximum length is 256 characters.
22362203
Name param.Field[string] `json:"name"`
2237-
// Specifies the format that the model must output. Compatible with
2238-
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
2239-
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
2240-
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
2241-
//
2242-
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
2243-
// message the model generates is valid JSON.
2244-
//
2245-
// **Important:** when using JSON mode, you **must** also instruct the model to
2246-
// produce JSON yourself via a system or user message. Without this, the model may
2247-
// generate an unending stream of whitespace until the generation reaches the token
2248-
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
2249-
// the message content may be partially cut off if `finish_reason="length"`, which
2250-
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
2251-
// max context length.
2252-
ResponseFormat param.Field[AssistantResponseFormatOptionUnionParam] `json:"response_format"`
22532204
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
22542205
// make the output more random, while lower values like 0.2 will make it more
22552206
// focused and deterministic.
@@ -2335,7 +2286,7 @@ type BetaAssistantListParams struct {
23352286
// `url.Values`.
23362287
func (r BetaAssistantListParams) URLQuery() (v url.Values) {
23372288
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2338-
ArrayFormat: apiquery.ArrayQueryFormatComma,
2289+
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
23392290
NestedFormat: apiquery.NestedQueryFormatBrackets,
23402291
})
23412292
}

betaassistant_test.go

+12-14
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
2626
option.WithAPIKey("My API Key"),
2727
)
2828
_, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{
29-
Model: openai.F(openai.ChatModelGPT4o),
30-
Description: openai.F("description"),
31-
Instructions: openai.F("instructions"),
32-
Metadata: openai.F[any](map[string]interface{}{}),
33-
Name: openai.F("name"),
34-
ResponseFormat: openai.F[openai.AssistantResponseFormatOptionUnionParam](openai.AssistantResponseFormatOptionString(openai.AssistantResponseFormatOptionStringNone)),
35-
Temperature: openai.F(1.000000),
29+
Model: openai.F(openai.ChatModelGPT4o),
30+
Description: openai.F("description"),
31+
Instructions: openai.F("instructions"),
32+
Metadata: openai.F[any](map[string]interface{}{}),
33+
Name: openai.F("name"),
34+
Temperature: openai.F(1.000000),
3635
ToolResources: openai.F(openai.BetaAssistantNewParamsToolResources{
3736
CodeInterpreter: openai.F(openai.BetaAssistantNewParamsToolResourcesCodeInterpreter{
3837
FileIDs: openai.F([]string{"string", "string", "string"}),
@@ -104,13 +103,12 @@ func TestBetaAssistantUpdateWithOptionalParams(t *testing.T) {
104103
context.TODO(),
105104
"assistant_id",
106105
openai.BetaAssistantUpdateParams{
107-
Description: openai.F("description"),
108-
Instructions: openai.F("instructions"),
109-
Metadata: openai.F[any](map[string]interface{}{}),
110-
Model: openai.F("model"),
111-
Name: openai.F("name"),
112-
ResponseFormat: openai.F[openai.AssistantResponseFormatOptionUnionParam](openai.AssistantResponseFormatOptionString(openai.AssistantResponseFormatOptionStringNone)),
113-
Temperature: openai.F(1.000000),
106+
Description: openai.F("description"),
107+
Instructions: openai.F("instructions"),
108+
Metadata: openai.F[any](map[string]interface{}{}),
109+
Model: openai.F("model"),
110+
Name: openai.F("name"),
111+
Temperature: openai.F(1.000000),
114112
ToolResources: openai.F(openai.BetaAssistantUpdateParamsToolResources{
115113
CodeInterpreter: openai.F(openai.BetaAssistantUpdateParamsToolResourcesCodeInterpreter{
116114
FileIDs: openai.F([]string{"string", "string", "string"}),

0 commit comments

Comments
 (0)