mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(ui): show cache key for cache-populating requests
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
aeb38b6664
commit
96cde25dd6
2 changed files with 26 additions and 3 deletions
|
|
@ -366,9 +366,30 @@ describe("LogDetailContent", () => {
|
|||
expect(screen.getByText("abc123cachekey")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should display a cache miss and Cache Key for the request that populates the response cache", () => {
|
||||
render(
|
||||
<LogDetailContent
|
||||
logEntry={createLogEntry({ cache_hit: "None", cache_key: "abc123cachekey" })}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("Response Cache")).toBeInTheDocument();
|
||||
expect(screen.getByText("Miss")).toBeInTheDocument();
|
||||
expect(screen.getByText("Cache Key")).toBeInTheDocument();
|
||||
expect(screen.getByText("abc123cachekey")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should hide the Cache Key row when caching is off", () => {
|
||||
render(<LogDetailContent logEntry={createLogEntry({ cache_hit: "False", cache_key: "Cache OFF" })} />);
|
||||
|
||||
expect(screen.getByText("Response Cache")).toBeInTheDocument();
|
||||
expect(screen.queryByText("Cache Key")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should hide response cache metadata when caching is off and cache_hit is None", () => {
|
||||
render(<LogDetailContent logEntry={createLogEntry({ cache_hit: "None", cache_key: "Cache OFF" })} />);
|
||||
|
||||
expect(screen.queryByText("Response Cache")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Cache Key")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -382,8 +382,10 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata:
|
|||
: null;
|
||||
|
||||
const responseCacheValue = String(logEntry.cache_hit ?? "").toLowerCase();
|
||||
const responseCacheKey =
|
||||
logEntry.cache_key && logEntry.cache_key !== "Cache OFF" ? logEntry.cache_key : undefined;
|
||||
const isResponseCacheHit = responseCacheValue === "true";
|
||||
const showResponseCache = isResponseCacheHit || responseCacheValue === "false";
|
||||
const showResponseCache = isResponseCacheHit || responseCacheValue === "false" || responseCacheKey != null;
|
||||
const promptCacheReadTokens = Number(metadata?.additional_usage_values?.cache_read_input_tokens) || 0;
|
||||
const promptCacheCreationTokens = Number(metadata?.additional_usage_values?.cache_creation_input_tokens) || 0;
|
||||
|
||||
|
|
@ -438,11 +440,11 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata:
|
|||
</Badge>
|
||||
</DescriptionItem>
|
||||
)}
|
||||
{showResponseCache && logEntry.cache_key && logEntry.cache_key !== "Cache OFF" && (
|
||||
{responseCacheKey && (
|
||||
<DescriptionItem
|
||||
label={<MetricLabel label="Cache Key" tooltip={CACHE_KEY_TOOLTIP} docsUrl={RESPONSE_CACHE_DOCS_URL} />}
|
||||
>
|
||||
<TruncatedValue value={logEntry.cache_key} />
|
||||
<TruncatedValue value={responseCacheKey} />
|
||||
</DescriptionItem>
|
||||
)}
|
||||
{promptCacheReadTokens > 0 && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue