|
|
|
@ -353,7 +353,12 @@ func completions(c *gin.Context) {
|
|
|
|
if trimStr != "\n" {
|
|
|
|
if trimStr != "\n" {
|
|
|
|
json.Unmarshal([]byte(trimStr), &chatResponse)
|
|
|
|
json.Unmarshal([]byte(trimStr), &chatResponse)
|
|
|
|
if chatResponse.Choices != nil {
|
|
|
|
if chatResponse.Choices != nil {
|
|
|
|
|
|
|
|
if chatResponse.Choices[0].Text != "" {
|
|
|
|
|
|
|
|
reqContent += chatResponse.Choices[0].Text
|
|
|
|
|
|
|
|
} else {
|
|
|
|
reqContent += chatResponse.Choices[0].Delta.Content
|
|
|
|
reqContent += chatResponse.Choices[0].Delta.Content
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chatRequestId = chatResponse.Id
|
|
|
|
chatRequestId = chatResponse.Id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -372,6 +377,7 @@ func completions(c *gin.Context) {
|
|
|
|
prompt_tokens = numTokensFromMessages(chatRequest.Messages, chatRequest.Model)
|
|
|
|
prompt_tokens = numTokensFromMessages(chatRequest.Messages, chatRequest.Model)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
completion_tokens = numTokensFromString(reqContent, chatRequest.Model)
|
|
|
|
completion_tokens = numTokensFromString(reqContent, chatRequest.Model)
|
|
|
|
|
|
|
|
log.Printf("返回内容:%v", reqContent)
|
|
|
|
total_tokens = prompt_tokens + completion_tokens
|
|
|
|
total_tokens = prompt_tokens + completion_tokens
|
|
|
|
log.Printf("prompt_tokens: %v completion_tokens: %v total_tokens: %v", prompt_tokens, completion_tokens, total_tokens)
|
|
|
|
log.Printf("prompt_tokens: %v completion_tokens: %v total_tokens: %v", prompt_tokens, completion_tokens, total_tokens)
|
|
|
|
//消费余额
|
|
|
|
//消费余额
|
|
|
|
|