fix: claude model ratio (#449)
* fix: Claude model ratio * chore: update implementation --------- Co-authored-by: JustSong <songquanpeng@foxmail.com>
This commit is contained in:
parent
49d1a63402
commit
23b1c63538
@ -1,6 +1,9 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import "encoding/json"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// ModelRatio
|
// ModelRatio
|
||||||
// https://platform.openai.com/docs/models/model-endpoint-compatibility
|
// https://platform.openai.com/docs/models/model-endpoint-compatibility
|
||||||
@ -38,8 +41,8 @@ var ModelRatio = map[string]float64{
|
|||||||
"text-moderation-stable": 0.1,
|
"text-moderation-stable": 0.1,
|
||||||
"text-moderation-latest": 0.1,
|
"text-moderation-latest": 0.1,
|
||||||
"dall-e": 8,
|
"dall-e": 8,
|
||||||
"claude-instant-1": 0.75,
|
"claude-instant-1": 0.815, // $1.63 / 1M tokens
|
||||||
"claude-2": 30,
|
"claude-2": 5.51, // $11.02 / 1M tokens
|
||||||
"ERNIE-Bot": 0.8572, // ¥0.012 / 1k tokens
|
"ERNIE-Bot": 0.8572, // ¥0.012 / 1k tokens
|
||||||
"ERNIE-Bot-turbo": 0.5715, // ¥0.008 / 1k tokens
|
"ERNIE-Bot-turbo": 0.5715, // ¥0.008 / 1k tokens
|
||||||
"Embedding-V1": 0.1429, // ¥0.002 / 1k tokens
|
"Embedding-V1": 0.1429, // ¥0.002 / 1k tokens
|
||||||
@ -73,3 +76,19 @@ func GetModelRatio(name string) float64 {
|
|||||||
}
|
}
|
||||||
return ratio
|
return ratio
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCompletionRatio(name string) float64 {
|
||||||
|
if strings.HasPrefix(name, "gpt-3.5") {
|
||||||
|
return 1.333333
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(name, "gpt-4") {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(name, "claude-instant-1") {
|
||||||
|
return 3.38
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(name, "claude-2") {
|
||||||
|
return 2.965517
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
@ -326,14 +326,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
go func() {
|
go func() {
|
||||||
if consumeQuota {
|
if consumeQuota {
|
||||||
quota := 0
|
quota := 0
|
||||||
completionRatio := 1.0
|
completionRatio := common.GetCompletionRatio(textRequest.Model)
|
||||||
if strings.HasPrefix(textRequest.Model, "gpt-3.5") {
|
|
||||||
completionRatio = 1.333333
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(textRequest.Model, "gpt-4") {
|
|
||||||
completionRatio = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
promptTokens = textResponse.Usage.PromptTokens
|
promptTokens = textResponse.Usage.PromptTokens
|
||||||
completionTokens = textResponse.Usage.CompletionTokens
|
completionTokens = textResponse.Usage.CompletionTokens
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user