Merge pull request #3388 from BerriAI/litellm_ui_latency_tracker

[UI] Fix show latency < 0.0001 for deployments that have low latency + only show non cache hits on latency UI
This commit is contained in:
Ishaan Jaff 2024-05-01 16:58:03 -07:00 committed by GitHub
commit 8c148506a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 12 deletions

View file

@ -7549,7 +7549,7 @@ async def model_metrics(
"LiteLLM_SpendLogs"
WHERE
"startTime" >= NOW() - INTERVAL '30 days'
AND "model" = $1
AND "model" = $1 AND "cache_hit" != 'True'
GROUP BY
api_base,
model,
@ -7598,7 +7598,7 @@ async def model_metrics(
for day in _daily_entries:
entry = {"date": str(day)}
for model_key, latency in _daily_entries[day].items():
entry[model_key] = round(latency, 8)
entry[model_key] = latency
response.append(entry)
return {

View file

@ -720,17 +720,20 @@ const handleEditSubmit = async (formValues: Record<string, any>) => {
return (
<div className="w-150 rounded-tremor-default border border-tremor-border bg-tremor-background p-2 text-tremor-default shadow-tremor-dropdown">
{date && <p className="text-tremor-content-emphasis mb-2">Date: {date}</p>}
{sortedPayload.map((category: any, idx: number) => (
<div key={idx} className="flex justify-between">
<div className="flex items-center space-x-2">
<div className={`w-2 h-2 mt-1 rounded-full bg-${category.color}-500`} />
<p className="text-tremor-content">{category.dataKey}</p>
{sortedPayload.map((category: any, idx: number) => {
const roundedValue = parseFloat(category.value.toFixed(5));
const displayValue =
roundedValue === 0 && category.value > 0 ? "<0.00001" : roundedValue.toFixed(5);
return (
<div key={idx} className="flex justify-between">
<div className="flex items-center space-x-2">
<div className={`w-2 h-2 mt-1 rounded-full bg-${category.color}-500`} />
<p className="text-tremor-content">{category.dataKey}</p>
</div>
<p className="font-medium text-tremor-content-emphasis text-righ ml-2">{displayValue}</p>
</div>
<p className="font-medium text-tremor-content-emphasis text-righ ml-2">
{category.value.toFixed(5)}
</p>
</div>
))}
);
})}
</div>
);
};