From c3000c401c762acb7c755be894a80d22c91b606b Mon Sep 17 00:00:00 2001 From: Sakurasan <1173092237@qq.com> Date: Sun, 2 Jul 2023 21:00:58 +0800 Subject: [PATCH] =?UTF-8?q?update:=E8=AE=A1=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/router.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/router/router.go b/router/router.go index 000b52d..f4726af 100644 --- a/router/router.go +++ b/router/router.go @@ -638,12 +638,24 @@ func Cost(model string, promptCount, completionCount int) float64 { completion = float64(completionCount) switch model { - case "gpt-3.5-turbo", "gpt-3.5-turbo-0301": + case "gpt-3.5-turbo-0301": cost = 0.002 * float64((prompt+completion)/1000) - case "gpt-4", "gpt-4-0314": + case "gpt-3.5-turbo", "gpt-3.5-turbo-0613": + cost = 0.0015*float64((prompt)/1000) + 0.002*float64(completion/1000) + case "gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613": + cost = 0.003*float64((prompt)/1000) + 0.004*float64(completion/1000) + case "gpt-4", "gpt-4-0613", "gpt-4-0314": cost = 0.03*float64(prompt/1000) + 0.06*float64(completion/1000) - case "gpt-4-32k", "gpt-4-32k-0314": + case "gpt-4-32k", "gpt-4-32k-0613": cost = 0.06*float64(prompt/1000) + 0.12*float64(completion/1000) + default: + if strings.Contains(model, "gpt-3.5-turbo") { + cost = 0.003 * float64((prompt+completion)/1000) + } else if strings.Contains(model, "gpt-4") { + cost = 0.06 * float64((prompt+completion)/1000) + } else { + cost = 0.002 * float64((prompt+completion)/1000) + } } return cost }