Files
Eric Allam 1cfc296c6b feat(ai): LLM metrics tracking and AI span inspector (#3213)
- Automatic LLM cost enrichment for AI SDK spans (streamText,
generateText, generateObject) or any other spans that use semantic
gen_ai attributes with support for 145+ models
- New AI span inspector sidebar showing model, tokens, cost, messages,
tool calls, and response text
- LLM metrics dual-write to ClickHouse `llm_metrics_v1` table for
analytics
- LLM metrics built-in dashboard (unlinked at the moment)
- Provider cost fallback — uses gateway/OpenRouter reported costs from
`providerMetadata` when registry pricing is unavailable
- Prefix-stripping for gateway/OpenRouter model names (e.g.
`mistral/mistral-large-3` matches `mistral-large-3` pricing)
- Admin dashboard for managing LLM model pricing (list, create, edit,
delete, search, test pattern matching)
- Missing models detection page — queries ClickHouse for unpriced models
with sample spans and Claude Code-ready prompts for adding pricing
- AI span seed script (`pnpm run db:seed:ai-spans`) with 51 spans across
12 provider systems for local dev testing
- UI fixes: `completionTokens`/`promptTokens` aliases,
`ai.response.object` display for generateObject, cache read/write token
breakdown

## Screenshots:

<img width="1030" height="104" alt="CleanShot 2026-03-17 at 16 48 54@2x"
src="https://github.com/user-attachments/assets/bc8fccda-e48b-4d0c-bfb1-e620064e5979"
/>

<img width="1094" height="1512" alt="CleanShot 2026-03-17 at 16 49
23@2x"
src="https://github.com/user-attachments/assets/c2424569-d07e-4d67-a436-e8250043a1ee"
/>

<img width="1074" height="1412" alt="CleanShot 2026-03-17 at 16 49
18@2x"
src="https://github.com/user-attachments/assets/22342ac4-4769-45d1-a328-a24fb9a82a50"
/>

<img width="1012" height="2292" alt="CleanShot 2026-03-17 at 16 39
01@2x"
src="https://github.com/user-attachments/assets/59e327d1-6652-4293-8be0-bb8326e5fbc5"
/>

<img width="3680" height="2392" alt="CleanShot 2026-03-15 at 08 29
38@2x"
src="https://github.com/user-attachments/assets/1f77beb8-de67-495b-b890-bcdb8d7f1fe8"
/>

---------

Co-authored-by: James Ritchie <james@trigger.dev>
2026-03-17 18:26:43 +00:00

250 lines
5.8 KiB
CSS

@import url("non.geist");
@import url("non.geist/mono");
@import "react-grid-layout/css/styles.css";
@import "react-resizable/css/styles.css";
/* Override react-grid-layout placeholder color (default is red) */
.react-grid-item.react-grid-placeholder {
background: rgb(99 102 241) !important; /* indigo-500 */
border-radius: 0.375rem !important; /* rounded-md */
}
/* Sidebar reorder grid: subtle placeholder */
.sidebar-reorder-grid .react-grid-item.react-grid-placeholder {
background: rgb(39 42 46) !important; /* charcoal-700 */
border-radius: 0.25rem;
opacity: 1 !important;
}
/* Sidebar reorder grid: only animate transform (vertical position), not width/height */
.sidebar-reorder-grid .react-grid-item {
transition: transform 200ms ease !important;
}
/* Override resize handle icon to white */
.react-resizable-handle {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiNmZmZmZmYiLz48L2c+PC9zdmc+') !important;
}
.react-resizable-handle::after {
border-bottom-color: rgba(255, 255, 255, 0.4) !important;
border-right-color: rgba(255, 255, 255, 0.4) !important;
border-top-color: rgba(255, 255, 255, 0.4) !important;
border-left-color: rgba(255, 255, 255, 0.4) !important;
}
@tailwind base;
@tailwind components;
@tailwind utilities;
@property --gradient-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
@supports (-webkit-hyphens: none) {
.safari-only {
@apply border-b border-grid-dimmed;
}
}
@layer base {
* {
@apply border-grid-bright;
}
body {
@apply bg-background-dimmed text-text-dimmed;
font-feature-settings: "rlig" 1, "calt" 1;
}
/* Text selection styles */
::selection {
@apply bg-text-bright/30 text-text-bright;
}
::-moz-selection {
@apply bg-text-bright/30 text-text-bright;
}
/* shadcn charts: https://ui.shadcn.com/docs/components/chart#add-a-grid */
:root {
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}
.dark {
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}
@layer utilities {
.scrollbar-gutter-stable {
scrollbar-gutter: stable;
}
.animated-gradient-glow {
position: relative;
overflow: visible;
}
.animated-gradient-glow::before {
content: "";
position: absolute;
inset: -8px;
z-index: -1;
background: conic-gradient(
from var(--gradient-angle),
rgb(99 102 241),
rgb(245 158 11),
rgb(236 72 153),
rgb(245 158 11),
rgb(99 102 241)
);
border-radius: inherit;
animation: gradient-rotation 3s linear infinite;
pointer-events: none;
filter: blur(0.5rem);
opacity: 0.1;
}
.animated-gradient-glow-small {
position: relative;
overflow: visible;
}
.animated-gradient-glow-small::before {
content: "";
position: absolute;
inset: -1px;
z-index: -1;
background: conic-gradient(
from var(--gradient-angle),
rgb(99 102 241),
rgb(245 158 11),
rgb(236 72 153),
rgb(245 158 11),
rgb(99 102 241)
);
border-radius: inherit;
animation: gradient-rotation 3s linear infinite;
pointer-events: none;
filter: blur(0.2rem);
opacity: 0.3;
}
}
@keyframes gradient-rotation {
0% {
--gradient-angle: 0deg;
}
100% {
--gradient-angle: 360deg;
}
}
/* Streamdown markdown styling */
.streamdown-container {
/* Streamdown uses shadcn/ui CSS variables - define them for our theme */
--muted: 220 13% 20%;
--muted-foreground: 215 14% 60%;
--foreground: 210 20% 90%;
--border: 217 19% 27%;
/* Code block styling */
& [data-code-block-container] {
@apply rounded border-charcoal-650 my-0;
}
& [data-code-block] {
border-top: none;
}
& p {
@apply my-1;
}
& h1, & h2, & h3, & h4, & h5, & h6 {
@apply font-semibold text-text-bright mt-2 mb-1;
}
& h1 {
@apply text-base;
}
& h2 {
@apply text-sm;
}
& h3, & h4, & h5, & h6 {
@apply text-xs;
}
& ul, & ol {
@apply ml-4 my-1;
}
& ul {
@apply list-disc;
}
& ol {
@apply list-decimal;
}
& li {
@apply my-0.5;
}
/* Inline code (not in pre blocks) */
& code:not(pre code) {
@apply bg-charcoal-700 px-1 py-0.5 rounded text-text-bright font-mono;
}
& blockquote {
@apply border-l-2 border-charcoal-600 pl-3 my-2 italic;
}
& a {
@apply text-blue-400 hover:underline;
}
& strong {
@apply font-semibold text-text-bright;
}
& em {
@apply italic;
}
& hr {
@apply my-2 border-charcoal-600;
}
& table {
@apply w-full my-2 border-collapse;
}
& th, & td {
@apply border border-charcoal-600 px-2 py-1 text-left;
}
& th {
@apply bg-charcoal-700 font-semibold;
}
/* Streamdown code block container */
& [data-code-block-container] {
@apply my-2 border-charcoal-700;
}
& [data-code-block-header] {
@apply bg-charcoal-800 text-text-dimmed border-b border-charcoal-700;
}
/* Hide light mode code block, show dark mode */
& [data-code-block].dark\:hidden {
display: none !important;
}
& [data-code-block].hidden.dark\:block {
display: block !important;
}
/* Override the bg-muted/40 class to let inline styles work */
& [data-code-block] pre {
background-color: inherit !important;
@apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600;
}
& [data-code-block] pre code {
@apply bg-transparent;
}
& [data-code-block] .line {
@apply leading-relaxed;
}
}