Skip to content

Commit

Permalink
fix minimax empty log (songquanpeng#1560)
Browse files Browse the repository at this point in the history
  • Loading branch information
ye4293 authored and mxdlzg committed Oct 15, 2024
1 parent f9c8814 commit 47fecac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions relay/adaptor/openai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"bufio"
"bytes"
"encoding/json"
"io"
"net/http"
"strings"

"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common"
"github.com/songquanpeng/one-api/common/conv"
"github.com/songquanpeng/one-api/common/logger"
"github.com/songquanpeng/one-api/relay/model"
"github.com/songquanpeng/one-api/relay/relaymode"
"io"
"net/http"
"strings"
)

const (
Expand Down Expand Up @@ -149,7 +150,7 @@ func Handler(c *gin.Context, resp *http.Response, promptTokens int, modelName st
return ErrorWrapper(err, "close_response_body_failed", http.StatusInternalServerError), nil
}

if textResponse.Usage.TotalTokens == 0 {
if textResponse.Usage.TotalTokens == 0 || (textResponse.Usage.PromptTokens == 0 && textResponse.Usage.CompletionTokens == 0) {
completionTokens := 0
for _, choice := range textResponse.Choices {
completionTokens += CountTokenText(choice.Message.StringContent(), modelName)
Expand Down

0 comments on commit 47fecac

Please sign in to comment.