feat: openai response /v1/response/compact (#2644)

* feat: openai response /v1/response/compact

* feat: /v1/response/compact bill

* feat: /v1/response/compact

* feat: /v1/responses/compact -> codex channel

* feat: /v1/responses/compact -> codex channel

* feat: /v1/responses/compact -> codex channel

* feat: codex channel default models

* feat: compact model price

* feat: /v1/responses/comapct test
This commit is contained in:
Seefs
2026-01-26 20:20:16 +08:00
committed by GitHub
parent d7d3a2f763
commit cc1da72d10
25 changed files with 483 additions and 42 deletions

View File

@@ -0,0 +1,13 @@
package ratio_setting
import "strings"
const CompactModelSuffix = "-openai-compact"
const CompactWildcardModelKey = "*" + CompactModelSuffix
func WithCompactModelSuffix(modelName string) string {
if strings.HasSuffix(modelName, CompactModelSuffix) {
return modelName
}
return modelName + CompactModelSuffix
}

View File

@@ -411,6 +411,17 @@ func GetModelPrice(name string, printErr bool) (float64, bool) {
name = FormatMatchingModelName(name)
if strings.HasSuffix(name, CompactModelSuffix) {
price, ok := modelPriceMap[CompactWildcardModelKey]
if !ok {
if printErr {
common.SysError("model price not found: " + name)
}
return -1, false
}
return price, true
}
price, ok := modelPriceMap[name]
if !ok {
if printErr {
@@ -448,6 +459,12 @@ func GetModelRatio(name string) (float64, bool, string) {
ratio, ok := modelRatioMap[name]
if !ok {
if strings.HasSuffix(name, CompactModelSuffix) {
if wildcardRatio, ok := modelRatioMap[CompactWildcardModelKey]; ok {
return wildcardRatio, true, name
}
return 0, true, name
}
return 37.5, operation_setting.SelfUseModeEnabled, name
}
return ratio, true, name