From 14f29510a5f81eecd85db6e9369f1cb4a5585eff Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Thu, 6 Mar 2025 14:49:59 +0000 Subject: [PATCH] chore: move ChatModel type to shared --- README.md | 9 +-- aliases.go | 126 +++++++++++++++++++++++++++++++++++++++++ api.md | 5 +- betaassistant.go | 2 +- betaassistant_test.go | 2 +- betathread.go | 2 +- betathread_test.go | 2 +- betathreadrun.go | 2 +- betathreadrun_test.go | 2 +- chat.go | 46 --------------- chatcompletion.go | 2 +- chatcompletion_test.go | 2 +- client_test.go | 21 +++---- finetuningjob.go | 80 +++++++++++++------------- shared/shared.go | 46 +++++++++++++++ usage_test.go | 3 +- 16 files changed, 239 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index 0b6e1337..d80ede4a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ import ( "github.com/openai/openai-go" "github.com/openai/openai-go/option" + "github.com/openai/openai-go/shared" ) func main() { @@ -55,7 +56,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err != nil { panic(err.Error()) @@ -242,7 +243,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }, // This sets the per-retry timeout option.WithRequestTimeout(20*time.Second), @@ -305,7 +306,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }, option.WithMaxRetries(5), ) @@ -326,7 +327,7 @@ chatCompletion, err := 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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }, option.WithResponseInto(&response), ) diff --git a/aliases.go b/aliases.go index eae9b385..3694c617 100644 --- a/aliases.go +++ b/aliases.go @@ -9,6 +9,132 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type ChatModel = shared.ChatModel + +// This is an alias to an internal value. +const ChatModelO3Mini = shared.ChatModelO3Mini + +// This is an alias to an internal value. +const ChatModelO3Mini2025_01_31 = shared.ChatModelO3Mini2025_01_31 + +// This is an alias to an internal value. +const ChatModelO1 = shared.ChatModelO1 + +// This is an alias to an internal value. +const ChatModelO1_2024_12_17 = shared.ChatModelO1_2024_12_17 + +// This is an alias to an internal value. +const ChatModelO1Preview = shared.ChatModelO1Preview + +// This is an alias to an internal value. +const ChatModelO1Preview2024_09_12 = shared.ChatModelO1Preview2024_09_12 + +// This is an alias to an internal value. +const ChatModelO1Mini = shared.ChatModelO1Mini + +// This is an alias to an internal value. +const ChatModelO1Mini2024_09_12 = shared.ChatModelO1Mini2024_09_12 + +// This is an alias to an internal value. +const ChatModelGPT4_5Preview = shared.ChatModelGPT4_5Preview + +// This is an alias to an internal value. +const ChatModelGPT4_5Preview2025_02_27 = shared.ChatModelGPT4_5Preview2025_02_27 + +// This is an alias to an internal value. +const ChatModelGPT4o = shared.ChatModelGPT4o + +// This is an alias to an internal value. +const ChatModelGPT4o2024_11_20 = shared.ChatModelGPT4o2024_11_20 + +// This is an alias to an internal value. +const ChatModelGPT4o2024_08_06 = shared.ChatModelGPT4o2024_08_06 + +// This is an alias to an internal value. +const ChatModelGPT4o2024_05_13 = shared.ChatModelGPT4o2024_05_13 + +// This is an alias to an internal value. +const ChatModelGPT4oAudioPreview = shared.ChatModelGPT4oAudioPreview + +// This is an alias to an internal value. +const ChatModelGPT4oAudioPreview2024_10_01 = shared.ChatModelGPT4oAudioPreview2024_10_01 + +// This is an alias to an internal value. +const ChatModelGPT4oAudioPreview2024_12_17 = shared.ChatModelGPT4oAudioPreview2024_12_17 + +// This is an alias to an internal value. +const ChatModelGPT4oMiniAudioPreview = shared.ChatModelGPT4oMiniAudioPreview + +// This is an alias to an internal value. +const ChatModelGPT4oMiniAudioPreview2024_12_17 = shared.ChatModelGPT4oMiniAudioPreview2024_12_17 + +// This is an alias to an internal value. +const ChatModelChatgpt4oLatest = shared.ChatModelChatgpt4oLatest + +// This is an alias to an internal value. +const ChatModelGPT4oMini = shared.ChatModelGPT4oMini + +// This is an alias to an internal value. +const ChatModelGPT4oMini2024_07_18 = shared.ChatModelGPT4oMini2024_07_18 + +// This is an alias to an internal value. +const ChatModelGPT4Turbo = shared.ChatModelGPT4Turbo + +// This is an alias to an internal value. +const ChatModelGPT4Turbo2024_04_09 = shared.ChatModelGPT4Turbo2024_04_09 + +// This is an alias to an internal value. +const ChatModelGPT4_0125Preview = shared.ChatModelGPT4_0125Preview + +// This is an alias to an internal value. +const ChatModelGPT4TurboPreview = shared.ChatModelGPT4TurboPreview + +// This is an alias to an internal value. +const ChatModelGPT4_1106Preview = shared.ChatModelGPT4_1106Preview + +// This is an alias to an internal value. +const ChatModelGPT4VisionPreview = shared.ChatModelGPT4VisionPreview + +// This is an alias to an internal value. +const ChatModelGPT4 = shared.ChatModelGPT4 + +// This is an alias to an internal value. +const ChatModelGPT4_0314 = shared.ChatModelGPT4_0314 + +// This is an alias to an internal value. +const ChatModelGPT4_0613 = shared.ChatModelGPT4_0613 + +// This is an alias to an internal value. +const ChatModelGPT4_32k = shared.ChatModelGPT4_32k + +// This is an alias to an internal value. +const ChatModelGPT4_32k0314 = shared.ChatModelGPT4_32k0314 + +// This is an alias to an internal value. +const ChatModelGPT4_32k0613 = shared.ChatModelGPT4_32k0613 + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo = shared.ChatModelGPT3_5Turbo + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo16k = shared.ChatModelGPT3_5Turbo16k + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo0301 = shared.ChatModelGPT3_5Turbo0301 + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo0613 = shared.ChatModelGPT3_5Turbo0613 + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo1106 = shared.ChatModelGPT3_5Turbo1106 + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo0125 = shared.ChatModelGPT3_5Turbo0125 + +// This is an alias to an internal value. +const ChatModelGPT3_5Turbo16k0613 = shared.ChatModelGPT3_5Turbo16k0613 + // This is an alias to an internal type. type ErrorObject = shared.ErrorObject diff --git a/api.md b/api.md index 304da154..6830ca16 100644 --- a/api.md +++ b/api.md @@ -1,5 +1,6 @@ # Shared Params Types +- shared.ChatModel - shared.FunctionDefinitionParam - shared.FunctionParameters - shared.MetadataParam @@ -28,10 +29,6 @@ Methods: # Chat -Params Types: - -- openai.ChatModel - ## Completions Params Types: diff --git a/betaassistant.go b/betaassistant.go index 96176c7f..99e32afc 100644 --- a/betaassistant.go +++ b/betaassistant.go @@ -2067,7 +2067,7 @@ type BetaAssistantNewParams struct { // see all of your available models, or see our // [Model overview](https://platform.openai.com/docs/models) for descriptions of // them. - Model param.Field[ChatModel] `json:"model,required"` + Model param.Field[shared.ChatModel] `json:"model,required"` // The description of the assistant. The maximum length is 512 characters. Description param.Field[string] `json:"description"` // The system instructions that the assistant uses. The maximum length is 256,000 diff --git a/betaassistant_test.go b/betaassistant_test.go index 3131e3cb..e06596d8 100644 --- a/betaassistant_test.go +++ b/betaassistant_test.go @@ -27,7 +27,7 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) { option.WithAPIKey("My API Key"), ) _, err := client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{ - Model: openai.F(openai.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), Description: openai.F("description"), Instructions: openai.F("instructions"), Metadata: openai.F(shared.MetadataParam{ diff --git a/betathread.go b/betathread.go index 88a9d180..43ea3820 100644 --- a/betathread.go +++ b/betathread.go @@ -730,7 +730,7 @@ type BetaThreadNewAndRunParams struct { // 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 // assistant will be used. - Model param.Field[ChatModel] `json:"model"` + Model param.Field[shared.ChatModel] `json:"model"` // Whether to enable // [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) // during tool use. diff --git a/betathread_test.go b/betathread_test.go index b3f0cc86..2b3578ee 100644 --- a/betathread_test.go +++ b/betathread_test.go @@ -172,7 +172,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) { Metadata: openai.F(shared.MetadataParam{ "foo": "string", }), - Model: openai.F(openai.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), ParallelToolCalls: openai.F(true), Temperature: openai.F(1.000000), Thread: openai.F(openai.BetaThreadNewAndRunParamsThread{ diff --git a/betathreadrun.go b/betathreadrun.go index 4aaab610..6af1d835 100644 --- a/betathreadrun.go +++ b/betathreadrun.go @@ -709,7 +709,7 @@ type BetaThreadRunNewParams struct { // 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 // assistant will be used. - Model param.Field[ChatModel] `json:"model"` + Model param.Field[shared.ChatModel] `json:"model"` // Whether to enable // [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) // during tool use. diff --git a/betathreadrun_test.go b/betathreadrun_test.go index e228f4ed..d955b7af 100644 --- a/betathreadrun_test.go +++ b/betathreadrun_test.go @@ -52,7 +52,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) { Metadata: openai.F(shared.MetadataParam{ "foo": "string", }), - Model: openai.F(openai.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), ParallelToolCalls: openai.F(true), ReasoningEffort: openai.F(openai.BetaThreadRunNewParamsReasoningEffortLow), Temperature: openai.F(1.000000), diff --git a/chat.go b/chat.go index 1162a281..fb7af6e6 100644 --- a/chat.go +++ b/chat.go @@ -26,49 +26,3 @@ func NewChatService(opts ...option.RequestOption) (r *ChatService) { r.Completions = NewChatCompletionService(opts...) return } - -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" - ChatModelO1Preview2024_09_12 ChatModel = "o1-preview-2024-09-12" - ChatModelO1Mini ChatModel = "o1-mini" - ChatModelO1Mini2024_09_12 ChatModel = "o1-mini-2024-09-12" - ChatModelGPT4_5Preview ChatModel = "gpt-4.5-preview" - ChatModelGPT4_5Preview2025_02_27 ChatModel = "gpt-4.5-preview-2025-02-27" - ChatModelGPT4o ChatModel = "gpt-4o" - ChatModelGPT4o2024_11_20 ChatModel = "gpt-4o-2024-11-20" - ChatModelGPT4o2024_08_06 ChatModel = "gpt-4o-2024-08-06" - ChatModelGPT4o2024_05_13 ChatModel = "gpt-4o-2024-05-13" - ChatModelGPT4oAudioPreview ChatModel = "gpt-4o-audio-preview" - ChatModelGPT4oAudioPreview2024_10_01 ChatModel = "gpt-4o-audio-preview-2024-10-01" - ChatModelGPT4oAudioPreview2024_12_17 ChatModel = "gpt-4o-audio-preview-2024-12-17" - ChatModelGPT4oMiniAudioPreview ChatModel = "gpt-4o-mini-audio-preview" - ChatModelGPT4oMiniAudioPreview2024_12_17 ChatModel = "gpt-4o-mini-audio-preview-2024-12-17" - ChatModelChatgpt4oLatest ChatModel = "chatgpt-4o-latest" - ChatModelGPT4oMini ChatModel = "gpt-4o-mini" - ChatModelGPT4oMini2024_07_18 ChatModel = "gpt-4o-mini-2024-07-18" - ChatModelGPT4Turbo ChatModel = "gpt-4-turbo" - ChatModelGPT4Turbo2024_04_09 ChatModel = "gpt-4-turbo-2024-04-09" - ChatModelGPT4_0125Preview ChatModel = "gpt-4-0125-preview" - ChatModelGPT4TurboPreview ChatModel = "gpt-4-turbo-preview" - ChatModelGPT4_1106Preview ChatModel = "gpt-4-1106-preview" - ChatModelGPT4VisionPreview ChatModel = "gpt-4-vision-preview" - ChatModelGPT4 ChatModel = "gpt-4" - ChatModelGPT4_0314 ChatModel = "gpt-4-0314" - ChatModelGPT4_0613 ChatModel = "gpt-4-0613" - ChatModelGPT4_32k ChatModel = "gpt-4-32k" - ChatModelGPT4_32k0314 ChatModel = "gpt-4-32k-0314" - ChatModelGPT4_32k0613 ChatModel = "gpt-4-32k-0613" - ChatModelGPT3_5Turbo ChatModel = "gpt-3.5-turbo" - ChatModelGPT3_5Turbo16k ChatModel = "gpt-3.5-turbo-16k" - ChatModelGPT3_5Turbo0301 ChatModel = "gpt-3.5-turbo-0301" - ChatModelGPT3_5Turbo0613 ChatModel = "gpt-3.5-turbo-0613" - ChatModelGPT3_5Turbo1106 ChatModel = "gpt-3.5-turbo-1106" - ChatModelGPT3_5Turbo0125 ChatModel = "gpt-3.5-turbo-0125" - ChatModelGPT3_5Turbo16k0613 ChatModel = "gpt-3.5-turbo-16k-0613" -) diff --git a/chatcompletion.go b/chatcompletion.go index 78f8cb36..5c62608c 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -1826,7 +1826,7 @@ type ChatCompletionNewParams struct { // ID of the model to use. See the // [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility) // table for details on which models work with the Chat API. - Model param.Field[ChatModel] `json:"model,required"` + Model param.Field[shared.ChatModel] `json:"model,required"` // Parameters for audio output. Required when audio output is requested with // `modalities: ["audio"]`. // [Learn more](https://platform.openai.com/docs/guides/audio). diff --git a/chatcompletion_test.go b/chatcompletion_test.go index 1fb57aa8..1a4be6e4 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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), Audio: openai.F(openai.ChatCompletionAudioParam{ Format: openai.F(openai.ChatCompletionAudioParamFormatWAV), Voice: openai.F(openai.ChatCompletionAudioParamVoiceAlloy), diff --git a/client_test.go b/client_test.go index 773f3ab3..94efef1e 100644 --- a/client_test.go +++ b/client_test.go @@ -14,6 +14,7 @@ import ( "github.com/openai/openai-go" "github.com/openai/openai-go/internal" "github.com/openai/openai-go/option" + "github.com/openai/openai-go/shared" ) type closureTransport struct { @@ -43,7 +44,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if userAgent != fmt.Sprintf("OpenAI/Go %s", internal.PackageVersion) { t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent) @@ -72,7 +73,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("Expected there to be a cancel error") @@ -112,7 +113,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("Expected there to be a cancel error") @@ -147,7 +148,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("Expected there to be a cancel error") @@ -181,7 +182,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("Expected there to be a cancel error") @@ -209,7 +210,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("Expected there to be a cancel error") @@ -234,7 +235,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("expected there to be a cancel error") @@ -265,7 +266,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err == nil { t.Error("expected there to be a deadline error") @@ -315,7 +316,7 @@ func TestContextDeadlineStreaming(t *testing.T) { Content: openai.F([]openai.ChatCompletionContentPartTextParam{{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}), Role: openai.F(openai.ChatCompletionDeveloperMessageParamRoleDeveloper), }}), - Model: openai.F(openai.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) for stream.Next() { _ = stream.Current() @@ -367,7 +368,7 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) { Content: openai.F([]openai.ChatCompletionContentPartTextParam{{Text: openai.F("text"), Type: openai.F(openai.ChatCompletionContentPartTextTypeText)}}), Role: openai.F(openai.ChatCompletionDeveloperMessageParamRoleDeveloper), }}), - Model: openai.F(openai.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }, option.WithRequestTimeout((100 * time.Millisecond)), ) diff --git a/finetuningjob.go b/finetuningjob.go index 0559cd61..33ebb5da 100644 --- a/finetuningjob.go +++ b/finetuningjob.go @@ -985,6 +985,46 @@ func (r FineTuningJobEventType) IsKnown() bool { return false } +// The settings for your integration with Weights and Biases. This payload +// specifies the project that metrics will be sent to. Optionally, you can set an +// explicit display name for your run, add tags to your run, and set a default +// entity (team, username, etc) to be associated with your run. +type FineTuningJobWandbIntegration struct { + // The name of the project that the new run will be created under. + Project string `json:"project,required"` + // The entity to use for the run. This allows you to set the team or username of + // the WandB user that you would like associated with the run. If not set, the + // default entity for the registered WandB API key is used. + Entity string `json:"entity,nullable"` + // A display name to set for the run. If not set, we will use the Job ID as the + // name. + Name string `json:"name,nullable"` + // A list of tags to be attached to the newly created run. These tags are passed + // through directly to WandB. Some default tags are generated by OpenAI: + // "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + Tags []string `json:"tags"` + JSON fineTuningJobWandbIntegrationJSON `json:"-"` +} + +// fineTuningJobWandbIntegrationJSON contains the JSON metadata for the struct +// [FineTuningJobWandbIntegration] +type fineTuningJobWandbIntegrationJSON struct { + Project apijson.Field + Entity apijson.Field + Name apijson.Field + Tags apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FineTuningJobWandbIntegration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fineTuningJobWandbIntegrationJSON) RawJSON() string { + return r.raw +} + type FineTuningJobWandbIntegrationObject struct { // The type of the integration being enabled for the fine-tuning job Type FineTuningJobWandbIntegrationObjectType `json:"type,required"` @@ -1028,46 +1068,6 @@ func (r FineTuningJobWandbIntegrationObjectType) IsKnown() bool { return false } -// The settings for your integration with Weights and Biases. This payload -// specifies the project that metrics will be sent to. Optionally, you can set an -// explicit display name for your run, add tags to your run, and set a default -// entity (team, username, etc) to be associated with your run. -type FineTuningJobWandbIntegration struct { - // The name of the project that the new run will be created under. - Project string `json:"project,required"` - // The entity to use for the run. This allows you to set the team or username of - // the WandB user that you would like associated with the run. If not set, the - // default entity for the registered WandB API key is used. - Entity string `json:"entity,nullable"` - // A display name to set for the run. If not set, we will use the Job ID as the - // name. - Name string `json:"name,nullable"` - // A list of tags to be attached to the newly created run. These tags are passed - // through directly to WandB. Some default tags are generated by OpenAI: - // "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". - Tags []string `json:"tags"` - JSON fineTuningJobWandbIntegrationJSON `json:"-"` -} - -// fineTuningJobWandbIntegrationJSON contains the JSON metadata for the struct -// [FineTuningJobWandbIntegration] -type fineTuningJobWandbIntegrationJSON struct { - Project apijson.Field - Entity apijson.Field - Name apijson.Field - Tags apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FineTuningJobWandbIntegration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fineTuningJobWandbIntegrationJSON) RawJSON() string { - return r.raw -} - type FineTuningJobNewParams struct { // The name of the model to fine-tune. You can select one of the // [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). diff --git a/shared/shared.go b/shared/shared.go index c2df8df5..4da97385 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -7,6 +7,52 @@ import ( "github.com/openai/openai-go/internal/param" ) +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" + ChatModelO1Preview2024_09_12 ChatModel = "o1-preview-2024-09-12" + ChatModelO1Mini ChatModel = "o1-mini" + ChatModelO1Mini2024_09_12 ChatModel = "o1-mini-2024-09-12" + ChatModelGPT4_5Preview ChatModel = "gpt-4.5-preview" + ChatModelGPT4_5Preview2025_02_27 ChatModel = "gpt-4.5-preview-2025-02-27" + ChatModelGPT4o ChatModel = "gpt-4o" + ChatModelGPT4o2024_11_20 ChatModel = "gpt-4o-2024-11-20" + ChatModelGPT4o2024_08_06 ChatModel = "gpt-4o-2024-08-06" + ChatModelGPT4o2024_05_13 ChatModel = "gpt-4o-2024-05-13" + ChatModelGPT4oAudioPreview ChatModel = "gpt-4o-audio-preview" + ChatModelGPT4oAudioPreview2024_10_01 ChatModel = "gpt-4o-audio-preview-2024-10-01" + ChatModelGPT4oAudioPreview2024_12_17 ChatModel = "gpt-4o-audio-preview-2024-12-17" + ChatModelGPT4oMiniAudioPreview ChatModel = "gpt-4o-mini-audio-preview" + ChatModelGPT4oMiniAudioPreview2024_12_17 ChatModel = "gpt-4o-mini-audio-preview-2024-12-17" + ChatModelChatgpt4oLatest ChatModel = "chatgpt-4o-latest" + ChatModelGPT4oMini ChatModel = "gpt-4o-mini" + ChatModelGPT4oMini2024_07_18 ChatModel = "gpt-4o-mini-2024-07-18" + ChatModelGPT4Turbo ChatModel = "gpt-4-turbo" + ChatModelGPT4Turbo2024_04_09 ChatModel = "gpt-4-turbo-2024-04-09" + ChatModelGPT4_0125Preview ChatModel = "gpt-4-0125-preview" + ChatModelGPT4TurboPreview ChatModel = "gpt-4-turbo-preview" + ChatModelGPT4_1106Preview ChatModel = "gpt-4-1106-preview" + ChatModelGPT4VisionPreview ChatModel = "gpt-4-vision-preview" + ChatModelGPT4 ChatModel = "gpt-4" + ChatModelGPT4_0314 ChatModel = "gpt-4-0314" + ChatModelGPT4_0613 ChatModel = "gpt-4-0613" + ChatModelGPT4_32k ChatModel = "gpt-4-32k" + ChatModelGPT4_32k0314 ChatModel = "gpt-4-32k-0314" + ChatModelGPT4_32k0613 ChatModel = "gpt-4-32k-0613" + ChatModelGPT3_5Turbo ChatModel = "gpt-3.5-turbo" + ChatModelGPT3_5Turbo16k ChatModel = "gpt-3.5-turbo-16k" + ChatModelGPT3_5Turbo0301 ChatModel = "gpt-3.5-turbo-0301" + ChatModelGPT3_5Turbo0613 ChatModel = "gpt-3.5-turbo-0613" + ChatModelGPT3_5Turbo1106 ChatModel = "gpt-3.5-turbo-1106" + ChatModelGPT3_5Turbo0125 ChatModel = "gpt-3.5-turbo-0125" + ChatModelGPT3_5Turbo16k0613 ChatModel = "gpt-3.5-turbo-16k-0613" +) + type ErrorObject struct { Code string `json:"code,required,nullable"` Message string `json:"message,required"` diff --git a/usage_test.go b/usage_test.go index 68f4757f..288f3755 100644 --- a/usage_test.go +++ b/usage_test.go @@ -10,6 +10,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 TestUsage(t *testing.T) { @@ -29,7 +30,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.ChatModelO3Mini), + Model: openai.F(shared.ChatModelO3Mini), }) if err != nil { t.Error(err)