fix: charge local input tokens when Gemini returns empty response

This commit is contained in:
Seefs
2026-02-05 15:57:17 +08:00
parent 9d73aa44b7
commit ecebd619a4
3 changed files with 9 additions and 9 deletions

View File

@@ -1258,8 +1258,7 @@ func geminiStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http
}
if usage.CompletionTokens <= 0 {
str := responseText.String()
if len(str) > 0 {
if info.ReceivedResponseCount > 0 {
usage = service.ResponseText2Usage(c, responseText.String(), info.UpstreamModelName, info.GetEstimatePromptTokens())
} else {
usage = &dto.Usage{}