Fix usage
This commit is contained in:
parent
cae9dfa5fc
commit
d5ab5a8e7c
@ -165,11 +165,12 @@ func RequestAnthropic(model string, messages []Message, maxTokens int, temperatu
|
||||
|
||||
var usedModelInfo ModelInfo
|
||||
edgeClient.QuerySingle(edgeCtx, `
|
||||
Select ModelInfo {
|
||||
SELECT ModelInfo {
|
||||
inputPrice,
|
||||
outputPrice
|
||||
}
|
||||
FILTER .name = <str>$0
|
||||
FILTER .modelID = <str>$0
|
||||
LIMIT 1
|
||||
`, &usedModelInfo, model)
|
||||
|
||||
var inputCost float32 = float32(chatCompletionResponse.Usage.InputTokens) * usedModelInfo.InputPrice
|
||||
|
@ -172,11 +172,12 @@ func RequestGoogle(model string, messages []Message, temperature float64) (Opena
|
||||
|
||||
var usedModelInfo ModelInfo
|
||||
edgeClient.QuerySingle(edgeCtx, `
|
||||
Select ModelInfo {
|
||||
SELECT ModelInfo {
|
||||
inputPrice,
|
||||
outputPrice
|
||||
}
|
||||
Filter ModelInfo.model = <str>$0
|
||||
FILTER .modelID = <str>$0
|
||||
LIMIT 1
|
||||
`, &usedModelInfo, model)
|
||||
|
||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
||||
|
@ -163,11 +163,12 @@ func RequestGroq(model string, messages []Message, temperature float64) (GroqCha
|
||||
|
||||
var usedModelInfo ModelInfo
|
||||
edgeClient.QuerySingle(edgeCtx, `
|
||||
Select ModelInfo {
|
||||
SELECT ModelInfo {
|
||||
inputPrice,
|
||||
outputPrice
|
||||
}
|
||||
Filter ModelInfo.model = <str>$0
|
||||
FILTER .modelID = <str>$0
|
||||
LIMIT 1
|
||||
`, &usedModelInfo, model)
|
||||
|
||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
||||
|
@ -170,11 +170,12 @@ func RequestMistral(model string, messages []Message, temperature float64) (Mist
|
||||
|
||||
var usedModelInfo ModelInfo
|
||||
edgeClient.QuerySingle(edgeCtx, `
|
||||
Select ModelInfo {
|
||||
SELECT ModelInfo {
|
||||
inputPrice,
|
||||
outputPrice
|
||||
}
|
||||
Filter ModelInfo.model = <str>$0
|
||||
FILTER .modelID = <str>$0
|
||||
LIMIT 1
|
||||
`, &usedModelInfo, model)
|
||||
|
||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
||||
|
@ -162,13 +162,17 @@ func RequestOpenai(model string, messages []Message, temperature float64) (Opena
|
||||
}
|
||||
|
||||
var usedModelInfo ModelInfo
|
||||
edgeClient.QuerySingle(edgeCtx, `
|
||||
Select ModelInfo {
|
||||
err = edgeClient.QuerySingle(edgeCtx, `
|
||||
SELECT ModelInfo {
|
||||
inputPrice,
|
||||
outputPrice
|
||||
}
|
||||
Filter ModelInfo.model = <str>$0
|
||||
FILTER .modelID = <str>$0
|
||||
LIMIT 1
|
||||
`, &usedModelInfo, model)
|
||||
if err != nil {
|
||||
return OpenaiChatCompletionResponse{}, fmt.Errorf("error getting model info: %w", err)
|
||||
}
|
||||
|
||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
||||
var outputCost float32 = float32(chatCompletionResponse.Usage.CompletionTokens) * usedModelInfo.OutputPrice
|
||||
|
Loading…
x
Reference in New Issue
Block a user