Skip to content

Commit

Permalink
feat(api): updates (#5)
Browse files Browse the repository at this point in the history
- This commit removes the `AssistantResponseFormat` type
  • Loading branch information
stainless-app[bot] authored Aug 6, 2024
1 parent 5f9f87b commit c126ef9
Show file tree
Hide file tree
Showing 24 changed files with 508 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b04761ffd2adad3cc19a6dc6fc696ac445878219972f891881a967340fa9a6b0.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-4097c2f86beb3f3bb021775cd1dfa240e960caf842aeefc2e08da4dc0851ea79.yml
36 changes: 36 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,39 @@ type FunctionDefinitionParam = shared.FunctionDefinitionParam
//
// This is an alias to an internal type.
type FunctionParameters = shared.FunctionParameters

// This is an alias to an internal type.
type ResponseFormatJSONObjectParam = shared.ResponseFormatJSONObjectParam

// The type of response format being defined: `json_object`
//
// This is an alias to an internal type.
type ResponseFormatJSONObjectType = shared.ResponseFormatJSONObjectType

// This is an alias to an internal value.
const ResponseFormatJSONObjectTypeJSONObject = shared.ResponseFormatJSONObjectTypeJSONObject

// This is an alias to an internal type.
type ResponseFormatJSONSchemaParam = shared.ResponseFormatJSONSchemaParam

// This is an alias to an internal type.
type ResponseFormatJSONSchemaJSONSchemaParam = shared.ResponseFormatJSONSchemaJSONSchemaParam

// The type of response format being defined: `json_schema`
//
// This is an alias to an internal type.
type ResponseFormatJSONSchemaType = shared.ResponseFormatJSONSchemaType

// This is an alias to an internal value.
const ResponseFormatJSONSchemaTypeJSONSchema = shared.ResponseFormatJSONSchemaTypeJSONSchema

// This is an alias to an internal type.
type ResponseFormatTextParam = shared.ResponseFormatTextParam

// The type of response format being defined: `text`
//
// This is an alias to an internal type.
type ResponseFormatTextType = shared.ResponseFormatTextType

// This is an alias to an internal value.
const ResponseFormatTextTypeText = shared.ResponseFormatTextTypeText
10 changes: 6 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

- <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>
- <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>
- <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>
- <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>
- <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>

# Shared Response Types

Expand Down Expand Up @@ -34,6 +37,7 @@ Params Types:
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
Expand Down Expand Up @@ -270,16 +274,12 @@ Methods:

Params Types:

- <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>
- <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>
- <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>
- <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>
- <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>

Response Types:

- <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>
- <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>
- <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>
- <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>
- <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>
Expand Down Expand Up @@ -371,6 +371,8 @@ Response Types:
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
Expand Down
2 changes: 1 addition & 1 deletion batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ type BatchListParams struct {
// URLQuery serializes [BatchListParams]'s query parameters as `url.Values`.
func (r BatchListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
87 changes: 19 additions & 68 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,6 @@ type Assistant struct {
// assistant. Tools can be of types `code_interpreter`, `file_search`, or
// `function`.
Tools []AssistantTool `json:"tools,required"`
// Specifies the format that the model must output. Compatible with
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
//
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
// message the model generates is valid JSON.
//
// **Important:** when using JSON mode, you **must** also instruct the model to
// produce JSON yourself via a system or user message. Without this, the model may
// generate an unending stream of whitespace until the generation reaches the token
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
// the message content may be partially cut off if `finish_reason="length"`, which
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
// max context length.
ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,nullable"`
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
// make the output more random, while lower values like 0.2 will make it more
// focused and deterministic.
Expand All @@ -172,21 +156,20 @@ type Assistant struct {

// assistantJSON contains the JSON metadata for the struct [Assistant]
type assistantJSON struct {
ID apijson.Field
CreatedAt apijson.Field
Description apijson.Field
Instructions apijson.Field
Metadata apijson.Field
Model apijson.Field
Name apijson.Field
Object apijson.Field
Tools apijson.Field
ResponseFormat apijson.Field
Temperature apijson.Field
ToolResources apijson.Field
TopP apijson.Field
raw string
ExtraFields map[string]apijson.Field
ID apijson.Field
CreatedAt apijson.Field
Description apijson.Field
Instructions apijson.Field
Metadata apijson.Field
Model apijson.Field
Name apijson.Field
Object apijson.Field
Tools apijson.Field
Temperature apijson.Field
ToolResources apijson.Field
TopP apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *Assistant) UnmarshalJSON(data []byte) (err error) {
Expand Down Expand Up @@ -1869,8 +1852,8 @@ func (r FileSearchToolType) IsKnown() bool {
// Overrides for the file search tool.
type FileSearchToolFileSearch struct {
// The maximum number of results the file search tool should output. The default is
// 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
// and 50 inclusive.
// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
// 1 and 50 inclusive.
//
// Note that the file search tool may output fewer than `max_num_results` results.
// See the
Expand Down Expand Up @@ -1914,8 +1897,8 @@ func (r FileSearchToolParam) implementsBetaThreadNewAndRunParamsToolUnion() {}
// Overrides for the file search tool.
type FileSearchToolFileSearchParam struct {
// The maximum number of results the file search tool should output. The default is
// 20 for gpt-4\* models and 5 for gpt-3.5-turbo. This number should be between 1
// and 50 inclusive.
// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
// 1 and 50 inclusive.
//
// Note that the file search tool may output fewer than `max_num_results` results.
// See the
Expand Down Expand Up @@ -2001,22 +1984,6 @@ type BetaAssistantNewParams struct {
Metadata param.Field[interface{}] `json:"metadata"`
// The name of the assistant. The maximum length is 256 characters.
Name param.Field[string] `json:"name"`
// Specifies the format that the model must output. Compatible with
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
//
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
// message the model generates is valid JSON.
//
// **Important:** when using JSON mode, you **must** also instruct the model to
// produce JSON yourself via a system or user message. Without this, the model may
// generate an unending stream of whitespace until the generation reaches the token
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
// the message content may be partially cut off if `finish_reason="length"`, which
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
// max context length.
ResponseFormat param.Field[AssistantResponseFormatOptionUnionParam] `json:"response_format"`
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
// make the output more random, while lower values like 0.2 will make it more
// focused and deterministic.
Expand Down Expand Up @@ -2234,22 +2201,6 @@ type BetaAssistantUpdateParams struct {
Model param.Field[string] `json:"model"`
// The name of the assistant. The maximum length is 256 characters.
Name param.Field[string] `json:"name"`
// Specifies the format that the model must output. Compatible with
// [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
// [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
//
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
// message the model generates is valid JSON.
//
// **Important:** when using JSON mode, you **must** also instruct the model to
// produce JSON yourself via a system or user message. Without this, the model may
// generate an unending stream of whitespace until the generation reaches the token
// limit, resulting in a long-running and seemingly "stuck" request. Also note that
// the message content may be partially cut off if `finish_reason="length"`, which
// indicates the generation exceeded `max_tokens` or the conversation exceeded the
// max context length.
ResponseFormat param.Field[AssistantResponseFormatOptionUnionParam] `json:"response_format"`
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
// make the output more random, while lower values like 0.2 will make it more
// focused and deterministic.
Expand Down Expand Up @@ -2335,7 +2286,7 @@ type BetaAssistantListParams struct {
// `url.Values`.
func (r BetaAssistantListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
Expand Down
26 changes: 12 additions & 14 deletions betaassistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
option.WithAPIKey("My API Key"),
)
_, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{
Model: openai.F(openai.ChatModelGPT4o),
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F[any](map[string]interface{}{}),
Name: openai.F("name"),
ResponseFormat: openai.F[openai.AssistantResponseFormatOptionUnionParam](openai.AssistantResponseFormatOptionString(openai.AssistantResponseFormatOptionStringNone)),
Temperature: openai.F(1.000000),
Model: openai.F(openai.ChatModelGPT4o),
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F[any](map[string]interface{}{}),
Name: openai.F("name"),
Temperature: openai.F(1.000000),
ToolResources: openai.F(openai.BetaAssistantNewParamsToolResources{
CodeInterpreter: openai.F(openai.BetaAssistantNewParamsToolResourcesCodeInterpreter{
FileIDs: openai.F([]string{"string", "string", "string"}),
Expand Down Expand Up @@ -104,13 +103,12 @@ func TestBetaAssistantUpdateWithOptionalParams(t *testing.T) {
context.TODO(),
"assistant_id",
openai.BetaAssistantUpdateParams{
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F[any](map[string]interface{}{}),
Model: openai.F("model"),
Name: openai.F("name"),
ResponseFormat: openai.F[openai.AssistantResponseFormatOptionUnionParam](openai.AssistantResponseFormatOptionString(openai.AssistantResponseFormatOptionStringNone)),
Temperature: openai.F(1.000000),
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F[any](map[string]interface{}{}),
Model: openai.F("model"),
Name: openai.F("name"),
Temperature: openai.F(1.000000),
ToolResources: openai.F(openai.BetaAssistantUpdateParamsToolResources{
CodeInterpreter: openai.F(openai.BetaAssistantUpdateParamsToolResourcesCodeInterpreter{
FileIDs: openai.F([]string{"string", "string", "string"}),
Expand Down
Loading

0 comments on commit c126ef9

Please sign in to comment.