mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 00:46:42 +00:00
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:
13
setting/ratio_setting/compact_suffix.go
Normal file
13
setting/ratio_setting/compact_suffix.go
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user