From d9ddeb16ba571767cb3998c4ccef513b742785fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:28:32 +0000 Subject: [PATCH 1/4] test: use o1 in examples (#190) --- betaassistant_test.go | 2 +- betathread_test.go | 2 +- betathreadrun_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/betaassistant_test.go b/betaassistant_test.go index 320efd0..8885f27 100644 --- a/betaassistant_test.go +++ b/betaassistant_test.go @@ -26,7 +26,7 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) { option.WithAPIKey("My API Key"), ) _, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{ - Model: openai.F(openai.ChatModelGPT4o), + Model: openai.F(openai.ChatModelO1), Description: openai.F("description"), Instructions: openai.F("instructions"), Metadata: openai.F[any](map[string]interface{}{}), diff --git a/betathread_test.go b/betathread_test.go index b4d386f..a9a3ef8 100644 --- a/betathread_test.go +++ b/betathread_test.go @@ -161,7 +161,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) { MaxCompletionTokens: openai.F(int64(256)), MaxPromptTokens: openai.F(int64(256)), Metadata: openai.F[any](map[string]interface{}{}), - Model: openai.F(openai.ChatModelGPT4o), + Model: openai.F(openai.ChatModelO1), ParallelToolCalls: openai.F(true), Temperature: openai.F(1.000000), Thread: openai.F(openai.BetaThreadNewAndRunParamsThread{ diff --git a/betathreadrun_test.go b/betathreadrun_test.go index 13feaac..7967ddf 100644 --- a/betathreadrun_test.go +++ b/betathreadrun_test.go @@ -47,7 +47,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) { MaxCompletionTokens: openai.F(int64(256)), MaxPromptTokens: openai.F(int64(256)), Metadata: openai.F[any](map[string]interface{}{}), - Model: openai.F(openai.ChatModelGPT4o), + Model: openai.F(openai.ChatModelO1), ParallelToolCalls: openai.F(true), Temperature: openai.F(1.000000), ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionAuto(openai.AssistantToolChoiceOptionAutoNone)), From 3bd3c60561b1213dc4a5fe8b27c30ddef8234726 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 08:48:52 +0000 Subject: [PATCH 2/4] fix: fix unicode encoding for json (#193) --- internal/apijson/encoder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go index decc24a..71b3f4e 100644 --- a/internal/apijson/encoder.go +++ b/internal/apijson/encoder.go @@ -143,7 +143,7 @@ func (e *encoder) newPrimitiveTypeEncoder(t reflect.Type) encoderFunc { // code more and this current code shouldn't cause any issues case reflect.String: return func(v reflect.Value) ([]byte, error) { - return []byte(fmt.Sprintf("%q", v.String())), nil + return json.Marshal(v.Interface()) } case reflect.Bool: return func(v reflect.Value) ([]byte, error) { From c5689d01773a7ac0c10e95c1c8badadde251924e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 19:11:00 +0000 Subject: [PATCH 3/4] feat(api): add o3-mini (#195) fix(types): correct metadata type + other fixes --- .stats.yml | 2 +- aliases.go | 20 ++++++++ api.md | 2 + audiotranscription.go | 4 +- batch.go | 20 +++++--- batch_test.go | 3 +- betaassistant.go | 42 +++++++++------- betaassistant_test.go | 27 ++++++---- betathread.go | 100 +++++++++++++++++++++++--------------- betathread_test.go | 43 +++++++++++----- betathreadmessage.go | 31 +++++++----- betathreadmessage_test.go | 9 +++- betathreadrun.go | 41 ++++++++++------ betathreadrun_test.go | 21 +++++--- betathreadrunstep.go | 11 +++-- betavectorstore.go | 31 +++++++----- betavectorstore_test.go | 15 ++++-- chat.go | 2 + chatcompletion.go | 18 ++++--- chatcompletion_test.go | 4 +- client_test.go | 16 +++--- shared/shared.go | 4 ++ upload.go | 2 +- usage_test.go | 2 +- 24 files changed, 303 insertions(+), 167 deletions(-) diff --git a/.stats.yml b/.stats.yml index 36f4b58..9a2cd3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/aliases.go b/aliases.go index 26737f4..eae9b38 100644 --- a/aliases.go +++ b/aliases.go @@ -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 diff --git a/api.md b/api.md index 7fd6c67..18eae07 100644 --- a/api.md +++ b/api.md @@ -2,6 +2,7 @@ - shared.FunctionDefinitionParam - shared.FunctionParameters +- shared.MetadataParam - shared.ResponseFormatJSONObjectParam - shared.ResponseFormatJSONSchemaParam - shared.ResponseFormatTextParam @@ -11,6 +12,7 @@ - shared.ErrorObject - shared.FunctionDefinition - shared.FunctionParameters +- shared.Metadata # Completions diff --git a/audiotranscription.go b/audiotranscription.go index 483b0d1..15f5bd6 100644 --- a/audiotranscription.go +++ b/audiotranscription.go @@ -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 diff --git a/batch.go b/batch.go index 7becfa8..1930340 100644 --- a/batch.go +++ b/batch.go @@ -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 @@ -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. @@ -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) { diff --git a/batch_test.go b/batch_test.go index 86272d5..6b8ecd4 100644 --- a/batch_test.go +++ b/batch_test.go @@ -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) { @@ -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", }), }) diff --git a/betaassistant.go b/betaassistant.go index 4b2aee7..34373bc 100644 --- a/betaassistant.go +++ b/betaassistant.go @@ -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 @@ -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 @@ -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) { @@ -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 diff --git a/betaassistant_test.go b/betaassistant_test.go index 8885f27..9600fdf 100644 --- a/betaassistant_test.go +++ b/betaassistant_test.go @@ -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) { @@ -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"}), @@ -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", + }), }}), }), }), @@ -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"}), diff --git a/betathread.go b/betathread.go index 07c0091..7bfe354 100644 --- a/betathread.go +++ b/betathread.go @@ -283,10 +283,12 @@ type Thread struct { // The Unix timestamp (in seconds) for when the thread was created. CreatedAt int64 `json:"created_at,required"` // 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"` // The object type, which is always `thread`. Object ThreadObject `json:"object,required"` // A set of resources that are made available to the assistant's tools in this @@ -450,10 +452,12 @@ type BetaThreadNewParams struct { // start the thread with. Messages param.Field[[]BetaThreadNewParamsMessage] `json:"messages"` // 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"` // A set of resources that are made available to the assistant's tools in this // thread. The resources are specific to the type of tool. For example, the // `code_interpreter` tool requires a list of file IDs, while the `file_search` @@ -481,10 +485,12 @@ type BetaThreadNewParamsMessage struct { // A list of files attached to the message, and the tools they should be added to. Attachments param.Field[[]BetaThreadNewParamsMessagesAttachment] `json:"attachments"` // 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"` } func (r BetaThreadNewParamsMessage) MarshalJSON() (data []byte, err error) { @@ -634,11 +640,13 @@ type BetaThreadNewParamsToolResourcesFileSearchVectorStore 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 BetaThreadNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) { @@ -647,10 +655,12 @@ func (r BetaThreadNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (da type BetaThreadUpdateParams struct { // 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"` // A set of resources that are made available to the assistant's tools in this // thread. The resources are specific to the type of tool. For example, the // `code_interpreter` tool requires a list of file IDs, while the `file_search` @@ -719,10 +729,12 @@ type BetaThreadNewAndRunParams struct { // `incomplete_details` for more info. MaxPromptTokens param.Field[int64] `json:"max_prompt_tokens"` // 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 ID of the [Model](https://platform.openai.com/docs/api-reference/models) to // be used to execute this run. If a value is provided here, it will override the // model associated with the assistant. If not, the model associated with the @@ -736,7 +748,8 @@ type BetaThreadNewAndRunParams struct { // make the output more random, while lower values like 0.2 will make it more // focused and deterministic. Temperature param.Field[float64] `json:"temperature"` - // If no thread is provided, an empty thread will be created. + // Options to create a new thread. If no thread is provided when running a request, + // an empty thread will be created. Thread param.Field[BetaThreadNewAndRunParamsThread] `json:"thread"` // Controls which (if any) tool is called by the model. `none` means the model will // not call any tools and instead generates a message. `auto` is the default value @@ -769,16 +782,19 @@ func (r BetaThreadNewAndRunParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// If no thread is provided, an empty thread will be created. +// Options to create a new thread. If no thread is provided when running a request, +// an empty thread will be created. type BetaThreadNewAndRunParamsThread struct { // A list of [messages](https://platform.openai.com/docs/api-reference/messages) to // start the thread with. Messages param.Field[[]BetaThreadNewAndRunParamsThreadMessage] `json:"messages"` // 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"` // A set of resources that are made available to the assistant's tools in this // thread. The resources are specific to the type of tool. For example, the // `code_interpreter` tool requires a list of file IDs, while the `file_search` @@ -806,10 +822,12 @@ type BetaThreadNewAndRunParamsThreadMessage struct { // A list of files attached to the message, and the tools they should be added to. Attachments param.Field[[]BetaThreadNewAndRunParamsThreadMessagesAttachment] `json:"attachments"` // 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"` } func (r BetaThreadNewAndRunParamsThreadMessage) MarshalJSON() (data []byte, err error) { @@ -959,11 +977,13 @@ type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore 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 BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) { diff --git a/betathread_test.go b/betathread_test.go index a9a3ef8..b3f0cc8 100644 --- a/betathread_test.go +++ b/betathread_test.go @@ -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 TestBetaThreadNewWithOptionalParams(t *testing.T) { @@ -35,9 +36,13 @@ func TestBetaThreadNewWithOptionalParams(t *testing.T) { Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }}), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), ToolResources: openai.F(openai.BetaThreadNewParamsToolResources{ CodeInterpreter: openai.F(openai.BetaThreadNewParamsToolResourcesCodeInterpreter{ FileIDs: openai.F([]string{"string"}), @@ -48,8 +53,10 @@ func TestBetaThreadNewWithOptionalParams(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", + }), }}), }), }), @@ -101,7 +108,9 @@ func TestBetaThreadUpdateWithOptionalParams(t *testing.T) { context.TODO(), "thread_id", openai.BetaThreadUpdateParams{ - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), ToolResources: openai.F(openai.BetaThreadUpdateParamsToolResources{ CodeInterpreter: openai.F(openai.BetaThreadUpdateParamsToolResourcesCodeInterpreter{ FileIDs: openai.F([]string{"string"}), @@ -160,10 +169,12 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) { Instructions: openai.F("instructions"), MaxCompletionTokens: openai.F(int64(256)), MaxPromptTokens: openai.F(int64(256)), - Metadata: openai.F[any](map[string]interface{}{}), - Model: openai.F(openai.ChatModelO1), - ParallelToolCalls: openai.F(true), - Temperature: openai.F(1.000000), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), + Model: openai.F(openai.ChatModelO3Mini), + ParallelToolCalls: openai.F(true), + Temperature: openai.F(1.000000), Thread: openai.F(openai.BetaThreadNewAndRunParamsThread{ Messages: openai.F([]openai.BetaThreadNewAndRunParamsThreadMessage{{ Content: openai.F([]openai.MessageContentPartParamUnion{openai.ImageFileContentBlockParam{ImageFile: openai.F(openai.ImageFileParam{FileID: openai.F("file_id"), Detail: openai.F(openai.ImageFileDetailAuto)}), Type: openai.F(openai.ImageFileContentBlockTypeImageFile)}}), @@ -174,9 +185,13 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) { Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }}), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), ToolResources: openai.F(openai.BetaThreadNewAndRunParamsThreadToolResources{ CodeInterpreter: openai.F(openai.BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter{ FileIDs: openai.F([]string{"string"}), @@ -187,8 +202,10 @@ func TestBetaThreadNewAndRunWithOptionalParams(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", + }), }}), }), }), diff --git a/betathreadmessage.go b/betathreadmessage.go index 6f8f4e9..a62d134 100644 --- a/betathreadmessage.go +++ b/betathreadmessage.go @@ -16,6 +16,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" "github.com/tidwall/gjson" ) @@ -1050,10 +1051,12 @@ type Message struct { // On an incomplete message, details about why the message is incomplete. IncompleteDetails MessageIncompleteDetails `json:"incomplete_details,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"` // The object type, which is always `thread.message`. Object MessageObject `json:"object,required"` // The entity that produced the message. One of `user` or `assistant`. @@ -1964,10 +1967,12 @@ type BetaThreadMessageNewParams struct { // A list of files attached to the message, and the tools they should be added to. Attachments param.Field[[]BetaThreadMessageNewParamsAttachment] `json:"attachments"` // 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"` } func (r BetaThreadMessageNewParams) MarshalJSON() (data []byte, err error) { @@ -2070,10 +2075,12 @@ func (r BetaThreadMessageNewParamsAttachmentsToolsType) IsKnown() bool { type BetaThreadMessageUpdateParams struct { // 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"` } func (r BetaThreadMessageUpdateParams) MarshalJSON() (data []byte, err error) { diff --git a/betathreadmessage_test.go b/betathreadmessage_test.go index facc3d7..9f99567 100644 --- a/betathreadmessage_test.go +++ b/betathreadmessage_test.go @@ -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 TestBetaThreadMessageNewWithOptionalParams(t *testing.T) { @@ -37,7 +38,9 @@ func TestBetaThreadMessageNewWithOptionalParams(t *testing.T) { Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }}), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }, ) if err != nil { @@ -92,7 +95,9 @@ func TestBetaThreadMessageUpdateWithOptionalParams(t *testing.T) { "thread_id", "message_id", openai.BetaThreadMessageUpdateParams{ - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }, ) if err != nil { diff --git a/betathreadrun.go b/betathreadrun.go index ee9b9ea..b2766f3 100644 --- a/betathreadrun.go +++ b/betathreadrun.go @@ -16,6 +16,7 @@ import ( "github.com/openai/openai-go/option" "github.com/openai/openai-go/packages/pagination" "github.com/openai/openai-go/packages/ssestream" + "github.com/openai/openai-go/shared" ) // BetaThreadRunService contains methods and other services that help with @@ -323,10 +324,12 @@ type Run struct { // of the run. MaxPromptTokens int64 `json:"max_prompt_tokens,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"` // The model that the // [assistant](https://platform.openai.com/docs/api-reference/assistants) used for // this run. @@ -718,10 +721,12 @@ type BetaThreadRunNewParams struct { // `incomplete_details` for more info. MaxPromptTokens param.Field[int64] `json:"max_prompt_tokens"` // 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 ID of the [Model](https://platform.openai.com/docs/api-reference/models) to // be used to execute this run. If a value is provided here, it will override the // model associated with the assistant. If not, the model associated with the @@ -785,10 +790,12 @@ type BetaThreadRunNewParamsAdditionalMessage struct { // A list of files attached to the message, and the tools they should be added to. Attachments param.Field[[]BetaThreadRunNewParamsAdditionalMessagesAttachment] `json:"attachments"` // 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"` } func (r BetaThreadRunNewParamsAdditionalMessage) MarshalJSON() (data []byte, err error) { @@ -927,10 +934,12 @@ func (r BetaThreadRunNewParamsTruncationStrategyType) IsKnown() bool { type BetaThreadRunUpdateParams struct { // 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"` } func (r BetaThreadRunUpdateParams) MarshalJSON() (data []byte, err error) { diff --git a/betathreadrun_test.go b/betathreadrun_test.go index 7967ddf..66a39aa 100644 --- a/betathreadrun_test.go +++ b/betathreadrun_test.go @@ -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 TestBetaThreadRunNewWithOptionalParams(t *testing.T) { @@ -41,16 +42,20 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) { Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }}), }}), - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }}), Instructions: openai.F("instructions"), MaxCompletionTokens: openai.F(int64(256)), MaxPromptTokens: openai.F(int64(256)), - Metadata: openai.F[any](map[string]interface{}{}), - Model: openai.F(openai.ChatModelO1), - ParallelToolCalls: openai.F(true), - Temperature: openai.F(1.000000), - ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionAuto(openai.AssistantToolChoiceOptionAutoNone)), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), + Model: openai.F(openai.ChatModelO3Mini), + ParallelToolCalls: openai.F(true), + Temperature: openai.F(1.000000), + ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionAuto(openai.AssistantToolChoiceOptionAutoNone)), Tools: openai.F([]openai.AssistantToolUnionParam{openai.CodeInterpreterToolParam{ Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }}), @@ -113,7 +118,9 @@ func TestBetaThreadRunUpdateWithOptionalParams(t *testing.T) { "thread_id", "run_id", openai.BetaThreadRunUpdateParams{ - Metadata: openai.F[any](map[string]interface{}{}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), }, ) if err != nil { diff --git a/betathreadrunstep.go b/betathreadrunstep.go index efa3dc7..8fdc27c 100644 --- a/betathreadrunstep.go +++ b/betathreadrunstep.go @@ -16,6 +16,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" "github.com/tidwall/gjson" ) @@ -1127,10 +1128,12 @@ type RunStep struct { // errors. LastError RunStepLastError `json:"last_error,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"` // The object type, which is always `thread.run.step`. Object RunStepObject `json:"object,required"` // The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that diff --git a/betavectorstore.go b/betavectorstore.go index 08495df..8f7930b 100644 --- a/betavectorstore.go +++ b/betavectorstore.go @@ -16,6 +16,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" "github.com/tidwall/gjson" ) @@ -424,10 +425,12 @@ type VectorStore struct { // The Unix timestamp (in seconds) for when the vector store was last active. LastActiveAt int64 `json:"last_active_at,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"` // The name of the vector store. Name string `json:"name,required"` // The object type, which is always `vector_store`. @@ -631,10 +634,12 @@ type BetaVectorStoreNewParams struct { // files. FileIDs param.Field[[]string] `json:"file_ids"` // 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 vector store. Name param.Field[string] `json:"name"` } @@ -676,10 +681,12 @@ type BetaVectorStoreUpdateParams struct { // The expiration policy for a vector store. ExpiresAfter param.Field[BetaVectorStoreUpdateParamsExpiresAfter] `json:"expires_after"` // 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 vector store. Name param.Field[string] `json:"name"` } diff --git a/betavectorstore_test.go b/betavectorstore_test.go index f19a530..a845765 100644 --- a/betavectorstore_test.go +++ b/betavectorstore_test.go @@ -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 TestBetaVectorStoreNewWithOptionalParams(t *testing.T) { @@ -33,9 +34,11 @@ func TestBetaVectorStoreNewWithOptionalParams(t *testing.T) { Anchor: openai.F(openai.BetaVectorStoreNewParamsExpiresAfterAnchorLastActiveAt), Days: openai.F(int64(1)), }), - FileIDs: openai.F([]string{"string"}), - Metadata: openai.F[any](map[string]interface{}{}), - Name: openai.F("name"), + FileIDs: openai.F([]string{"string"}), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), + Name: openai.F("name"), }) if err != nil { var apierr *openai.Error @@ -88,8 +91,10 @@ func TestBetaVectorStoreUpdateWithOptionalParams(t *testing.T) { Anchor: openai.F(openai.BetaVectorStoreUpdateParamsExpiresAfterAnchorLastActiveAt), Days: openai.F(int64(1)), }), - Metadata: openai.F[any](map[string]interface{}{}), - Name: openai.F("name"), + Metadata: openai.F(shared.MetadataParam{ + "foo": "string", + }), + Name: openai.F("name"), }, ) if err != nil { diff --git a/chat.go b/chat.go index 3e1d9dc..0a050eb 100644 --- a/chat.go +++ b/chat.go @@ -30,6 +30,8 @@ func NewChatService(opts ...option.RequestOption) (r *ChatService) { type ChatModel = string const ( + ChatModelO3Mini ChatModel = "o3-mini" + ChatModelO3Mini2025_01_31 ChatModel = "o3-mini-2025-01-31" ChatModelO1 ChatModel = "o1" ChatModelO1_2024_12_17 ChatModel = "o1-2024-12-17" ChatModelO1Preview ChatModel = "o1-preview" diff --git a/chatcompletion.go b/chatcompletion.go index 4cb1334..9e8681d 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -1837,9 +1837,13 @@ type ChatCompletionNewParams struct { // compatible with // [o1 series models](https://platform.openai.com/docs/guides/reasoning). MaxTokens param.Field[int64] `json:"max_tokens"` - // Developer-defined tags and values used for filtering completions in the - // [dashboard](https://platform.openai.com/chat-completions). - 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"` // Output types that you would like the model to generate for this request. Most // models are capable of generating text, which is the default: // @@ -1904,9 +1908,9 @@ type ChatCompletionNewParams struct { // utilize scale tier credits until they are exhausted. // - If set to 'auto', and the Project is not Scale tier enabled, the request will // be processed using the default service tier with a lower uptime SLA and no - // latency guarentee. + // latency guarantee. // - If set to 'default', the request will be processed using the default service - // tier with a lower uptime SLA and no latency guarentee. + // tier with a lower uptime SLA and no latency guarantee. // - When not set, the default behavior is 'auto'. ServiceTier param.Field[ChatCompletionNewParamsServiceTier] `json:"service_tier"` // Up to 4 sequences where the API will stop generating further tokens. @@ -2101,9 +2105,9 @@ func (r ChatCompletionNewParamsResponseFormatType) IsKnown() bool { // utilize scale tier credits until they are exhausted. // - If set to 'auto', and the Project is not Scale tier enabled, the request will // be processed using the default service tier with a lower uptime SLA and no -// latency guarentee. +// latency guarantee. // - If set to 'default', the request will be processed using the default service -// tier with a lower uptime SLA and no latency guarentee. +// tier with a lower uptime SLA and no latency guarantee. // - When not set, the default behavior is 'auto'. type ChatCompletionNewParamsServiceTier string diff --git a/chatcompletion_test.go b/chatcompletion_test.go index 5804de9..2248171 100644 --- a/chatcompletion_test.go +++ b/chatcompletion_test.go @@ -32,7 +32,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { Role: openai.F(openai.ChatCompletionDeveloperMessageParamRoleDeveloper), Name: openai.F("name"), }}), - Model: openai.F(openai.ChatModelO1), + Model: openai.F(openai.ChatModelO3Mini), Audio: openai.F(openai.ChatCompletionAudioParam{ Format: openai.F(openai.ChatCompletionAudioParamFormatWAV), Voice: openai.F(openai.ChatCompletionAudioParamVoiceAlloy), @@ -52,7 +52,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { Logprobs: openai.F(true), MaxCompletionTokens: openai.F(int64(0)), MaxTokens: openai.F(int64(0)), - Metadata: openai.F(map[string]string{ + Metadata: openai.F(shared.MetadataParam{ "foo": "string", }), Modalities: openai.F([]openai.ChatCompletionModality{openai.ChatCompletionModalityText}), diff --git a/client_test.go b/client_test.go index 64aa9dd..9be4432 100644 --- a/client_test.go +++ b/client_test.go @@ -42,7 +42,7 @@ func TestUserAgentHeader(t *testing.T) { 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 userAgent != fmt.Sprintf("OpenAI/Go %s", internal.PackageVersion) { t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent) @@ -71,7 +71,7 @@ func TestRetryAfter(t *testing.T) { 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 { t.Error("Expected there to be a cancel error") @@ -111,7 +111,7 @@ func TestDeleteRetryCountHeader(t *testing.T) { 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 { t.Error("Expected there to be a cancel error") @@ -146,7 +146,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) { 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 { t.Error("Expected there to be a cancel error") @@ -180,7 +180,7 @@ func TestRetryAfterMs(t *testing.T) { 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 { t.Error("Expected there to be a cancel error") @@ -208,7 +208,7 @@ func TestContextCancel(t *testing.T) { 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 { t.Error("Expected there to be a cancel error") @@ -233,7 +233,7 @@ func TestContextCancelDelay(t *testing.T) { 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 { t.Error("expected there to be a cancel error") @@ -264,7 +264,7 @@ func TestContextDeadline(t *testing.T) { 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 { t.Error("expected there to be a deadline error") diff --git a/shared/shared.go b/shared/shared.go index 9bf1ed3..a9dce4b 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -105,6 +105,10 @@ func (r FunctionDefinitionParam) MarshalJSON() (data []byte, err error) { type FunctionParameters map[string]interface{} +type Metadata map[string]string + +type MetadataParam map[string]string + type ResponseFormatJSONObjectParam struct { // The type of response format being defined: `json_object` Type param.Field[ResponseFormatJSONObjectType] `json:"type,required"` diff --git a/upload.go b/upload.go index 0c5f0d1..26c52e5 100644 --- a/upload.go +++ b/upload.go @@ -118,7 +118,7 @@ type Upload struct { Purpose string `json:"purpose,required"` // The status of the Upload. Status UploadStatus `json:"status,required"` - // The ready File object after the Upload is completed. + // The `File` object represents a document that has been uploaded to OpenAI. File FileObject `json:"file,nullable"` JSON uploadJSON `json:"-"` } diff --git a/usage_test.go b/usage_test.go index 930d2d8..7d26068 100644 --- a/usage_test.go +++ b/usage_test.go @@ -29,7 +29,7 @@ func TestUsage(t *testing.T) { 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 { t.Error(err) From fe22468dc9d1685be36afdbc80a7c7392bd3d2ed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 19:11:20 +0000 Subject: [PATCH 4/4] release: 0.1.0-alpha.51 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 14 ++++++++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 56c2389..fa87c7e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.50" + ".": "0.1.0-alpha.51" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b5875..c614f3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.1.0-alpha.51 (2025-01-31) + +Full Changelog: [v0.1.0-alpha.50...v0.1.0-alpha.51](https://github.com/openai/openai-go/compare/v0.1.0-alpha.50...v0.1.0-alpha.51) + +### Features + +* **api:** add o3-mini ([#195](https://github.com/openai/openai-go/issues/195)) ([c5689d0](https://github.com/openai/openai-go/commit/c5689d01773a7ac0c10e95c1c8badadde251924e)) + + +### Bug Fixes + +* fix unicode encoding for json ([#193](https://github.com/openai/openai-go/issues/193)) ([3bd3c60](https://github.com/openai/openai-go/commit/3bd3c60561b1213dc4a5fe8b27c30ddef8234726)) +* **types:** correct metadata type + other fixes ([c5689d0](https://github.com/openai/openai-go/commit/c5689d01773a7ac0c10e95c1c8badadde251924e)) + ## 0.1.0-alpha.50 (2025-01-29) Full Changelog: [v0.1.0-alpha.49...v0.1.0-alpha.50](https://github.com/openai/openai-go/compare/v0.1.0-alpha.49...v0.1.0-alpha.50) diff --git a/README.md b/README.md index d366aef..0f260c0 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go@v0.1.0-alpha.50' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.51' ``` diff --git a/internal/version.go b/internal/version.go index d61716e..ddc9cd7 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.50" // x-release-please-version +const PackageVersion = "0.1.0-alpha.51" // x-release-please-version