Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO1),
Model: openai.F(openai.ChatModelO3Mini),
})
if err != nil {
panic(err.Error())
Expand Down Expand Up @@ -240,7 +240,7 @@ client.Chat.Completions.New(
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO1),
Model: openai.F(openai.ChatModelO3Mini),
},
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
Expand Down Expand Up @@ -303,7 +303,7 @@ client.Chat.Completions.New(
Role: openai.F(openai.ChatCompletionUserMessageParamRoleUser),
Content: openai.F([]openai.ChatCompletionContentPartUnionParam{openai.ChatCompletionContentPartTextParam{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}),
}}),
Model: openai.F(openai.ChatModelO1),
Model: openai.F(openai.ChatModelO3Mini),
},
option.WithMaxRetries(5),
)
Expand Down
20 changes: 20 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ type FunctionDefinitionParam = shared.FunctionDefinitionParam
// This is an alias to an internal type.
type FunctionParameters = shared.FunctionParameters

// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
//
// This is an alias to an internal type.
type Metadata = shared.Metadata

// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
//
// This is an alias to an internal type.
type MetadataParam = shared.MetadataParam

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

Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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#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#MetadataParam">MetadataParam</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>
Expand All @@ -11,6 +12,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#ErrorObject">ErrorObject</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#FunctionDefinition">FunctionDefinition</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#Metadata">Metadata</a>

# Completions

Expand Down
4 changes: 2 additions & 2 deletions audiotranscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ type AudioTranscriptionNewParams struct {
// Whisper V2 model) is currently available.
Model param.Field[AudioModel] `json:"model,required"`
// The language of the input audio. Supplying the input language in
// [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will
// improve accuracy and latency.
// [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
// format will improve accuracy and latency.
Language param.Field[string] `json:"language"`
// An optional text to guide the model's style or continue a previous audio
// segment. The
Expand Down
20 changes: 14 additions & 6 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/openai/openai-go/internal/requestconfig"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/packages/pagination"
"github.com/openai/openai-go/shared"
)

// BatchService contains methods and other services that help with interacting with
Expand Down Expand Up @@ -127,10 +128,12 @@ type Batch struct {
// The Unix timestamp (in seconds) for when the batch started processing.
InProgressAt int64 `json:"in_progress_at"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format. Keys
// can be a maximum of 64 characters long and values can be a maximum of 512
// characters long.
Metadata interface{} `json:"metadata,nullable"`
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata shared.Metadata `json:"metadata,nullable"`
// The ID of the file containing the outputs of successfully executed requests.
OutputFileID string `json:"output_file_id"`
// The request counts for different statuses within the batch.
Expand Down Expand Up @@ -310,8 +313,13 @@ type BatchNewParams struct {
// and must be uploaded with the purpose `batch`. The file can contain up to 50,000
// requests, and can be up to 200 MB in size.
InputFileID param.Field[string] `json:"input_file_id,required"`
// Optional custom metadata for the batch.
Metadata param.Field[map[string]string] `json:"metadata"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata param.Field[shared.MetadataParam] `json:"metadata"`
}

func (r BatchNewParams) MarshalJSON() (data []byte, err error) {
Expand Down
3 changes: 2 additions & 1 deletion batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/openai/openai-go"
"github.com/openai/openai-go/internal/testutil"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/shared"
)

func TestBatchNewWithOptionalParams(t *testing.T) {
Expand All @@ -29,7 +30,7 @@ func TestBatchNewWithOptionalParams(t *testing.T) {
CompletionWindow: openai.F(openai.BatchNewParamsCompletionWindow24h),
Endpoint: openai.F(openai.BatchNewParamsEndpointV1ChatCompletions),
InputFileID: openai.F("input_file_id"),
Metadata: openai.F(map[string]string{
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
})
Expand Down
42 changes: 25 additions & 17 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ type Assistant struct {
// characters.
Instructions string `json:"instructions,required,nullable"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format. Keys
// can be a maximum of 64 characters long and values can be a maximum of 512
// characters long.
Metadata interface{} `json:"metadata,required,nullable"`
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata shared.Metadata `json:"metadata,required,nullable"`
// ID of the model to use. You can use the
// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
// see all of your available models, or see our
Expand Down Expand Up @@ -2072,10 +2074,12 @@ type BetaAssistantNewParams struct {
// characters.
Instructions param.Field[string] `json:"instructions"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format. Keys
// can be a maximum of 64 characters long and values can be a maximum of 512
// characters long.
Metadata param.Field[interface{}] `json:"metadata"`
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata param.Field[shared.MetadataParam] `json:"metadata"`
// The name of the assistant. The maximum length is 256 characters.
Name param.Field[string] `json:"name"`
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
Expand Down Expand Up @@ -2152,11 +2156,13 @@ type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct {
// add to the vector store. There can be a maximum of 10000 files in a vector
// store.
FileIDs param.Field[[]string] `json:"file_ids"`
// Set of 16 key-value pairs that can be attached to a vector store. This can be
// useful for storing additional information about the vector store in a structured
// format. Keys can be a maximum of 64 characters long and values can be a maximum
// of 512 characters long.
Metadata param.Field[interface{}] `json:"metadata"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata param.Field[shared.MetadataParam] `json:"metadata"`
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) {
Expand All @@ -2170,10 +2176,12 @@ type BetaAssistantUpdateParams struct {
// characters.
Instructions param.Field[string] `json:"instructions"`
// Set of 16 key-value pairs that can be attached to an object. This can be useful
// for storing additional information about the object in a structured format. Keys
// can be a maximum of 64 characters long and values can be a maximum of 512
// characters long.
Metadata param.Field[interface{}] `json:"metadata"`
// for storing additional information about the object in a structured format, and
// querying for objects via API or the dashboard.
//
// Keys are strings with a maximum length of 64 characters. Values are strings with
// a maximum length of 512 characters.
Metadata param.Field[shared.MetadataParam] `json:"metadata"`
// ID of the model to use. You can use the
// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
// see all of your available models, or see our
Expand Down
27 changes: 17 additions & 10 deletions betaassistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/openai/openai-go"
"github.com/openai/openai-go/internal/testutil"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/shared"
)

func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
Expand All @@ -26,12 +27,14 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
option.WithAPIKey("My API Key"),
)
_, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{
Model: openai.F(openai.ChatModelO1),
Model: openai.F(openai.ChatModelO3Mini),
Description: openai.F("description"),
Instructions: openai.F("instructions"),
Metadata: openai.F[any](map[string]interface{}{}),
Name: openai.F("name"),
Temperature: openai.F(1.000000),
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
Name: openai.F("name"),
Temperature: openai.F(1.000000),
ToolResources: openai.F(openai.BetaAssistantNewParamsToolResources{
CodeInterpreter: openai.F(openai.BetaAssistantNewParamsToolResourcesCodeInterpreter{
FileIDs: openai.F([]string{"string"}),
Expand All @@ -42,8 +45,10 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
ChunkingStrategy: openai.F[openai.FileChunkingStrategyParamUnion](openai.AutoFileChunkingStrategyParam{
Type: openai.F(openai.AutoFileChunkingStrategyParamTypeAuto),
}),
FileIDs: openai.F([]string{"string"}),
Metadata: openai.F[any](map[string]interface{}{}),
FileIDs: openai.F([]string{"string"}),
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
}}),
}),
}),
Expand Down Expand Up @@ -101,10 +106,12 @@ func TestBetaAssistantUpdateWithOptionalParams(t *testing.T) {
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"),
Temperature: openai.F(1.000000),
Metadata: openai.F(shared.MetadataParam{
"foo": "string",
}),
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"}),
Expand Down
Loading