feat: add image counter for gpt-4 vision (#795)

This commit is contained in:
Qiying Wang
2023-12-10 19:39:46 +08:00
committed by GitHub
parent 9ba5388367
commit 4c5feee0b6
6 changed files with 315 additions and 7 deletions

View File

@@ -410,6 +410,10 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
defer func(ctx context.Context) {
// c.Writer.Flush()
go func() {
if promptTokens != textResponse.PromptTokens {
common.SysError(fmt.Sprintf("prompt tokens not match, expected %d, actual %d", promptTokens, textResponse.PromptTokens))
}
quota := 0
completionRatio := common.GetCompletionRatio(textRequest.Model)
promptTokens = textResponse.Usage.PromptTokens