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]

Merge remote-tracking branch 'origin' into litellm_usage_date_pick_fix

yuneng-jiang94a0ff08b733
diff --cc ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.test.tsx
index 14f53dd28a0,afd5c5789b8..9a9fa68f762
--- a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.test.tsx
+++ b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.test.tsx
@@@ -270,44 -270,78 +270,119 @@@ describe("EntityUsage", () =>
expect(screen.getAllByText("0")[0]).toBeInTheDocument();
});
+ it("should display Model Activity tab for non-agent entity types", async () => {
+ render(<EntityUsage {...defaultProps} entityType="tag" />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ expect(screen.getByText("Model Activity")).toBeInTheDocument();
+ });
+
+ it("should display Request / Token Consumption tab for agent entity type", async () => {
+ render(<EntityUsage {...defaultProps} entityType="agent" />);
+
+ await waitFor(() => {
+ expect(mockAgentDailyActivityCall).toHaveBeenCalled();
+ });
+
+ expect(screen.getByText("Request / Token Consumption")).toBeInTheDocument();
+ });
+
+ it("should display Top Models title for non-agent entity types", async () => {
+ render(<EntityUsage {...defaultProps} entityType="tag" />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ const topModelsElements = screen.getAllByText("Top Models");
+ expect(topModelsElements.length).toBeGreaterThan(0);
+ });
+
+ it("should display Top Agents title for agent entity type", async () => {
+ render(<EntityUsage {...defaultProps} entityType="agent" />);
+
+ await waitFor(() => {
+ expect(mockAgentDailyActivityCall).toHaveBeenCalled();
+ });
+
+ expect(screen.getByText("Top Agents")).toBeInTheDocument();
+ });
++
+ it("should use entityList label when entityList is provided and entity exists", async () => {
+ const customEntityList = [
+ { label: "Custom Tag Label", value: "tag-1" },
+ { label: "Tag 2", value: "tag-2" },
+ ];
+
+ render(<EntityUsage {...defaultProps} entityList={customEntityList} />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Custom Tag Label")).toBeInTheDocument();
+ });
+ });
+
+ it("should fallback to team_alias when entityList is provided but entity does not exist", async () => {
+ const customEntityList = [{ label: "Tag 2", value: "tag-2" }];
+
+ render(<EntityUsage {...defaultProps} entityList={customEntityList} />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Tag 1")).toBeInTheDocument();
+ });
+ });
+
+ it("should fallback to team_alias when entityList is null", async () => {
+ render(<EntityUsage {...defaultProps} entityList={null} />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Tag 1")).toBeInTheDocument();
+ });
+ });
+
+ it("should fallback to entity value when no entityList and no team_alias", async () => {
+ const spendDataWithoutAlias = {
+ ...mockSpendData,
+ results: [
+ {
+ ...mockSpendData.results[0],
+ breakdown: {
+ ...mockSpendData.results[0].breakdown,
+ entities: {
+ "tag-1": {
+ ...mockSpendData.results[0].breakdown.entities["tag-1"],
+ metadata: {},
+ },
+ },
+ },
+ },
+ ],
+ };
+
+ mockTagDailyActivityCall.mockResolvedValue(spendDataWithoutAlias);
+
+ render(<EntityUsage {...defaultProps} entityList={null} />);
+
+ await waitFor(() => {
+ expect(mockTagDailyActivityCall).toHaveBeenCalled();
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("tag-1")).toBeInTheDocument();
+ });
+ });
});