mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
feat: add midjourney price log
This commit is contained in:
parent
705171e495
commit
a3921ea54d
@ -103,13 +103,15 @@ func UpdateModelPriceByJSONString(jsonStr string) error {
|
|||||||
return json.Unmarshal([]byte(jsonStr), &ModelPrice)
|
return json.Unmarshal([]byte(jsonStr), &ModelPrice)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetModelPrice(name string) float64 {
|
func GetModelPrice(name string, printErr bool) float64 {
|
||||||
if strings.HasPrefix(name, "gpt-4-gizmo") {
|
if strings.HasPrefix(name, "gpt-4-gizmo") {
|
||||||
name = "gpt-4-gizmo-*"
|
name = "gpt-4-gizmo-*"
|
||||||
}
|
}
|
||||||
price, ok := ModelPrice[name]
|
price, ok := ModelPrice[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
//SysError("model price not found: " + name)
|
if printErr {
|
||||||
|
SysError("model price not found: " + name)
|
||||||
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
|
@ -392,7 +392,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
requestBody = c.Request.Body
|
requestBody = c.Request.Body
|
||||||
}
|
}
|
||||||
mjAction := "mj_" + strings.ToLower(midjRequest.Action)
|
mjAction := "mj_" + strings.ToLower(midjRequest.Action)
|
||||||
modelPrice := common.GetModelPrice(mjAction)
|
modelPrice := common.GetModelPrice(mjAction, true)
|
||||||
// 如果没有配置价格,则使用默认价格
|
// 如果没有配置价格,则使用默认价格
|
||||||
if modelPrice == -1 {
|
if modelPrice == -1 {
|
||||||
defaultPrice, ok := DefaultModelPrice[mjAction]
|
defaultPrice, ok := DefaultModelPrice[mjAction]
|
||||||
|
@ -232,7 +232,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
case RelayModeModerations:
|
case RelayModeModerations:
|
||||||
promptTokens = countTokenInput(textRequest.Input, textRequest.Model)
|
promptTokens = countTokenInput(textRequest.Input, textRequest.Model)
|
||||||
}
|
}
|
||||||
modelPrice := common.GetModelPrice(textRequest.Model)
|
modelPrice := common.GetModelPrice(textRequest.Model, false)
|
||||||
groupRatio := common.GetGroupRatio(group)
|
groupRatio := common.GetGroupRatio(group)
|
||||||
|
|
||||||
var preConsumedQuota int
|
var preConsumedQuota int
|
||||||
|
Loading…
Reference in New Issue
Block a user