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
|
var usedModelInfo ModelInfo
|
||||||
edgeClient.QuerySingle(edgeCtx, `
|
edgeClient.QuerySingle(edgeCtx, `
|
||||||
Select ModelInfo {
|
SELECT ModelInfo {
|
||||||
inputPrice,
|
inputPrice,
|
||||||
outputPrice
|
outputPrice
|
||||||
}
|
}
|
||||||
FILTER .name = <str>$0
|
FILTER .modelID = <str>$0
|
||||||
|
LIMIT 1
|
||||||
`, &usedModelInfo, model)
|
`, &usedModelInfo, model)
|
||||||
|
|
||||||
var inputCost float32 = float32(chatCompletionResponse.Usage.InputTokens) * usedModelInfo.InputPrice
|
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
|
var usedModelInfo ModelInfo
|
||||||
edgeClient.QuerySingle(edgeCtx, `
|
edgeClient.QuerySingle(edgeCtx, `
|
||||||
Select ModelInfo {
|
SELECT ModelInfo {
|
||||||
inputPrice,
|
inputPrice,
|
||||||
outputPrice
|
outputPrice
|
||||||
}
|
}
|
||||||
Filter ModelInfo.model = <str>$0
|
FILTER .modelID = <str>$0
|
||||||
|
LIMIT 1
|
||||||
`, &usedModelInfo, model)
|
`, &usedModelInfo, model)
|
||||||
|
|
||||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
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
|
var usedModelInfo ModelInfo
|
||||||
edgeClient.QuerySingle(edgeCtx, `
|
edgeClient.QuerySingle(edgeCtx, `
|
||||||
Select ModelInfo {
|
SELECT ModelInfo {
|
||||||
inputPrice,
|
inputPrice,
|
||||||
outputPrice
|
outputPrice
|
||||||
}
|
}
|
||||||
Filter ModelInfo.model = <str>$0
|
FILTER .modelID = <str>$0
|
||||||
|
LIMIT 1
|
||||||
`, &usedModelInfo, model)
|
`, &usedModelInfo, model)
|
||||||
|
|
||||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
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
|
var usedModelInfo ModelInfo
|
||||||
edgeClient.QuerySingle(edgeCtx, `
|
edgeClient.QuerySingle(edgeCtx, `
|
||||||
Select ModelInfo {
|
SELECT ModelInfo {
|
||||||
inputPrice,
|
inputPrice,
|
||||||
outputPrice
|
outputPrice
|
||||||
}
|
}
|
||||||
Filter ModelInfo.model = <str>$0
|
FILTER .modelID = <str>$0
|
||||||
|
LIMIT 1
|
||||||
`, &usedModelInfo, model)
|
`, &usedModelInfo, model)
|
||||||
|
|
||||||
var inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
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
|
var usedModelInfo ModelInfo
|
||||||
edgeClient.QuerySingle(edgeCtx, `
|
err = edgeClient.QuerySingle(edgeCtx, `
|
||||||
Select ModelInfo {
|
SELECT ModelInfo {
|
||||||
inputPrice,
|
inputPrice,
|
||||||
outputPrice
|
outputPrice
|
||||||
}
|
}
|
||||||
Filter ModelInfo.model = <str>$0
|
FILTER .modelID = <str>$0
|
||||||
|
LIMIT 1
|
||||||
`, &usedModelInfo, model)
|
`, &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 inputCost float32 = float32(chatCompletionResponse.Usage.PromptTokens) * usedModelInfo.InputPrice
|
||||||
var outputCost float32 = float32(chatCompletionResponse.Usage.CompletionTokens) * usedModelInfo.OutputPrice
|
var outputCost float32 = float32(chatCompletionResponse.Usage.CompletionTokens) * usedModelInfo.OutputPrice
|
||||||
|
Loading…
x
Reference in New Issue
Block a user