mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-09 02:03:42 +08:00
fix: update cost calculation to use QuotaPerUsd for search context sizes
This commit is contained in:
@@ -213,11 +213,11 @@ func (a *Adaptor) DoResponse(c *gin.Context,
|
||||
case strings.HasPrefix(meta.ActualModelName, "gpt-4o-search"):
|
||||
switch searchContextSize {
|
||||
case "low":
|
||||
usage.ToolsCost += int64(math.Ceil(30 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(30 / 1000 * ratio.QuotaPerUsd))
|
||||
case "medium":
|
||||
usage.ToolsCost += int64(math.Ceil(35 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(35 / 1000 * ratio.QuotaPerUsd))
|
||||
case "high":
|
||||
usage.ToolsCost += int64(math.Ceil(40 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(40 / 1000 * ratio.QuotaPerUsd))
|
||||
default:
|
||||
return nil, ErrorWrapper(
|
||||
errors.Errorf("invalid search context size %q", searchContextSize),
|
||||
@@ -227,11 +227,11 @@ func (a *Adaptor) DoResponse(c *gin.Context,
|
||||
case strings.HasPrefix(meta.ActualModelName, "gpt-4o-mini-search"):
|
||||
switch searchContextSize {
|
||||
case "low":
|
||||
usage.ToolsCost += int64(math.Ceil(25 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(25 / 1000 * ratio.QuotaPerUsd))
|
||||
case "medium":
|
||||
usage.ToolsCost += int64(math.Ceil(27.5 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(27.5 / 1000 * ratio.QuotaPerUsd))
|
||||
case "high":
|
||||
usage.ToolsCost += int64(math.Ceil(30 / 1000 * ratio.USD))
|
||||
usage.ToolsCost += int64(math.Ceil(30 / 1000 * ratio.QuotaPerUsd))
|
||||
default:
|
||||
return nil, ErrorWrapper(
|
||||
errors.Errorf("invalid search context size %q", searchContextSize),
|
||||
|
||||
Reference in New Issue
Block a user