🐛 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

View File

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