feat: support gpt-5.1 prompt_cache_retention (#2228)

This commit is contained in:
Seefs
2025-11-15 13:32:24 +08:00
committed by GitHub
parent fd38abd562
commit e07347ac53
2 changed files with 20 additions and 17 deletions

1
.gitignore vendored
View File

@@ -16,6 +16,7 @@ new-api
tiktoken_cache tiktoken_cache
.eslintcache .eslintcache
.gocache .gocache
.cache
electron/node_modules electron/node_modules
electron/dist electron/dist

View File

@@ -66,10 +66,11 @@ type GeneralOpenAIRequest struct {
// 注意:默认过滤此字段以保护用户隐私,但过滤后可能导致 Codex 无法正常使用 // 注意:默认过滤此字段以保护用户隐私,但过滤后可能导致 Codex 无法正常使用
Store json.RawMessage `json:"store,omitempty"` Store json.RawMessage `json:"store,omitempty"`
// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field // Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field
PromptCacheKey string `json:"prompt_cache_key,omitempty"` PromptCacheKey string `json:"prompt_cache_key,omitempty"`
LogitBias json.RawMessage `json:"logit_bias,omitempty"` PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"` LogitBias json.RawMessage `json:"logit_bias,omitempty"`
Prediction json.RawMessage `json:"prediction,omitempty"` Metadata json.RawMessage `json:"metadata,omitempty"`
Prediction json.RawMessage `json:"prediction,omitempty"`
// gemini // gemini
ExtraBody json.RawMessage `json:"extra_body,omitempty"` ExtraBody json.RawMessage `json:"extra_body,omitempty"`
//xai //xai
@@ -798,19 +799,20 @@ type OpenAIResponsesRequest struct {
PreviousResponseID string `json:"previous_response_id,omitempty"` PreviousResponseID string `json:"previous_response_id,omitempty"`
Reasoning *Reasoning `json:"reasoning,omitempty"` Reasoning *Reasoning `json:"reasoning,omitempty"`
// 服务层级字段,用于指定 API 服务等级。允许透传可能导致实际计费高于预期,默认应过滤 // 服务层级字段,用于指定 API 服务等级。允许透传可能导致实际计费高于预期,默认应过滤
ServiceTier string `json:"service_tier,omitempty"` ServiceTier string `json:"service_tier,omitempty"`
Store json.RawMessage `json:"store,omitempty"` Store json.RawMessage `json:"store,omitempty"`
PromptCacheKey json.RawMessage `json:"prompt_cache_key,omitempty"` PromptCacheKey json.RawMessage `json:"prompt_cache_key,omitempty"`
Stream bool `json:"stream,omitempty"` PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
Temperature float64 `json:"temperature,omitempty"` Stream bool `json:"stream,omitempty"`
Text json.RawMessage `json:"text,omitempty"` Temperature float64 `json:"temperature,omitempty"`
ToolChoice json.RawMessage `json:"tool_choice,omitempty"` Text json.RawMessage `json:"text,omitempty"`
Tools json.RawMessage `json:"tools,omitempty"` // 需要处理的参数很少MCP 参数太多不确定,所以用 map ToolChoice json.RawMessage `json:"tool_choice,omitempty"`
TopP float64 `json:"top_p,omitempty"` Tools json.RawMessage `json:"tools,omitempty"` // 需要处理的参数很少MCP 参数太多不确定,所以用 map
Truncation string `json:"truncation,omitempty"` TopP float64 `json:"top_p,omitempty"`
User string `json:"user,omitempty"` Truncation string `json:"truncation,omitempty"`
MaxToolCalls uint `json:"max_tool_calls,omitempty"` User string `json:"user,omitempty"`
Prompt json.RawMessage `json:"prompt,omitempty"` MaxToolCalls uint `json:"max_tool_calls,omitempty"`
Prompt json.RawMessage `json:"prompt,omitempty"`
} }
func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta { func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta {