Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

address greptile review feedback + UI refinements for retry display

yuneng-jiangd6c562a35da1
diff --git a/litellm/router.py b/litellm/router.py
index a7fa6129c16..b1337159e57 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -5130,7 +5130,7 @@ class Router:
)
## ADD RETRY TRACKING TO METADATA - used for spend logs retry tracking
_metadata["attempted_retries"] = 0
- _metadata["max_retries"] = num_retries
+ _metadata["max_retries"] = num_retries # Updated after overrides in exception handler
try:
self._handle_mock_testing_rate_limit_error(
model_group=model_group, kwargs=kwargs
@@ -5196,6 +5196,9 @@ class Router:
regular_fallbacks=fallbacks,
content_policy_fallbacks=content_policy_fallbacks,
)
+ # Update max_retries after overrides (deployment_num_retries / retry_policy)
+ _metadata["max_retries"] = num_retries
+
## LOGGING
if num_retries > 0:
kwargs = self.log_retry(kwargs=kwargs, e=original_exception)
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
index 30a884a0092..be25eed8ec5 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
@@ -296,13 +296,13 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata:
</Descriptions.Item>
)}
- {metadata?.attempted_retries !== undefined && metadata?.attempted_retries !== null && (
- <Descriptions.Item label="Retries">
- {metadata.attempted_retries > 0
+ <Descriptions.Item label="Retries">
+ {metadata?.attempted_retries !== undefined && metadata?.attempted_retries !== null
+ ? metadata.attempted_retries > 0
? <>{metadata.attempted_retries}{metadata.max_retries !== undefined && metadata.max_retries !== null ? ` / ${metadata.max_retries}` : ''}</>
- : "Not Retried"}
- </Descriptions.Item>
- )}
+ : <Tag color="green">None</Tag>
+ : "-"}
+ </Descriptions.Item>
<Descriptions.Item label="Start Time">
{moment(logEntry.startTime).format("YYYY-MM-DDTHH:mm:ss.SSS[Z]")}
diff --git a/ui/litellm-dashboard/src/components/view_logs/index.test.tsx b/ui/litellm-dashboard/src/components/view_logs/index.test.tsx
index 61d96f72ce2..7d4fc98111d 100644
--- a/ui/litellm-dashboard/src/components/view_logs/index.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/index.test.tsx
@@ -145,7 +145,7 @@ describe("Request Viewer", () => {
expect(screen.getByText("2 / 3")).toBeInTheDocument();
});
- it("should display 'Not Retried' when attempted_retries is 0", () => {
+ it("should display green 'None' tag when attempted_retries is 0", () => {
render(
<RequestViewer
row={createRow({
@@ -163,13 +163,14 @@ describe("Request Viewer", () => {
);
expect(screen.getByText("Retries:")).toBeInTheDocument();
- expect(screen.getByText("Not Retried")).toBeInTheDocument();
+ expect(screen.getByText("None")).toBeInTheDocument();
});
- it("should not display Retries when attempted_retries is not present in metadata", () => {
+ it("should display '-' for Retries when attempted_retries is not present in metadata", () => {
render(<RequestViewer row={createRow()} />);
- expect(screen.queryByText("Retries:")).not.toBeInTheDocument();
+ expect(screen.getByText("Retries:")).toBeInTheDocument();
+ expect(screen.getByText("-")).toBeInTheDocument();
});
});
diff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsx
index 153acdc9ca9..a3f40aff995 100644
--- a/ui/litellm-dashboard/src/components/view_logs/index.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx
@@ -7,7 +7,7 @@ import { truncateString } from "@/utils/textUtils";
import { SettingOutlined, SyncOutlined } from "@ant-design/icons";
import { Row } from "@tanstack/react-table";
import { Switch, Tab, TabGroup, TabList, TabPanel, TabPanels } from "@tremor/react";
-import { Button, Tooltip } from "antd";
+import { Button, Tag, Tooltip } from "antd";
import { internalUserRoles } from "../../utils/roles";
import DeletedKeysPage from "../DeletedKeysPage/DeletedKeysPage";
import DeletedTeamsPage from "../DeletedTeamsPage/DeletedTeamsPage";
@@ -960,16 +960,16 @@ export function RequestViewer({ row, onOpenSettings }: { row: Row<LogEntry>; onO
<span>{row.original.metadata.litellm_overhead_time_ms} ms</span>
</div>
)}
- {row.original.metadata?.attempted_retries !== undefined && row.original.metadata?.attempted_retries !== null && (
- <div className="flex">
- <span className="font-medium w-1/3">Retries:</span>
- <span>
- {row.original.metadata.attempted_retries > 0
+ <div className="flex">
+ <span className="font-medium w-1/3">Retries:</span>
+ <span>
+ {row.original.metadata?.attempted_retries !== undefined && row.original.metadata?.attempted_retries !== null
+ ? row.original.metadata.attempted_retries > 0
? `${row.original.metadata.attempted_retries}${row.original.metadata.max_retries !== undefined && row.original.metadata.max_retries !== null ? ` / ${row.original.metadata.max_retries}` : ''}`
- : 'Not Retried'}
- </span>
- </div>
- )}
+ : <Tag color="green">None</Tag>
+ : '-'}
+ </span>
+ </div>
</div>
</div>
</div>