From 3a5c6a657ac8d821e95e07b442f00140b5332c93 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:52:13 +0000 Subject: [PATCH 1/4] chore(docs): fix maxium typo (#69) --- .stats.yml | 2 +- batch.go | 2 +- betaassistant.go | 8 ++++---- betathread.go | 18 +++++++++--------- betathreadmessage.go | 6 +++--- betathreadrun.go | 8 ++++---- betathreadrunstep.go | 2 +- betavectorstore.go | 6 +++--- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.stats.yml b/.stats.yml index 68789976..67778eef 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-71e58a77027c67e003fdd1b1ac8ac11557d8bfabc7666d1a827c6b1ca8ab98b5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8ad878332083dd506a478a293db78dc9e7b1b2124f2682e1d991225bc5bbcc3b.yml diff --git a/batch.go b/batch.go index 14a25093..94f07dbb 100644 --- a/batch.go +++ b/batch.go @@ -128,7 +128,7 @@ type Batch struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,nullable"` // The ID of the file containing the outputs of successfully executed requests. diff --git a/betaassistant.go b/betaassistant.go index 148f5a1a..2a8f989e 100644 --- a/betaassistant.go +++ b/betaassistant.go @@ -119,7 +119,7 @@ type Assistant struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // ID of the model to use. You can use the @@ -2063,7 +2063,7 @@ type BetaAssistantNewParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // The name of the assistant. The maximum length is 256 characters. @@ -2144,7 +2144,7 @@ type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct { 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 maxium + // 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"` } @@ -2161,7 +2161,7 @@ type BetaAssistantUpdateParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // ID of the model to use. You can use the diff --git a/betathread.go b/betathread.go index 9ac32615..c192c15b 100644 --- a/betathread.go +++ b/betathread.go @@ -270,7 +270,7 @@ type Thread struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // The object type, which is always `thread`. @@ -437,7 +437,7 @@ type BetaThreadNewParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // A set of resources that are made available to the assistant's tools in this @@ -468,7 +468,7 @@ type BetaThreadNewParamsMessage struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } @@ -622,7 +622,7 @@ type BetaThreadNewParamsToolResourcesFileSearchVectorStore struct { 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 maxium + // 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"` } @@ -634,7 +634,7 @@ 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // A set of resources that are made available to the assistant's tools in this @@ -706,7 +706,7 @@ type BetaThreadNewAndRunParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to @@ -762,7 +762,7 @@ type BetaThreadNewAndRunParamsThread struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // A set of resources that are made available to the assistant's tools in this @@ -793,7 +793,7 @@ type BetaThreadNewAndRunParamsThreadMessage struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } @@ -947,7 +947,7 @@ type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore struct { 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 maxium + // 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"` } diff --git a/betathreadmessage.go b/betathreadmessage.go index 1f719eae..eab161ff 100644 --- a/betathreadmessage.go +++ b/betathreadmessage.go @@ -1047,7 +1047,7 @@ type Message struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // The object type, which is always `thread.message`. @@ -1961,7 +1961,7 @@ type BetaThreadMessageNewParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } @@ -2067,7 +2067,7 @@ 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } diff --git a/betathreadrun.go b/betathreadrun.go index 9b298b85..f2f4f40b 100644 --- a/betathreadrun.go +++ b/betathreadrun.go @@ -297,7 +297,7 @@ type Run struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // The model that the @@ -692,7 +692,7 @@ type BetaThreadRunNewParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to @@ -759,7 +759,7 @@ type BetaThreadRunNewParamsAdditionalMessage struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } @@ -901,7 +901,7 @@ 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` } diff --git a/betathreadrunstep.go b/betathreadrunstep.go index 78425cfd..28b4c5b5 100644 --- a/betathreadrunstep.go +++ b/betathreadrunstep.go @@ -1127,7 +1127,7 @@ type RunStep struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // The object type, which is always `thread.run.step`. diff --git a/betavectorstore.go b/betavectorstore.go index 3e71258b..c16d1c37 100644 --- a/betavectorstore.go +++ b/betavectorstore.go @@ -394,7 +394,7 @@ type VectorStore struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata interface{} `json:"metadata,required,nullable"` // The name of the vector store. @@ -601,7 +601,7 @@ type BetaVectorStoreNewParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // The name of the vector store. @@ -646,7 +646,7 @@ type BetaVectorStoreUpdateParams struct { 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 maxium of 512 + // can be a maximum of 64 characters long and values can be a maximum of 512 // characters long. Metadata param.Field[interface{}] `json:"metadata"` // The name of the vector store. From 1e50f549ef135d7494c9260c4638c6054fe06c74 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:52:13 +0000 Subject: [PATCH 2/4] feat(api): support storing chat completions, enabling evals and model distillation in the dashboard (#72) Learn more at http://openai.com/devday2024 --- .stats.yml | 2 +- chat.go | 59 +++++++++++++++++++++--------------------- chatcompletion.go | 14 ++++++++-- chatcompletion_test.go | 10 ++++--- completion.go | 34 +++++++++++++++++++++++- 5 files changed, 83 insertions(+), 36 deletions(-) diff --git a/.stats.yml b/.stats.yml index 67778eef..ece28735 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-8ad878332083dd506a478a293db78dc9e7b1b2124f2682e1d991225bc5bbcc3b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-52b934aee6468039ec7f4ce046a282b5fbce114afc708e70f17121df654f71da.yml diff --git a/chat.go b/chat.go index 33bcf54b..ab1f5f11 100644 --- a/chat.go +++ b/chat.go @@ -30,33 +30,34 @@ func NewChatService(opts ...option.RequestOption) (r *ChatService) { type ChatModel = string const ( - 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" - ChatModelGPT4o ChatModel = "gpt-4o" - ChatModelGPT4o2024_08_06 ChatModel = "gpt-4o-2024-08-06" - ChatModelGPT4o2024_05_13 ChatModel = "gpt-4o-2024-05-13" - 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" + 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" + ChatModelGPT4o ChatModel = "gpt-4o" + ChatModelGPT4o2024_08_06 ChatModel = "gpt-4o-2024-08-06" + ChatModelGPT4o2024_05_13 ChatModel = "gpt-4o-2024-05-13" + ChatModelGPT4oRealtimePreview2024_10_01 ChatModel = "gpt-4o-realtime-preview-2024-10-01" + 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 3a368c1a..8166a88f 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -1442,8 +1442,12 @@ func (r ChatCompletionUserMessageParamRole) IsKnown() bool { } type ChatCompletionNewParams struct { - // A list of messages comprising the conversation so far. - // [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). + // A list of messages comprising the conversation so far. Depending on the + // [model](https://platform.openai.com/docs/models) you use, different message + // types (modalities) are supported, like + // [text](https://platform.openai.com/docs/guides/text-generation), + // [images](https://platform.openai.com/docs/guides/vision), and + // [audio](https://platform.openai.com/docs/guides/audio). Messages param.Field[[]ChatCompletionMessageParamUnion] `json:"messages,required"` // ID of the model to use. See the // [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) @@ -1495,6 +1499,9 @@ 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/completions). + Metadata param.Field[map[string]string] `json:"metadata"` // How many chat completion choices to generate for each input message. Note that // you will be charged based on the number of generated tokens across all of the // choices. Keep `n` as `1` to minimize costs. @@ -1554,6 +1561,9 @@ type ChatCompletionNewParams struct { ServiceTier param.Field[ChatCompletionNewParamsServiceTier] `json:"service_tier"` // Up to 4 sequences where the API will stop generating further tokens. Stop param.Field[ChatCompletionNewParamsStopUnion] `json:"stop"` + // Whether or not to store the output of this completion request for traffic + // logging in the [dashboard](https://platform.openai.com/completions). + Store param.Field[bool] `json:"store"` // Options for streaming response. Only set this when you set `stream: true`. StreamOptions param.Field[ChatCompletionStreamOptionsParam] `json:"stream_options"` // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will diff --git a/chatcompletion_test.go b/chatcompletion_test.go index 7f5250c8..e0ebbd85 100644 --- a/chatcompletion_test.go +++ b/chatcompletion_test.go @@ -48,15 +48,19 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { Logprobs: openai.F(true), MaxCompletionTokens: openai.F(int64(0)), MaxTokens: openai.F(int64(0)), - N: openai.F(int64(1)), - ParallelToolCalls: openai.F(true), - PresencePenalty: openai.F(-2.000000), + Metadata: openai.F(map[string]string{ + "foo": "string", + }), + N: openai.F(int64(1)), + ParallelToolCalls: openai.F(true), + PresencePenalty: openai.F(-2.000000), ResponseFormat: openai.F[openai.ChatCompletionNewParamsResponseFormatUnion](shared.ResponseFormatTextParam{ Type: openai.F(shared.ResponseFormatTextTypeText), }), Seed: openai.F(int64(-9007199254740991)), ServiceTier: openai.F(openai.ChatCompletionNewParamsServiceTierAuto), Stop: openai.F[openai.ChatCompletionNewParamsStopUnion](shared.UnionString("string")), + Store: openai.F(true), StreamOptions: openai.F(openai.ChatCompletionStreamOptionsParam{ IncludeUsage: openai.F(true), }), diff --git a/completion.go b/completion.go index a55022d1..fb43634f 100644 --- a/completion.go +++ b/completion.go @@ -200,7 +200,9 @@ type CompletionUsage struct { TotalTokens int64 `json:"total_tokens,required"` // Breakdown of tokens used in a completion. CompletionTokensDetails CompletionUsageCompletionTokensDetails `json:"completion_tokens_details"` - JSON completionUsageJSON `json:"-"` + // Breakdown of tokens used in the prompt. + PromptTokensDetails CompletionUsagePromptTokensDetails `json:"prompt_tokens_details"` + JSON completionUsageJSON `json:"-"` } // completionUsageJSON contains the JSON metadata for the struct [CompletionUsage] @@ -209,6 +211,7 @@ type completionUsageJSON struct { PromptTokens apijson.Field TotalTokens apijson.Field CompletionTokensDetails apijson.Field + PromptTokensDetails apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -223,6 +226,8 @@ func (r completionUsageJSON) RawJSON() string { // Breakdown of tokens used in a completion. type CompletionUsageCompletionTokensDetails struct { + // Audio input tokens generated by the model. + AudioTokens int64 `json:"audio_tokens"` // Tokens generated by the model for reasoning. ReasoningTokens int64 `json:"reasoning_tokens"` JSON completionUsageCompletionTokensDetailsJSON `json:"-"` @@ -231,6 +236,7 @@ type CompletionUsageCompletionTokensDetails struct { // completionUsageCompletionTokensDetailsJSON contains the JSON metadata for the // struct [CompletionUsageCompletionTokensDetails] type completionUsageCompletionTokensDetailsJSON struct { + AudioTokens apijson.Field ReasoningTokens apijson.Field raw string ExtraFields map[string]apijson.Field @@ -244,6 +250,32 @@ func (r completionUsageCompletionTokensDetailsJSON) RawJSON() string { return r.raw } +// Breakdown of tokens used in the prompt. +type CompletionUsagePromptTokensDetails struct { + // Audio input tokens present in the prompt. + AudioTokens int64 `json:"audio_tokens"` + // Cached tokens present in the prompt. + CachedTokens int64 `json:"cached_tokens"` + JSON completionUsagePromptTokensDetailsJSON `json:"-"` +} + +// completionUsagePromptTokensDetailsJSON contains the JSON metadata for the struct +// [CompletionUsagePromptTokensDetails] +type completionUsagePromptTokensDetailsJSON struct { + AudioTokens apijson.Field + CachedTokens apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CompletionUsagePromptTokensDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r completionUsagePromptTokensDetailsJSON) RawJSON() string { + return r.raw +} + type CompletionNewParams struct { // ID of the model to use. You can use the // [List models](https://platform.openai.com/docs/api-reference/models/list) API to From 16253e4f210188f3c3adafd8684ed32df0fae995 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:52:51 +0000 Subject: [PATCH 3/4] release: 0.1.0-alpha.24 --- CHANGELOG.md | 13 +++++++++++++ internal/version.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42bb0033..512fd3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.1.0-alpha.24 (2024-10-01) + +Full Changelog: [v0.1.0-alpha.23...v0.1.0-alpha.24](https://github.com/openai/openai-go/compare/v0.1.0-alpha.23...v0.1.0-alpha.24) + +### Features + +* **api:** support storing chat completions, enabling evals and model distillation in the dashboard ([#72](https://github.com/openai/openai-go/issues/72)) ([1e50f54](https://github.com/openai/openai-go/commit/1e50f549ef135d7494c9260c4638c6054fe06c74)) + + +### Chores + +* **docs:** fix maxium typo ([#69](https://github.com/openai/openai-go/issues/69)) ([3a5c6a6](https://github.com/openai/openai-go/commit/3a5c6a657ac8d821e95e07b442f00140b5332c93)) + ## 0.1.0-alpha.23 (2024-09-29) Full Changelog: [v0.1.0-alpha.22...v0.1.0-alpha.23](https://github.com/openai/openai-go/compare/v0.1.0-alpha.22...v0.1.0-alpha.23) diff --git a/internal/version.go b/internal/version.go index 9c3c699b..1072dcb8 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.23" // x-release-please-version +const PackageVersion = "0.1.0-alpha.24" // x-release-please-version From b1ae4f97969d0d60718e500b50030d29c84adfce Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:52:53 +0000 Subject: [PATCH 4/4] release: 0.1.0-alpha.24 --- .release-please-manifest.json | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1c0bb885..380b6f91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.23" + ".": "0.1.0-alpha.24" } \ No newline at end of file diff --git a/README.md b/README.md index 820ec326..bb776b4e 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.23' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.24' ```