Skip to content

Commit

Permalink
feat: cached call ui (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored May 8, 2024
1 parent 1d0d4ce commit bfaa939
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ops
Submodule ops updated from a8cbdd to 7dfc59
2 changes: 1 addition & 1 deletion packages/backend/src/api/v1/runs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ runs.get("/:id/related", checkAccess("logs", "read"), async (ctx) => {
INNER JOIN related_runs rr ON rr.id = r2.parent_run_id
)
SELECT rr.created_at, rr.tags, rr.project_id, rr.id, rr.status, rr.name, rr.ended_at, rr.error, rr.input, rr.output,
rr.params, rr.type, rr.parent_run_id, rr.completion_tokens, rr.prompt_tokens, rr.feedback
rr.params, rr.type, rr.parent_run_id, rr.completion_tokens, rr.prompt_tokens, rr.feedback, rr.metadata
FROM related_runs rr;
`

Expand Down
28 changes: 26 additions & 2 deletions packages/frontend/components/blocks/DurationBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
import { Badge, ThemeIcon } from "@mantine/core"
import { IconClock } from "@tabler/icons-react"
import { IconBolt, IconClock } from "@tabler/icons-react"

export default function DurationBadge({ createdAt, endedAt, minimal = false }) {
export default function DurationBadge({
cached = false,
createdAt,
endedAt,
minimal = false,
}) {
const duration = endedAt
? new Date(endedAt).getTime() - new Date(createdAt).getTime()
: NaN

if (cached) {
return (
<Badge
variant="light"
color="yellow"
pl={0}
pr={5}
leftSection={
<ThemeIcon variant="subtle" size="sm" color="light">
<IconBolt size="12" />
</ThemeIcon>
}
tt="none"
>
Cached ({(duration / 1000).toFixed(2)}s)
</Badge>
)
}

return (
<Badge
variant="light"
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/pages/traces/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ const TraceTree = ({
)}

{run.endedAt && (
<DurationBadge createdAt={run.createdAt} endedAt={run.endedAt} />
<DurationBadge
cached={run.metadata?.cache}
createdAt={run.createdAt}
endedAt={run.endedAt}
/>
)}

{/* {timeAfterFirst > 0 && (
Expand Down

0 comments on commit bfaa939

Please sign in to comment.