mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-11 19:03:43 +08:00
fix: improve error handling in rate limiter and remove unnecessary logging
This commit is contained in:
@@ -424,8 +424,6 @@ func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusC
|
||||
data = strings.TrimPrefix(data, "data: ")
|
||||
data = strings.TrimSuffix(data, "\"")
|
||||
|
||||
fmt.Printf(">> gemini response: %s\n", data)
|
||||
|
||||
var geminiResponse ChatResponse
|
||||
err := json.Unmarshal([]byte(data), &geminiResponse)
|
||||
if err != nil {
|
||||
|
||||
@@ -77,6 +77,7 @@ func getTokenNum(tokenEncoder *tiktoken.Tiktoken, text string) int {
|
||||
return len(tokenEncoder.Encode(text, nil, nil))
|
||||
}
|
||||
|
||||
// CountTokenMessages counts the number of tokens in a list of messages.
|
||||
func CountTokenMessages(ctx context.Context,
|
||||
messages []model.Message, actualModel string) int {
|
||||
tokenEncoder := getTokenEncoder(actualModel)
|
||||
|
||||
Reference in New Issue
Block a user