From d16fc7f3c8b872340a45be96898809bb1bdb046a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:06:54 +0000 Subject: [PATCH] feat(api): Realtime API token_limits, Hybrid searching ranking options --- .stats.yml | 6 +- aliases.go | 8 +++ conversations/aliases.go | 8 +++ image.go | 10 ++- realtime/aliases.go | 8 +++ realtime/clientsecret.go | 15 +++- realtime/realtime.go | 82 ++++++++++++++++++++-- responses/aliases.go | 8 +++ responses/response.go | 132 +++++++++++++++++++++++++++-------- shared/shared.go | 6 ++ vectorstorefilebatch.go | 68 ++++++++++++++++-- vectorstorefilebatch_test.go | 13 +++- video.go | 3 + webhooks/aliases.go | 8 +++ 14 files changed, 325 insertions(+), 50 deletions(-) diff --git a/.stats.yml b/.stats.yml index d52cd21..24a53bc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 123 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f68f718cd45ac3f9336603601bccc38a718af44d0b26601031de3d0a71b7ce2f.yml -openapi_spec_hash: 1560717860bba4105936647dde8f618d -config_hash: 50ee3382a63c021a9f821a935950e926 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-3c5d1593d7c6f2b38a7d78d7906041465ee9d6e9022f0651e1da194654488108.yml +openapi_spec_hash: 0a4d8ad2469823ce24a3fd94f23f1c2b +config_hash: 032995825500a503a76da119f5354905 diff --git a/aliases.go b/aliases.go index 3a8e563..c390bc3 100644 --- a/aliases.go +++ b/aliases.go @@ -294,9 +294,13 @@ type CompoundFilterParam = shared.CompoundFilterParam // This is an alias to an internal type. type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatText = shared.CustomToolInputFormatText +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar @@ -305,9 +309,13 @@ type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar // This is an alias to an internal type. type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam diff --git a/conversations/aliases.go b/conversations/aliases.go index a790e59..47bf438 100644 --- a/conversations/aliases.go +++ b/conversations/aliases.go @@ -294,9 +294,13 @@ type CompoundFilterParam = shared.CompoundFilterParam // This is an alias to an internal type. type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatText = shared.CustomToolInputFormatText +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar @@ -305,9 +309,13 @@ type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar // This is an alias to an internal type. type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam diff --git a/image.go b/image.go index a27d4d1..9c63ddc 100644 --- a/image.go +++ b/image.go @@ -960,7 +960,10 @@ type ImageEditParams struct { // // Any of "transparent", "opaque", "auto". Background ImageEditParamsBackground `json:"background,omitzero"` - // Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`. + // Control how much effort the model will exert to match the style and features, + // especially facial features, of input images. This parameter is only supported + // for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and + // `low`. Defaults to `low`. // // Any of "high", "low". InputFidelity ImageEditParamsInputFidelity `json:"input_fidelity,omitzero"` @@ -1059,7 +1062,10 @@ const ( ImageEditParamsBackgroundAuto ImageEditParamsBackground = "auto" ) -// Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`. +// Control how much effort the model will exert to match the style and features, +// especially facial features, of input images. This parameter is only supported +// for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and +// `low`. Defaults to `low`. type ImageEditParamsInputFidelity string const ( diff --git a/realtime/aliases.go b/realtime/aliases.go index 1a4d6fe..148a7a7 100644 --- a/realtime/aliases.go +++ b/realtime/aliases.go @@ -294,9 +294,13 @@ type CompoundFilterParam = shared.CompoundFilterParam // This is an alias to an internal type. type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatText = shared.CustomToolInputFormatText +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar @@ -305,9 +309,13 @@ type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar // This is an alias to an internal type. type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam diff --git a/realtime/clientsecret.go b/realtime/clientsecret.go index aa4f219..cf0ec56 100644 --- a/realtime/clientsecret.go +++ b/realtime/clientsecret.go @@ -124,8 +124,19 @@ type RealtimeSessionCreateResponse struct { // `auto` will create a trace for the session with default values for the workflow // name, group id, and metadata. Tracing RealtimeSessionCreateResponseTracingUnion `json:"tracing,nullable"` - // Controls how the realtime conversation is truncated prior to model inference. - // The default is `auto`. + // When the number of tokens in a conversation exceeds the model's input token + // limit, the conversation be truncated, meaning messages (starting from the + // oldest) will not be included in the model's context. A 32k context model with + // 4,096 max output tokens can only include 28,224 tokens in the context before + // truncation occurs. Clients can configure truncation behavior to truncate with a + // lower max token limit, which is an effective way to control token usage and + // cost. Truncation will reduce the number of cached tokens on the next turn + // (busting the cache), since messages are dropped from the beginning of the + // context. However, clients can also configure truncation to retain messages up to + // a fraction of the maximum context size, which will reduce the need for future + // truncations and thus improve the cache rate. Truncation can be disabled + // entirely, which means the server will never truncate but would instead return an + // error if the conversation exceeds the model's input token limit. Truncation RealtimeTruncationUnion `json:"truncation"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/realtime/realtime.go b/realtime/realtime.go index a92a1b9..0b73fc2 100644 --- a/realtime/realtime.go +++ b/realtime/realtime.go @@ -853,8 +853,19 @@ type RealtimeSessionCreateRequestParam struct { ToolChoice RealtimeToolChoiceConfigUnionParam `json:"tool_choice,omitzero"` // Tools available to the model. Tools RealtimeToolsConfigParam `json:"tools,omitzero"` - // Controls how the realtime conversation is truncated prior to model inference. - // The default is `auto`. + // When the number of tokens in a conversation exceeds the model's input token + // limit, the conversation be truncated, meaning messages (starting from the + // oldest) will not be included in the model's context. A 32k context model with + // 4,096 max output tokens can only include 28,224 tokens in the context before + // truncation occurs. Clients can configure truncation behavior to truncate with a + // lower max token limit, which is an effective way to control token usage and + // cost. Truncation will reduce the number of cached tokens on the next turn + // (busting the cache), since messages are dropped from the beginning of the + // context. However, clients can also configure truncation to retain messages up to + // a fraction of the maximum context size, which will reduce the need for future + // truncations and thus improve the cache rate. Truncation can be disabled + // entirely, which means the server will never truncate but would instead return an + // error if the conversation exceeds the model's input token limit. Truncation RealtimeTruncationUnionParam `json:"truncation,omitzero"` // The type of session to create. Always `realtime` for the Realtime API. // @@ -1697,10 +1708,13 @@ type RealtimeTruncationUnion struct { RetentionRatio float64 `json:"retention_ratio"` // This field is from variant [RealtimeTruncationRetentionRatio]. Type constant.RetentionRatio `json:"type"` - JSON struct { + // This field is from variant [RealtimeTruncationRetentionRatio]. + TokenLimits RealtimeTruncationRetentionRatioTokenLimits `json:"token_limits"` + JSON struct { OfRealtimeTruncationStrategy respjson.Field RetentionRatio respjson.Field Type respjson.Field + TokenLimits respjson.Field raw string } `json:"-"` } @@ -1778,15 +1792,21 @@ func (u *RealtimeTruncationUnionParam) asAny() any { // input token limit. This allows you to amortize truncations across multiple // turns, which can help improve cached token usage. type RealtimeTruncationRetentionRatio struct { - // Fraction of post-instruction conversation tokens to retain (0.0 - 1.0) when the - // conversation exceeds the input token limit. + // Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when + // the conversation exceeds the input token limit. Setting this to `0.8` means that + // messages will be dropped until 80% of the maximum allowed tokens are used. This + // helps reduce the frequency of truncations and improve cache rates. RetentionRatio float64 `json:"retention_ratio,required"` // Use retention ratio truncation. Type constant.RetentionRatio `json:"type,required"` + // Optional custom token limits for this truncation strategy. If not provided, the + // model's default token limits will be used. + TokenLimits RealtimeTruncationRetentionRatioTokenLimits `json:"token_limits"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { RetentionRatio respjson.Field Type respjson.Field + TokenLimits respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1808,15 +1828,43 @@ func (r RealtimeTruncationRetentionRatio) ToParam() RealtimeTruncationRetentionR return param.Override[RealtimeTruncationRetentionRatioParam](json.RawMessage(r.RawJSON())) } +// Optional custom token limits for this truncation strategy. If not provided, the +// model's default token limits will be used. +type RealtimeTruncationRetentionRatioTokenLimits struct { + // Maximum tokens allowed in the conversation after instructions (which including + // tool definitions). For example, setting this to 5,000 would mean that truncation + // would occur when the conversation exceeds 5,000 tokens after instructions. This + // cannot be higher than the model's context window size minus the maximum output + // tokens. + PostInstructions int64 `json:"post_instructions"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + PostInstructions respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r RealtimeTruncationRetentionRatioTokenLimits) RawJSON() string { return r.JSON.raw } +func (r *RealtimeTruncationRetentionRatioTokenLimits) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // Retain a fraction of the conversation tokens when the conversation exceeds the // input token limit. This allows you to amortize truncations across multiple // turns, which can help improve cached token usage. // // The properties RetentionRatio, Type are required. type RealtimeTruncationRetentionRatioParam struct { - // Fraction of post-instruction conversation tokens to retain (0.0 - 1.0) when the - // conversation exceeds the input token limit. + // Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when + // the conversation exceeds the input token limit. Setting this to `0.8` means that + // messages will be dropped until 80% of the maximum allowed tokens are used. This + // helps reduce the frequency of truncations and improve cache rates. RetentionRatio float64 `json:"retention_ratio,required"` + // Optional custom token limits for this truncation strategy. If not provided, the + // model's default token limits will be used. + TokenLimits RealtimeTruncationRetentionRatioTokenLimitsParam `json:"token_limits,omitzero"` // Use retention ratio truncation. // // This field can be elided, and will marshal its zero value as "retention_ratio". @@ -1831,3 +1879,23 @@ func (r RealtimeTruncationRetentionRatioParam) MarshalJSON() (data []byte, err e func (r *RealtimeTruncationRetentionRatioParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +// Optional custom token limits for this truncation strategy. If not provided, the +// model's default token limits will be used. +type RealtimeTruncationRetentionRatioTokenLimitsParam struct { + // Maximum tokens allowed in the conversation after instructions (which including + // tool definitions). For example, setting this to 5,000 would mean that truncation + // would occur when the conversation exceeds 5,000 tokens after instructions. This + // cannot be higher than the model's context window size minus the maximum output + // tokens. + PostInstructions param.Opt[int64] `json:"post_instructions,omitzero"` + paramObj +} + +func (r RealtimeTruncationRetentionRatioTokenLimitsParam) MarshalJSON() (data []byte, err error) { + type shadow RealtimeTruncationRetentionRatioTokenLimitsParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *RealtimeTruncationRetentionRatioTokenLimitsParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/responses/aliases.go b/responses/aliases.go index 06ebfd0..28e825f 100644 --- a/responses/aliases.go +++ b/responses/aliases.go @@ -294,9 +294,13 @@ type CompoundFilterParam = shared.CompoundFilterParam // This is an alias to an internal type. type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatText = shared.CustomToolInputFormatText +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar @@ -305,9 +309,13 @@ type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar // This is an alias to an internal type. type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam diff --git a/responses/response.go b/responses/response.go index 894ac11..3acb930 100644 --- a/responses/response.go +++ b/responses/response.go @@ -522,6 +522,9 @@ func (r *FileSearchToolFiltersUnion) UnmarshalJSON(data []byte) error { // Ranking options for search. type FileSearchToolRankingOptions struct { + // Weights that control how reciprocal rank fusion balances semantic embedding + // matches versus sparse keyword matches when hybrid search is enabled. + HybridSearch FileSearchToolRankingOptionsHybridSearch `json:"hybrid_search"` // The ranker to use for the file search. // // Any of "auto", "default-2024-11-15". @@ -532,6 +535,7 @@ type FileSearchToolRankingOptions struct { ScoreThreshold float64 `json:"score_threshold"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + HybridSearch respjson.Field Ranker respjson.Field ScoreThreshold respjson.Field ExtraFields map[string]respjson.Field @@ -545,6 +549,28 @@ func (r *FileSearchToolRankingOptions) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// Weights that control how reciprocal rank fusion balances semantic embedding +// matches versus sparse keyword matches when hybrid search is enabled. +type FileSearchToolRankingOptionsHybridSearch struct { + // The weight of the embedding in the reciprocal ranking fusion. + EmbeddingWeight float64 `json:"embedding_weight,required"` + // The weight of the text in the reciprocal ranking fusion. + TextWeight float64 `json:"text_weight,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EmbeddingWeight respjson.Field + TextWeight respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r FileSearchToolRankingOptionsHybridSearch) RawJSON() string { return r.JSON.raw } +func (r *FileSearchToolRankingOptionsHybridSearch) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // A tool that searches for relevant content from uploaded files. Learn more about // the // [file search tool](https://platform.openai.com/docs/guides/tools-file-search). @@ -640,6 +666,9 @@ type FileSearchToolRankingOptionsParam struct { // closer to 1 will attempt to return only the most relevant results, but may // return fewer results. ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"` + // Weights that control how reciprocal rank fusion balances semantic embedding + // matches versus sparse keyword matches when hybrid search is enabled. + HybridSearch FileSearchToolRankingOptionsHybridSearchParam `json:"hybrid_search,omitzero"` // The ranker to use for the file search. // // Any of "auto", "default-2024-11-15". @@ -661,6 +690,26 @@ func init() { ) } +// Weights that control how reciprocal rank fusion balances semantic embedding +// matches versus sparse keyword matches when hybrid search is enabled. +// +// The properties EmbeddingWeight, TextWeight are required. +type FileSearchToolRankingOptionsHybridSearchParam struct { + // The weight of the embedding in the reciprocal ranking fusion. + EmbeddingWeight float64 `json:"embedding_weight,required"` + // The weight of the text in the reciprocal ranking fusion. + TextWeight float64 `json:"text_weight,required"` + paramObj +} + +func (r FileSearchToolRankingOptionsHybridSearchParam) MarshalJSON() (data []byte, err error) { + type shadow FileSearchToolRankingOptionsHybridSearchParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *FileSearchToolRankingOptionsHybridSearchParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + func init() { apijson.RegisterUnion[ResponseCodeInterpreterToolCallOutputUnionParam]( "type", @@ -3038,18 +3087,18 @@ func (r *ResponseContentPartAddedEvent) UnmarshalJSON(data []byte) error { type ResponseContentPartAddedEventPartUnion struct { // This field is from variant [ResponseOutputText]. Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"` - Text string `json:"text"` - // Any of "output_text", "refusal", "reasoning_text". - Type string `json:"type"` // This field is from variant [ResponseOutputText]. Logprobs []ResponseOutputTextLogprob `json:"logprobs"` + Text string `json:"text"` + // Any of "output_text", "refusal", "reasoning_text". + Type string `json:"type"` // This field is from variant [ResponseOutputRefusal]. Refusal string `json:"refusal"` JSON struct { Annotations respjson.Field + Logprobs respjson.Field Text respjson.Field Type respjson.Field - Logprobs respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -3174,18 +3223,18 @@ func (r *ResponseContentPartDoneEvent) UnmarshalJSON(data []byte) error { type ResponseContentPartDoneEventPartUnion struct { // This field is from variant [ResponseOutputText]. Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"` - Text string `json:"text"` - // Any of "output_text", "refusal", "reasoning_text". - Type string `json:"type"` // This field is from variant [ResponseOutputText]. Logprobs []ResponseOutputTextLogprob `json:"logprobs"` + Text string `json:"text"` + // Any of "output_text", "refusal", "reasoning_text". + Type string `json:"type"` // This field is from variant [ResponseOutputRefusal]. Refusal string `json:"refusal"` JSON struct { Annotations respjson.Field + Logprobs respjson.Field Text respjson.Field Type respjson.Field - Logprobs respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -10203,18 +10252,18 @@ type ResponseOutputMessageContentUnion struct { // This field is from variant [ResponseOutputText]. Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"` // This field is from variant [ResponseOutputText]. + Logprobs []ResponseOutputTextLogprob `json:"logprobs"` + // This field is from variant [ResponseOutputText]. Text string `json:"text"` // Any of "output_text", "refusal". Type string `json:"type"` - // This field is from variant [ResponseOutputText]. - Logprobs []ResponseOutputTextLogprob `json:"logprobs"` // This field is from variant [ResponseOutputRefusal]. Refusal string `json:"refusal"` JSON struct { Annotations respjson.Field + Logprobs respjson.Field Text respjson.Field Type respjson.Field - Logprobs respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -10341,17 +10390,17 @@ func (u ResponseOutputMessageContentUnionParam) GetAnnotations() []ResponseOutpu } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseOutputMessageContentUnionParam) GetText() *string { +func (u ResponseOutputMessageContentUnionParam) GetLogprobs() []ResponseOutputTextLogprobParam { if vt := u.OfOutputText; vt != nil { - return &vt.Text + return vt.Logprobs } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseOutputMessageContentUnionParam) GetLogprobs() []ResponseOutputTextLogprobParam { +func (u ResponseOutputMessageContentUnionParam) GetText() *string { if vt := u.OfOutputText; vt != nil { - return vt.Logprobs + return &vt.Text } return nil } @@ -10431,17 +10480,17 @@ func (r *ResponseOutputRefusalParam) UnmarshalJSON(data []byte) error { type ResponseOutputText struct { // The annotations of the text output. Annotations []ResponseOutputTextAnnotationUnion `json:"annotations,required"` + Logprobs []ResponseOutputTextLogprob `json:"logprobs,required"` // The text output from the model. Text string `json:"text,required"` // The type of the output text. Always `output_text`. - Type constant.OutputText `json:"type,required"` - Logprobs []ResponseOutputTextLogprob `json:"logprobs"` + Type constant.OutputText `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Annotations respjson.Field + Logprobs respjson.Field Text respjson.Field Type respjson.Field - Logprobs respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -10725,13 +10774,13 @@ func (r *ResponseOutputTextLogprobTopLogprob) UnmarshalJSON(data []byte) error { // A text output from the model. // -// The properties Annotations, Text, Type are required. +// The properties Annotations, Logprobs, Text, Type are required. type ResponseOutputTextParam struct { // The annotations of the text output. Annotations []ResponseOutputTextAnnotationUnionParam `json:"annotations,omitzero,required"` + Logprobs []ResponseOutputTextLogprobParam `json:"logprobs,omitzero,required"` // The text output from the model. - Text string `json:"text,required"` - Logprobs []ResponseOutputTextLogprobParam `json:"logprobs,omitzero"` + Text string `json:"text,required"` // The type of the output text. Always `output_text`. // // This field can be elided, and will marshal its zero value as "output_text". @@ -12446,19 +12495,19 @@ type ResponseStreamEventUnionPart struct { // This field is from variant [ResponseContentPartAddedEventPartUnion], // [ResponseContentPartDoneEventPartUnion]. Annotations []ResponseOutputTextAnnotationUnion `json:"annotations"` - Text string `json:"text"` - Type string `json:"type"` // This field is from variant [ResponseContentPartAddedEventPartUnion], // [ResponseContentPartDoneEventPartUnion]. Logprobs []ResponseOutputTextLogprob `json:"logprobs"` + Text string `json:"text"` + Type string `json:"type"` // This field is from variant [ResponseContentPartAddedEventPartUnion], // [ResponseContentPartDoneEventPartUnion]. Refusal string `json:"refusal"` JSON struct { Annotations respjson.Field + Logprobs respjson.Field Text respjson.Field Type respjson.Field - Logprobs respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -13426,11 +13475,15 @@ type ToolCodeInterpreterContainerUnion struct { // This field is from variant // [ToolCodeInterpreterContainerCodeInterpreterContainerAuto]. FileIDs []string `json:"file_ids"` - JSON struct { - OfString respjson.Field - Type respjson.Field - FileIDs respjson.Field - raw string + // This field is from variant + // [ToolCodeInterpreterContainerCodeInterpreterContainerAuto]. + MemoryLimit string `json:"memory_limit"` + JSON struct { + OfString respjson.Field + Type respjson.Field + FileIDs respjson.Field + MemoryLimit respjson.Field + raw string } `json:"-"` } @@ -13458,10 +13511,13 @@ type ToolCodeInterpreterContainerCodeInterpreterContainerAuto struct { Type constant.Auto `json:"type,required"` // An optional list of uploaded files to make available to your code. FileIDs []string `json:"file_ids"` + // Any of "1g", "4g", "16g", "64g". + MemoryLimit string `json:"memory_limit,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Type respjson.Field FileIDs respjson.Field + MemoryLimit respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -13482,7 +13538,10 @@ type ToolImageGeneration struct { // // Any of "transparent", "opaque", "auto". Background string `json:"background"` - // Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`. + // Control how much effort the model will exert to match the style and features, + // especially facial features, of input images. This parameter is only supported + // for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and + // `low`. Defaults to `low`. // // Any of "high", "low". InputFidelity string `json:"input_fidelity,nullable"` @@ -14372,6 +14431,8 @@ func (u *ToolCodeInterpreterContainerUnionParam) asAny() any { // // The property Type is required. type ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam struct { + // Any of "1g", "4g", "16g", "64g". + MemoryLimit string `json:"memory_limit,omitzero"` // An optional list of uploaded files to make available to your code. FileIDs []string `json:"file_ids,omitzero"` // Always `auto`. @@ -14389,6 +14450,12 @@ func (r *ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam) Unmarsha return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam]( + "memory_limit", "1g", "4g", "16g", "64g", + ) +} + // A tool that generates images using a model like `gpt-image-1`. // // The property Type is required. @@ -14398,7 +14465,10 @@ type ToolImageGenerationParam struct { // Number of partial images to generate in streaming mode, from 0 (default value) // to 3. PartialImages param.Opt[int64] `json:"partial_images,omitzero"` - // Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`. + // Control how much effort the model will exert to match the style and features, + // especially facial features, of input images. This parameter is only supported + // for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and + // `low`. Defaults to `low`. // // Any of "high", "low". InputFidelity string `json:"input_fidelity,omitzero"` diff --git a/shared/shared.go b/shared/shared.go index b99c9c9..f794c2a 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -470,6 +470,7 @@ func (r CustomToolInputFormatUnion) ToParam() CustomToolInputFormatUnionParam { return param.Override[CustomToolInputFormatUnionParam](json.RawMessage(r.RawJSON())) } +// Unconstrained free-form text. type CustomToolInputFormatText struct { // Unconstrained text format. Always `text`. Type constant.Text `json:"type,required"` @@ -489,6 +490,7 @@ func (r *CustomToolInputFormatText) UnmarshalJSON(data []byte) error { func (CustomToolInputFormatText) implCustomToolInputFormatUnion() {} +// A grammar defined by the user. type CustomToolInputFormatGrammar struct { // The grammar definition. Definition string `json:"definition,required"` @@ -588,6 +590,8 @@ func NewCustomToolInputFormatTextParam() CustomToolInputFormatTextParam { } } +// Unconstrained free-form text. +// // This struct has a constant value, construct it with // [NewCustomToolInputFormatTextParam]. type CustomToolInputFormatTextParam struct { @@ -604,6 +608,8 @@ func (r *CustomToolInputFormatTextParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// A grammar defined by the user. +// // The properties Definition, Syntax, Type are required. type CustomToolInputFormatGrammarParam struct { // The grammar definition. diff --git a/vectorstorefilebatch.go b/vectorstorefilebatch.go index f3fd0fa..9ba50ec 100644 --- a/vectorstorefilebatch.go +++ b/vectorstorefilebatch.go @@ -258,10 +258,6 @@ const ( ) type VectorStoreFileBatchNewParams struct { - // A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that - // the vector store should use. Useful for tools like `file_search` that can access - // files. - FileIDs []string `json:"file_ids,omitzero,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, and // querying for objects via API or the dashboard. Keys are strings with a maximum @@ -271,6 +267,16 @@ type VectorStoreFileBatchNewParams struct { // The chunking strategy used to chunk the file(s). If not set, will use the `auto` // strategy. Only applicable if `file_ids` is non-empty. ChunkingStrategy FileChunkingStrategyParamUnion `json:"chunking_strategy,omitzero"` + // A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that + // the vector store should use. Useful for tools like `file_search` that can access + // files. If `attributes` or `chunking_strategy` are provided, they will be applied + // to all files in the batch. Mutually exclusive with `files`. + FileIDs []string `json:"file_ids,omitzero"` + // A list of objects that each include a `file_id` plus optional `attributes` or + // `chunking_strategy`. Use this when you need to override metadata for specific + // files. The global `attributes` or `chunking_strategy` will be ignored and must + // be specified for each file. Mutually exclusive with `file_ids`. + Files []VectorStoreFileBatchNewParamsFile `json:"files,omitzero"` paramObj } @@ -310,6 +316,60 @@ func (u *VectorStoreFileBatchNewParamsAttributeUnion) asAny() any { return nil } +// The property FileID is required. +type VectorStoreFileBatchNewParamsFile struct { + // A [File](https://platform.openai.com/docs/api-reference/files) ID that the + // vector store should use. Useful for tools like `file_search` that can access + // files. + FileID string `json:"file_id,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, 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, booleans, or numbers. + Attributes map[string]VectorStoreFileBatchNewParamsFileAttributeUnion `json:"attributes,omitzero"` + // The chunking strategy used to chunk the file(s). If not set, will use the `auto` + // strategy. Only applicable if `file_ids` is non-empty. + ChunkingStrategy FileChunkingStrategyParamUnion `json:"chunking_strategy,omitzero"` + paramObj +} + +func (r VectorStoreFileBatchNewParamsFile) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreFileBatchNewParamsFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreFileBatchNewParamsFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type VectorStoreFileBatchNewParamsFileAttributeUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfFloat param.Opt[float64] `json:",omitzero,inline"` + OfBool param.Opt[bool] `json:",omitzero,inline"` + paramUnion +} + +func (u VectorStoreFileBatchNewParamsFileAttributeUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) +} +func (u *VectorStoreFileBatchNewParamsFileAttributeUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *VectorStoreFileBatchNewParamsFileAttributeUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfFloat) { + return &u.OfFloat.Value + } else if !param.IsOmitted(u.OfBool) { + return &u.OfBool.Value + } + return nil +} + type VectorStoreFileBatchListFilesParams struct { // A cursor for use in pagination. `after` is an object ID that defines your place // in the list. For instance, if you make a list request and receive 100 objects, diff --git a/vectorstorefilebatch_test.go b/vectorstorefilebatch_test.go index bb89335..0be6123 100644 --- a/vectorstorefilebatch_test.go +++ b/vectorstorefilebatch_test.go @@ -29,7 +29,6 @@ func TestVectorStoreFileBatchNewWithOptionalParams(t *testing.T) { context.TODO(), "vs_abc123", openai.VectorStoreFileBatchNewParams{ - FileIDs: []string{"string"}, Attributes: map[string]openai.VectorStoreFileBatchNewParamsAttributeUnion{ "foo": { OfString: openai.String("string"), @@ -38,6 +37,18 @@ func TestVectorStoreFileBatchNewWithOptionalParams(t *testing.T) { ChunkingStrategy: openai.FileChunkingStrategyParamUnion{ OfAuto: &openai.AutoFileChunkingStrategyParam{}, }, + FileIDs: []string{"string"}, + Files: []openai.VectorStoreFileBatchNewParamsFile{{ + FileID: "file_id", + Attributes: map[string]openai.VectorStoreFileBatchNewParamsFileAttributeUnion{ + "foo": { + OfString: openai.String("string"), + }, + }, + ChunkingStrategy: openai.FileChunkingStrategyParamUnion{ + OfAuto: &openai.AutoFileChunkingStrategyParam{}, + }, + }}, }, ) if err != nil { diff --git a/video.go b/video.go index 735f548..f7689d5 100644 --- a/video.go +++ b/video.go @@ -156,6 +156,8 @@ type Video struct { Object constant.Video `json:"object,required"` // Approximate completion percentage for the generation task. Progress int64 `json:"progress,required"` + // The prompt that was used to generate the video. + Prompt string `json:"prompt,required"` // Identifier of the source video if this video is a remix. RemixedFromVideoID string `json:"remixed_from_video_id,required"` // Duration of the generated clip in seconds. @@ -180,6 +182,7 @@ type Video struct { Model respjson.Field Object respjson.Field Progress respjson.Field + Prompt respjson.Field RemixedFromVideoID respjson.Field Seconds respjson.Field Size respjson.Field diff --git a/webhooks/aliases.go b/webhooks/aliases.go index 42b8546..82e5b51 100644 --- a/webhooks/aliases.go +++ b/webhooks/aliases.go @@ -294,9 +294,13 @@ type CompoundFilterParam = shared.CompoundFilterParam // This is an alias to an internal type. type CustomToolInputFormatUnion = shared.CustomToolInputFormatUnion +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatText = shared.CustomToolInputFormatText +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar @@ -305,9 +309,13 @@ type CustomToolInputFormatGrammar = shared.CustomToolInputFormatGrammar // This is an alias to an internal type. type CustomToolInputFormatUnionParam = shared.CustomToolInputFormatUnionParam +// Unconstrained free-form text. +// // This is an alias to an internal type. type CustomToolInputFormatTextParam = shared.CustomToolInputFormatTextParam +// A grammar defined by the user. +// // This is an alias to an internal type. type CustomToolInputFormatGrammarParam = shared.CustomToolInputFormatGrammarParam