mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
Merge 598729c5f4 into ec3f8183c3
This commit is contained in:
commit
3cc2da592c
2 changed files with 28 additions and 4 deletions
|
|
@ -171,6 +171,25 @@ describe("RequestLogsPanel", () => {
|
|||
expect(within(row("req-llm") as HTMLElement).getByText("3")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("prefers a caller-sent call over an auto-router classifier sub-call as the representative", async () => {
|
||||
const classifierSubCall: Partial<LogEntry> = {
|
||||
request_id: "req-classify",
|
||||
session_id: "sess-1",
|
||||
session_total_count: 2,
|
||||
metadata: { internal_call_origin: "autorouter_classifier" },
|
||||
};
|
||||
const callerSentCall: Partial<LogEntry> = {
|
||||
request_id: "req-main",
|
||||
session_id: "sess-1",
|
||||
session_total_count: 2,
|
||||
};
|
||||
respondWith([logEntry(classifierSubCall), logEntry(callerSentCall)]);
|
||||
renderPanel();
|
||||
|
||||
await waitFor(() => expect(row("req-main")).not.toBeNull());
|
||||
expect(row("req-classify")).toBeNull();
|
||||
});
|
||||
|
||||
it("leaves single-call rows untouched", async () => {
|
||||
respondWith([
|
||||
logEntry({ request_id: "req-solo-a", session_id: "sess-a", session_total_count: 1 }),
|
||||
|
|
|
|||
|
|
@ -175,13 +175,18 @@ export default function RequestLogsPanel({ accessToken, token, userRole, userID,
|
|||
return acc;
|
||||
}, {});
|
||||
|
||||
const sessionRepresentativeMap = new Map<string, { requestId: string; isMcp: boolean }>();
|
||||
// Lower rank wins: caller-sent non-MCP call, then MCP call, then internal
|
||||
// sub-calls (metadata.internal_call_origin, e.g. auto-router classifier).
|
||||
const representativeRank = (log: LogEntry): number =>
|
||||
(log.metadata?.internal_call_origin ? 2 : 0) + (MCP_CALL_TYPES.includes(log.call_type) ? 1 : 0);
|
||||
|
||||
const sessionRepresentativeMap = new Map<string, { requestId: string; rank: number }>();
|
||||
for (const log of searchedLogs) {
|
||||
if (!log.session_id || (log.session_total_count || 1) <= 1) continue;
|
||||
const isMcp = MCP_CALL_TYPES.includes(log.call_type);
|
||||
const rank = representativeRank(log);
|
||||
const existing = sessionRepresentativeMap.get(log.session_id);
|
||||
if (!existing || (existing.isMcp && !isMcp)) {
|
||||
sessionRepresentativeMap.set(log.session_id, { requestId: log.request_id, isMcp });
|
||||
if (!existing || rank < existing.rank) {
|
||||
sessionRepresentativeMap.set(log.session_id, { requestId: log.request_id, rank });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue