mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(ui): only label logs cost and duration a session total when the aggregate exists
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
11225b7f13
commit
c4ab243fa6
2 changed files with 35 additions and 7 deletions
|
|
@ -73,6 +73,20 @@ describe("Cost column", () => {
|
|||
expect(screen.queryByText("$0.010000")).not.toBeInTheDocument();
|
||||
expect(screen.getByText("session total")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not label the per-call spend a session total when the aggregate is unavailable", () => {
|
||||
renderRows([
|
||||
logEntry({
|
||||
request_id: "req-session-no-aggregate",
|
||||
spend: 0.01,
|
||||
session_id: "sess-1",
|
||||
session_total_count: 3,
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(screen.getByText("$0.010000")).toBeInTheDocument();
|
||||
expect(screen.queryByText("session total")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Duration column", () => {
|
||||
|
|
@ -89,6 +103,21 @@ describe("Duration column", () => {
|
|||
|
||||
expect(screen.getByText("5.40")).toBeInTheDocument();
|
||||
expect(screen.queryByText("1.20")).not.toBeInTheDocument();
|
||||
expect(screen.getByText("session total")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not label the per-call duration a session total when the aggregate is unavailable", () => {
|
||||
renderRows([
|
||||
logEntry({
|
||||
request_id: "req-no-aggregate",
|
||||
request_duration_ms: 1200,
|
||||
session_id: "sess-3",
|
||||
session_total_count: 3,
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(screen.getByText("1.20")).toBeInTheDocument();
|
||||
expect(screen.queryByText("session total")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the call's own duration for a single-call session", () => {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ export const getRequestLogsTableColumns = ({
|
|||
const mcpCount = log.mcp_tool_call_count || 0;
|
||||
const mcpSpend = log.mcp_tool_call_spend || 0;
|
||||
const isMultiCallSession = (log.session_total_count || 1) > 1;
|
||||
const spend = isMultiCallSession && log.session_total_spend != null ? log.session_total_spend : log.spend;
|
||||
const sessionTotalSpend = isMultiCallSession ? log.session_total_spend : undefined;
|
||||
const spend = sessionTotalSpend ?? log.spend;
|
||||
const money = (
|
||||
<span>
|
||||
<MoneyCell value={spend} decimals={6} />
|
||||
|
|
@ -143,7 +144,7 @@ export const getRequestLogsTableColumns = ({
|
|||
return (
|
||||
<div className="flex flex-col items-end">
|
||||
{spend ? <CellTooltip content={`$${String(spend)}`} trigger={money} /> : money}
|
||||
{isMultiCallSession && <span className="text-[10px] text-gray-400">session total</span>}
|
||||
{sessionTotalSpend != null && <span className="text-[10px] text-gray-400">session total</span>}
|
||||
{mcpCount > 0 && mcpSpend > 0 && (
|
||||
<span className="text-[10px] text-amber-600">
|
||||
incl. {getSpendString(mcpSpend)} from {mcpCount} MCP
|
||||
|
|
@ -162,10 +163,8 @@ export const getRequestLogsTableColumns = ({
|
|||
cell: ({ row }) => {
|
||||
const log = row.original;
|
||||
const isMultiCallSession = (log.session_total_count || 1) > 1;
|
||||
const ms =
|
||||
isMultiCallSession && log.session_total_duration_ms != null
|
||||
? log.session_total_duration_ms
|
||||
: log.request_duration_ms;
|
||||
const sessionTotalMs = isMultiCallSession ? log.session_total_duration_ms : undefined;
|
||||
const ms = sessionTotalMs ?? log.request_duration_ms;
|
||||
if (ms == null) return <span>-</span>;
|
||||
return (
|
||||
<div className="flex flex-col items-end">
|
||||
|
|
@ -173,7 +172,7 @@ export const getRequestLogsTableColumns = ({
|
|||
content={`${ms}ms`}
|
||||
trigger={<span className="max-w-[15ch] truncate inline-block">{(ms / 1000).toFixed(2)}</span>}
|
||||
/>
|
||||
{isMultiCallSession && <span className="text-[10px] text-gray-400">session total</span>}
|
||||
{sessionTotalMs != null && <span className="text-[10px] text-gray-400">session total</span>}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue