🐛 fix: Fix conditional caching in RelayHandler

This commit is contained in:
Martial BE 2024-04-24 18:02:33 +08:00
parent 755dbf79be
commit 36653c2ce5
No known key found for this signature in database
GPG Key ID: D06C32DF0EDB9084

View File

@ -111,8 +111,11 @@ func RelayHandler(relay RelayBaseInterface) (err *types.OpenAIErrorWithStatusCod
}
quota.Consume(relay.getContext(), usage)
cacheProps := relay.GetChatCache()
go cacheProps.StoreCache(relay.getContext().GetInt("channel_id"), usage.PromptTokens, usage.CompletionTokens, relay.getModelName())
if usage.CompletionTokens > 0 {
cacheProps := relay.GetChatCache()
go cacheProps.StoreCache(relay.getContext().GetInt("channel_id"), usage.PromptTokens, usage.CompletionTokens, relay.getModelName())
}
return
}