Merge pull request #4692 from BerriAI/ui_fix_cache_ratio_calc

[UI] Fix Cache Ratio Calc
This commit is contained in:
Ishaan Jaff 2024-07-13 14:36:39 -07:00 committed by GitHub
commit b0a1ed72b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,8 +194,9 @@ const CacheDashboard: React.FC<CachePageProps> = ({
// set header cache statistics
setCachedResponses(valueFormatterNumbers(cache_hits));
setCachedTokens(valueFormatterNumbers(cached_tokens));
if (llm_api_requests > 0) {
let cache_hit_ratio = ((cache_hits / llm_api_requests) * 100).toFixed(2);
let allRequests = cache_hits + llm_api_requests
if (allRequests > 0) {
let cache_hit_ratio = ((cache_hits / allRequests) * 100).toFixed(2);
setCacheHitRatio(cache_hit_ratio);
} else {
setCacheHitRatio("0");