πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
Many UI improvements and usage chart (#89)
Marc Klingen05a9fb877939
diff --git a/README.md b/README.mdindex f6cbc84f38..f293dfc508 100644--- a/README.md+++ b/README.md@@ -141,11 +141,11 @@ docker-compose -f docker-compose.dev.yml up -dcp .env.dev.example .env# Migration-npx prisma migrate dev+npm run db:migrate# Optional: seed the database-# npx prisma db seed-# npx prisma db seed:examples+# npm run db:seed+# npm run db:seed:examples# Start the servernpm run devdiff --git a/package.json b/package.jsonindex 2f61bdfdef..290c06a454 100644--- a/package.json+++ b/package.json@@ -13,6 +13,7 @@"start": "next start","test": "jest --runInBand","test:watch": "jest --watch --runInBand",+ "db:migrate": "npx prisma migrate dev","db:seed": "npx prisma db seed","db:seed:examples": "npx prisma db seed -- --environment examples"},diff --git a/src/components/grouped-score-badge.tsx b/src/components/grouped-score-badge.tsxindex b747a17185..9db12aa4bf 100644--- a/src/components/grouped-score-badge.tsx+++ b/src/components/grouped-score-badge.tsx@@ -1,7 +1,10 @@import { Badge } from "@/src/components/ui/badge";import { type Score } from "@prisma/client";-export const GroupedScoreBadges = (props: { scores: Score[] }) => {+export const GroupedScoreBadges = (props: {+ scores: Score[];+ inline?: boolean;+}) => {const groupedScores = props.scores.reduce((acc, score) => {if (!acc[score.name] || !Array.isArray(acc[score.name])) {acc[score.name] = [score];@@ -13,11 +16,23 @@ export const GroupedScoreBadges = (props: { scores: Score[] }) => {return (<>- {Object.entries(groupedScores).map(([name, scores]) => (- <Badge variant="outline" key={name} className="break-all font-normal">- {name}: {scores.map((s) => s.value).join(", ")}- </Badge>- ))}+ {Object.entries(groupedScores)+ .sort(([a], [b]) => (a < b ? -1 : 1))+ .map(([name, scores]) =>+ props.inline ? (+ <span key={name} className="break-all font-normal">+ {name}: {scores.map((s) => s.value).join(", ")}+ </span>+ ) : (+ <Badge+ variant="outline"+ key={name}+ className="break-all font-normal"+ >+ {name}: {scores.map((s) => s.value).join(", ")}+ </Badge>+ )+ )}</>);};diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsxindex c63d61744c..dcee58d0a7 100644--- a/src/components/layouts/layout.tsx+++ b/src/components/layouts/layout.tsx@@ -113,7 +113,7 @@ export default function Layout(props: PropsWithChildren) {<Transition.Root show={sidebarOpen} as={Fragment}><Dialogas="div"- className="relative z-50 lg:hidden"+ className="relative z-50 xl:hidden"onClose={setSidebarOpen}><Transition.Child@@ -164,8 +164,8 @@ export default function Layout(props: PropsWithChildren) {</Transition.Child>{/* Sidebar component, swap this element with another sidebar if you like */}<div className="flex grow flex-col gap-y-5 overflow-y-auto bg-white px-6 pb-4">- <div className="flex h-16 shrink-0 items-center font-mono text-xl font-bold">- πͺ’ langfuse+ <div className="flex h-16 shrink-0 items-center font-mono text-xl font-semibold">+ πͺ’ Langfuse</div><nav className="flex flex-1 flex-col"><ul role="list" className="flex flex-1 flex-col gap-y-7">@@ -265,11 +265,11 @@ export default function Layout(props: PropsWithChildren) {</Transition.Root>{/* Static sidebar for desktop */}- <div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col">+ <div className="hidden xl:fixed xl:inset-y-0 xl:z-50 xl:flex xl:w-72 xl:flex-col">{/* Sidebar component, swap this element with another sidebar if you like */}<div className="flex grow flex-col gap-y-5 overflow-y-auto border-r border-gray-200 bg-white px-6">- <div className="flex h-16 shrink-0 items-center font-mono text-xl font-bold">- πͺ’ langfuse+ <div className="flex h-16 shrink-0 items-center font-mono text-xl font-semibold">+ πͺ’ Langfuse</div><nav className="flex flex-1 flex-col"><ul role="list" className="flex flex-1 flex-col gap-y-4">@@ -419,27 +419,18 @@ export default function Layout(props: PropsWithChildren) {</div></div>- <div className="sticky top-0 z-40 flex items-center gap-x-6 bg-white px-4 py-4 shadow-sm sm:px-6 lg:hidden">+ <div className="sticky top-0 z-40 flex items-center gap-x-6 bg-white px-4 py-4 shadow-sm sm:px-6 xl:hidden"><buttontype="button"- className="-m-2.5 p-2.5 text-gray-700 lg:hidden"+ className="-m-2.5 p-2.5 text-gray-700 xl:hidden"onClick={() => setSidebarOpen(true)}><span className="sr-only">Open sidebar</span><Bars3Icon className="h-6 w-6" aria-hidden="true" /></button>- <div className="flex-1 font-mono text-sm font-bold leading-6 text-gray-900">- πͺ’ langfuse+ <div className="flex-1 font-mono text-sm font-semibold leading-6 text-gray-900">+ πͺ’ Langfuse</div>- <FeedbackButtonWrapper>- <Button variant="outline" color="gray" size="sm">- <MessageSquarePlus- className="mr-2 h-4 w-4 shrink-0 text-primary"- aria-hidden="true"- />- <span>Feedback</span>- </Button>- </FeedbackButtonWrapper><Menu as="div" className="relative"><Menu.Button className="flex items-center gap-x-4 text-sm font-semibold leading-6 text-gray-900"><span className="sr-only">Open user menu</span>@@ -485,42 +476,22 @@ export default function Layout(props: PropsWithChildren) {</Transition></Menu></div>- <div className="lg:pl-72">+ <div className="xl:pl-72">{env.NEXT_PUBLIC_DEMO_PROJECT_ID &&projectId === env.NEXT_PUBLIC_DEMO_PROJECT_ID ? (- <div className="flex w-full items-center border-b border-yellow-500 bg-yellow-100 px-4 py-2 lg:sticky lg:top-0 lg:z-40">+ <div className="flex w-full items-center border-b border-yellow-500 bg-yellow-100 px-4 py-2 xl:sticky xl:top-0 xl:z-40"><div className="flex flex-1 flex-wrap gap-1"><div className="flex items-center gap-1"><Info className="h-4 w-4" /><span className="font-semibold">DEMO (view-only)</span></div>- <div className="hidden sm:block">- Live data from the Langfuse Q&A Chatbot.- </div>- </div>- <div className="ml-2">- <Button- size="sm"- variant="ghost"- className="hidden md:inline"- asChild- >- <Link- href="https://langfuse.com/blog/qa-chatbot-for-langfuse-docs"- target="_blank"- >- Blog post β- </Link>- </Button>- <Button size="sm" className="ml-3" asChild>- <Link- href="https://langfuse.com/docs/qa-chatbot"- target="_blank"- >- Q&A Chatbot β- </Link>- </Button>+ <div>Live data from the Langfuse Q&A Chatbot.</div></div>+ <Button size="sm" variant="ghost" asChild className="ml-2">+ <Link href="https://langfuse.com/docs/demo" target="_blank">+ Learn more β+ </Link>+ </Button></div>) : null}<main className="py-4">diff --git a/src/components/layouts/routes.ts b/src/components/layouts/routes.tsindex a9e88abd8d..e271663999 100644--- a/src/components/layouts/routes.ts+++ b/src/components/layouts/routes.ts@@ -1,12 +1,11 @@import {- Cog6ToothIcon,- DocumentDuplicateIcon,-} from "@heroicons/react/20/solid";-import {- BarChart3,+ FlaskConical,HelpingHand,- HomeIcon,+ LayoutDashboard,LineChart,+ ListTree,+ Settings,+ TextSelect,UsersIcon,} from "lucide-react";@@ -14,22 +13,22 @@ export const ROUTES = [{name: "Dashboard",pathname: `/project/[projectId]`,- icon: HomeIcon,+ icon: LayoutDashboard,},{name: "Analytics (alpha)",pathname: `/project/[projectId]/analytics`,- icon: BarChart3,+ icon: FlaskConical,},{name: "Traces",pathname: `/project/[projectId]/traces`,- icon: UsersIcon,+ icon: ListTree,},{name: "Generations",pathname: `/project/[projectId]/generations`,- icon: DocumentDuplicateIcon,+ icon: TextSelect,},{name: "Scores",@@ -44,7 +43,7 @@ export const ROUTES = [{name: "Settings",pathname: "/project/[projectId]/settings",- icon: Cog6ToothIcon,+ icon: Settings,},{name: "Talk to founder",diff --git a/src/components/table/data-table-toolbar.tsx b/src/components/table/data-table-toolbar.tsxindex 71e9a32ffc..f8d4d36e85 100644--- a/src/components/table/data-table-toolbar.tsx+++ b/src/components/table/data-table-toolbar.tsx@@ -34,7 +34,7 @@ export function DataTableToolbar<TData, TValue>({);return (- <div className="my-2 flex items-center justify-between">+ <div className="my-2 flex max-w-full items-center justify-between overflow-x-auto"><div className="flex flex-1 items-center space-x-2">{searchConfig ? (<div className="flex w-full max-w-md items-center space-x-2">diff --git a/src/components/table/data-table.tsx b/src/components/table/data-table.tsxindex 613273eb71..bdd2ef64eb 100644--- a/src/components/table/data-table.tsx+++ b/src/components/table/data-table.tsx@@ -60,7 +60,10 @@ export function DataTable<TData, TValue>({<TableRow key={headerGroup.id}>{headerGroup.headers.map((header) => {return (- <TableHead key={header.id}>+ <TableHead+ key={header.id}+ className="whitespace-nowrap p-2"+ >{header.isPlaceholder? null: flexRender(@@ -90,7 +93,10 @@ export function DataTable<TData, TValue>({data-state={row.getIsSelected() && "selected"}>{row.getVisibleCells().map((cell) => (- <TableCell key={cell.id}>+ <TableCell+ key={cell.id}+ className="whitespace-nowrap p-2 text-xs"+ >{flexRender(cell.column.columnDef.cell,cell.getContext()diff --git a/src/components/table/use-cases/traces.tsx b/src/components/table/use-cases/traces.tsxindex 569ef19546..8884fbbe35 100644--- a/src/components/table/use-cases/traces.tsx+++ b/src/components/table/use-cases/traces.tsx@@ -100,6 +100,7 @@ export default function TracesTable({ projectId, userId }: TraceTableProps) {const columns: ColumnDef<TraceTableRow>[] = [{accessorKey: "id",+ header: "ID",cell: ({ row }) => {const value = row.getValue("id");return typeof value === "string" ? (@@ -142,6 +143,15 @@ export default function TracesTable({ projectId, userId }: TraceTableProps) {{accessorKey: "userId",header: "User ID",+ cell: ({ row }) => {+ const value = row.getValue("userId");+ return typeof value === "string" ? (+ <TableLink+ path={`/project/${projectId}/users/${value}`}+ value={value}+ />+ ) : undefined;+ },},{accessorKey: "usage",@@ -157,6 +167,7 @@ export default function TracesTable({ projectId, userId }: TraceTableProps) {promptTokens={value.promptTokens}completionTokens={value.completionTokens}totalTokens={value.totalTokens}+ inline/>);},@@ -183,8 +194,8 @@ export default function TracesTable({ projectId, userId }: TraceTableProps) {cell: ({ row }) => {const values: Score[] = row.getValue("scores");return (- <div className="flex flex-col">- <GroupedScoreBadges scores={values} />+ <div className="flex flex-wrap gap-x-3 gap-y-1">+ <GroupedScoreBadges scores={values} inline /></div>);},diff --git a/src/components/token-usage-badge.tsx b/src/components/token-usage-badge.tsxindex 98111189fa..3de29cfb55 100644--- a/src/components/token-usage-badge.tsx+++ b/src/components/token-usage-badge.tsx@@ -18,13 +18,17 @@ export const TraceAggUsageBadge = (props: { observations: Observation[] }) => {export const TokenUsageBadge = (props:- | {- observation: Observation;- }- | {- promptTokens: number;- completionTokens: number;- totalTokens: number;+ | (+ | {+ observation: Observation;+ }+ | {+ promptTokens: number;+ completionTokens: number;+ totalTokens: number;+ }+ ) & {+ inline?: boolean;}) => {const usage =@@ -36,6 +40,13 @@ export const TokenUsageBadge = (}: props;+ if (props.inline)+ return (+ <span>+ {usage.promptTokens} β {usage.completionTokens} (β {usage.totalTokens})+ </span>+ );+return (<Badge variant="outline">{usage.promptTokens} β {usage.completionTokens} (β {usage.totalTokens})diff --git a/src/components/trace/ObservationPreview.tsx b/src/components/trace/ObservationPreview.tsxindex 4d9f8cd5c6..2730aa9695 100644--- a/src/components/trace/ObservationPreview.tsx+++ b/src/components/trace/ObservationPreview.tsx@@ -30,7 +30,7 @@ export const ObservationPreview = (props: {if (!observation) return <div className="flex-1">Not found</div>;return (<Card className="flex-1">- <CardHeader className="flex items-start gap-2 sm:flex-row sm:justify-between">+ <CardHeader className="flex flex-row flex-wrap justify-between gap-2"><div className="flex flex-col gap-1"><CardTitle><span className="mr-2 rounded-sm bg-gray-200 p-1 text-xs">diff --git a/src/components/trace/ObservationTree.tsx b/src/components/trace/ObservationTree.tsxindex c0d9aad75d..a309f161eb 100644--- a/src/components/trace/ObservationTree.tsx+++ b/src/components/trace/ObservationTree.tsx@@ -55,7 +55,7 @@ const ObservationTreeTraceNode = (props: {{props.trace.timestamp.toLocaleString()}</span></div>- <div className="flex flex-wrap gap-2">+ <div className="flex flex-wrap gap-1">{props.scores.find((s) => s.observationId === null) ? (<GroupedScoreBadgesscores={props.scores.filter((s) => s.observationId === null)}@@ -90,10 +90,14 @@ const ObservationTreeNode = (props: {onClick={() => props.setCurrentObservationId(observation.id)}><div className="flex gap-2">- <span className={cn("rounded-sm bg-gray-200 p-1 text-xs")}>+ <span+ className={cn(+ "self-start rounded-sm bg-gray-200 p-1 text-xs"+ )}+ >{observation.type}</span>- <span>{observation.name}</span>+ <span className="line-clamp-1">{observation.name}</span></div><div className="flex gap-2">{observation.endTime ? (@@ -103,10 +107,14 @@ const ObservationTreeNode = (props: {ms</span>) : null}- <span className="text-xs text-gray-500">- {observation.promptTokens} β {observation.completionTokens} (β{" "}- {observation.totalTokens})- </span>+ {observation.promptTokens ||+ observation.completionTokens ||+ observation.totalTokens ? (+ <span className="text-xs text-gray-500">+ {observation.promptTokens} β {observation.completionTokens}{" "}+ (β {observation.totalTokens})+ </span>+ ) : null}</div>{observation.level !== "DEFAULT" ? (<div className="flex">@@ -122,7 +130,7 @@ const ObservationTreeNode = (props: {</div>) : null}{props.scores.find((s) => s.observationId === observation.id) ? (- <div className="flex flex-wrap gap-2">+ <div className="flex flex-wrap gap-1"><GroupedScoreBadgesscores={props.scores.filter((s) => s.observationId === observation.iddiff --git a/src/components/trace/TracePreview.tsx b/src/components/trace/TracePreview.tsxindex dd42019e55..dd9c00a9c6 100644--- a/src/components/trace/TracePreview.tsx+++ b/src/components/trace/TracePreview.tsx@@ -31,7 +31,7 @@ export const TracePreview = ({}) => {return (<Card className="flex-1">- <CardHeader className="flex items-start gap-2 sm:flex-row sm:justify-between">+ <CardHeader className="flex flex-row flex-wrap justify-between gap-2"><div className="flex flex-col gap-1"><CardTitle><span className="mr-2 rounded-sm bg-gray-200 p-1 text-xs">diff --git a/src/features/dashboard/components/BaseTimeSeriesChart.tsx b/src/features/dashboard/components/BaseTimeSeriesChart.tsxindex 04689991f7..270013fd05 100644--- a/src/features/dashboard/components/BaseTimeSeriesChart.tsx+++ b/src/features/dashboard/components/BaseTimeSeriesChart.tsx@@ -5,6 +5,7 @@ import { AreaChart } from "@tremor/react";export function BaseTimeSeriesChart(props: {agg: DateTimeAggregationOption;data: { ts: number; values: { label: string; value: number }[] }[];+ connectNulls?: boolean;}) {const labels = new Set(props.data.flatMap((d) => d.values.map((v) => v.label))@@ -52,8 +53,10 @@ export function BaseTimeSeriesChart(props: {data={transformArray(props.data)}index="timestamp"categories={Array.from(labels)}+ connectNulls={props.connectNulls}colors={["indigo", "cyan"]}valueFormatter={numberFormatter}+ noDataText="Loading ..."/>);}diff --git a/src/features/dashboard/components/charts.tsx b/src/features/dashboard/components/charts.tsxindex 82c7e1a0e5..f7e087db47 100644--- a/src/features/dashboard/components/charts.tsx+++ b/src/features/dashboard/components/charts.tsx@@ -9,6 +9,14 @@ import {import { BaseTimeSeriesChart } from "./BaseTimeSeriesChart";import { type DateTimeAggregationOption } from "@/src/features/dashboard/lib/timeseriesAggregation";import { Loader } from "lucide-react";+import { useState } from "react";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/src/components/ui/select";export function ChartGenerations(props: {agg: DateTimeAggregationOption;@@ -85,7 +93,90 @@ export function ChartScores(props: {) : null}</CardHeader><CardContent>- <BaseTimeSeriesChart agg={props.agg} data={data.data ?? []} />+ <BaseTimeSeriesChart+ agg={props.agg}+ data={data.data ?? []}+ connectNulls+ />+ </CardContent>+ </Card>+ );+}++const metricOptions = [+ { label: "Total Tokens", value: "totalTokens" },+ { label: "Prompt Tokens", value: "promptTokens" },+ { label: "Completion Tokens", value: "completionTokens" },+] as const;++export function ChartUsage(props: {+ agg: DateTimeAggregationOption;+ projectId: string;+}) {+ const data = api.dashboard.tokenUsage.useQuery({+ agg: props.agg,+ projectId: props.projectId,+ });++ const [metric, setMetric] =+ useState<(typeof metricOptions)[number]["value"]>("totalTokens");++ // Typesafe selection of metric+ const filteredData =+ (metric === "totalTokens"+ ? data.data?.map((row) => ({+ ts: row.ts,+ values: row.totalTokens,+ }))+ : metric === "promptTokens"+ ? data.data?.map((row) => ({+ ts: row.ts,+ values: row.promptTokens,+ }))+ : data.data?.map((row) => ({+ ts: row.ts,+ values: row.completionTokens,+ }))) ?? [];++ return (+ <Card>+ <CardHeader className="relative">+ <CardTitle>Token Usage</CardTitle>+ <CardDescription></CardDescription>+ <div className="absolute right-5 top-5 ">+ {data.isLoading ? (+ <Loader className="h-5 w-5 animate-spin" />+ ) : (+ <Select+ onValueChange={(value) => setMetric(value as typeof metric)}+ value={metric}+ >+ <SelectTrigger className="w-[180px]">+ <SelectValue placeholder="Metric" />+ </SelectTrigger>+ <SelectContent>+ {metricOptions.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}+ </div>+ </CardHeader>+ <CardContent>+ <BaseTimeSeriesChart+ agg={props.agg}+ data={+ filteredData.map((row) => ({+ ts: row.ts,+ values: Object.entries(row.values ?? []).map(+ ([label, value]) => ({ label, value })+ ),+ })) ?? []+ }+ /></CardContent></Card>);diff --git a/src/features/dashboard/server/dashboardRouter.ts b/src/features/dashboard/server/dashboardRouter.tsindex 5d8fd57d69..3f9d42c0e6 100644--- a/src/features/dashboard/server/dashboardRouter.ts+++ b/src/features/dashboard/server/dashboardRouter.ts@@ -200,4 +200,70 @@ export const dashboardRouter = createTRPCRouter({ts: row.date_trunc.getTime(),}));}),+ tokenUsage: protectedProjectProcedure+ .input(+ z.object({+ projectId: z.string(),+ agg: z.enum(dateTimeAggregationOptions),+ })+ )+ .query(async ({ input, ctx }) => {+ const output = await ctx.prisma.$queryRawUnsafe<+ {+ date: Date;+ promptTokens: { [model: string]: number } | null;+ completionTokens: { [model: string]: number } | null;+ totalTokens: { [model: string]: number } | null;+ }[]+ >(`+ WITH timeseries AS (+ SELECT+ date_trunc('${+ dateTimeAggregationSettings[input.agg].date_trunc+ }', dt) as date_trunc+ FROM generate_series(+ NOW() - INTERVAL '${input.agg}', NOW(), INTERVAL '1 minute'+ ) as dt+ WHERE dt > NOW() - INTERVAL '${input.agg}'+ GROUP BY 1+ ),+ token_usage AS (+ SELECT+ date_trunc('${+ dateTimeAggregationSettings[input.agg].date_trunc+ }', start_time) as date_trunc,+ COALESCE(model, 'undefined') model,+ sum(prompt_tokens) prompt_tokens,+ sum(completion_tokens) completion_tokens,+ sum(total_tokens) total_tokens+ from observations+ WHERE start_time > NOW() - INTERVAL '${input.agg}'+ AND project_id = '${input.projectId}'+ GROUP BY 1,2+ HAVING sum(prompt_tokens) > 0 OR sum(completion_tokens) > 0 or sum(total_tokens) > 0+ ORDER BY 1,2+ ),+ json_metrics as (+ SELECT+ date_trunc,+ jsonb_object_agg(model, prompt_tokens) as prompt_tokens,+ jsonb_object_agg(model, completion_tokens) as completion_tokens,+ jsonb_object_agg(model, total_tokens) as total_tokens+ from token_usage+ GROUP BY 1+ )+ SELECT+ timeseries.date_trunc as "date",+ prompt_tokens "promptTokens",+ completion_tokens "completionTokens",+ total_tokens "totalTokens"+ FROM timeseries+ LEFT JOIN json_metrics ON timeseries.date_trunc = json_metrics.date_trunc+ `);++ return output.map((row) => ({+ ...row,+ ts: row.date.getTime(),+ }));+ }),});diff --git a/src/pages/auth/sign-in.tsx b/src/pages/auth/sign-in.tsxindex 09b0176eb2..5404542d2f 100644--- a/src/pages/auth/sign-in.tsx+++ b/src/pages/auth/sign-in.tsx@@ -44,7 +44,7 @@ export default function SignIn() {<Head><title>Sign in | Langfuse</title></Head>- <div className="flex min-h-full flex-1 flex-col justify-center py-12 sm:px-6 lg:px-8">+ <div className="flex flex-1 flex-col py-6 sm:min-h-full sm:justify-center sm:px-6 sm:py-12 lg:px-8"><div className="sm:mx-auto sm:w-full sm:max-w-md"><span className="block text-center font-mono text-4xl font-bold">πͺ’diff --git a/src/pages/auth/sign-up.tsx b/src/pages/auth/sign-up.tsxindex 88412e392d..8f0cb14ee9 100644--- a/src/pages/auth/sign-up.tsx+++ b/src/pages/auth/sign-up.tsx@@ -133,6 +133,35 @@ export default function SignIn() {</Button></form></Form>+ {env.NEXT_PUBLIC_HOSTNAME !== "cloud.langfuse.com" ? (+ <div className="-mb-4 mt-8 text-center text-xs text-gray-500">+ By creating an account you are agreeing to our{" "}+ <a+ href="https://app.termly.io/document/terms-of-service/baf80a2e-dc67-46de-9ca8-2f7457179c32"+ target="_blank"+ rel="noopener noreferrer"+ className="italic"+ >+ Terms of Service+ </a>+ ,{" "}+ <a+ href="https://app.termly.io/document/privacy-policy/47905712-56e1-4ad0-9bb7-8958f3263f90"+ rel="noopener noreferrer"+ className="italic"+ >+ Privacy Policy+ </a>+ , and{" "}+ <a+ href="https://app.termly.io/document/cookie-policy/f97945a3-cb02-4db7-9370-c57023d92838"+ rel="noopener noreferrer"+ className="italic"+ >+ Cookie Policy+ </a>+ </div>+ ) : null}</div><p className="mt-10 text-center text-sm text-gray-500">diff --git a/src/pages/project/[projectId]/generations.tsx b/src/pages/project/[projectId]/generations.tsxindex b5548718c1..bfe7c59a4b 100644--- a/src/pages/project/[projectId]/generations.tsx+++ b/src/pages/project/[projectId]/generations.tsx@@ -117,6 +117,7 @@ export default function Generations() {promptTokens={value.promptTokens}completionTokens={value.completionTokens}totalTokens={value.totalTokens}+ inline/>);},@@ -157,7 +158,7 @@ export default function Generations() {startTime: generation.startTime.toLocaleString(),endTime: generation.endTime?.toLocaleString() ?? undefined,name: generation.name ?? undefined,- model: JSON.stringify(generation.model),+ model: generation.model ?? "",usage: {promptTokens: generation.promptTokens,completionTokens: generation.completionTokens,diff --git a/src/pages/project/[projectId]/index.tsx b/src/pages/project/[projectId]/index.tsxindex 2960197a6c..100ca77294 100644--- a/src/pages/project/[projectId]/index.tsx+++ b/src/pages/project/[projectId]/index.tsx@@ -6,9 +6,9 @@ import {type DateTimeAggregationOption,} from "@/src/features/dashboard/lib/timeseriesAggregation";import {- ChartGenerations,ChartScores,ChartTraces,+ ChartUsage,} from "@/src/features/dashboard/components/charts";import { useRouter } from "next/router";@@ -23,7 +23,7 @@ export default function Start() {<Tabsvalue={agg}onValueChange={(value) => setAgg(value as DateTimeAggregationOption)}- className="mb-4"+ className="mb-4 max-w-full overflow-x-auto"><TabsList>{dateTimeAggregationOptions.map((option) => (@@ -35,7 +35,8 @@ export default function Start() {</Tabs><div className="grid gap-4 xl:grid-cols-2"><ChartTraces agg={agg} projectId={projectId} />- <ChartGenerations agg={agg} projectId={projectId} />+ {/* <ChartGenerations agg={agg} projectId={projectId} /> */}+ <ChartUsage agg={agg} projectId={projectId} /><div className="col-span-full"><ChartScores agg={agg} projectId={projectId} /></div>diff --git a/src/server/api/routers/traces.ts b/src/server/api/routers/traces.tsindex 1a4e38518a..821eb02edd 100644--- a/src/server/api/routers/traces.ts+++ b/src/server/api/routers/traces.ts@@ -88,6 +88,8 @@ export const traceRouter = createTRPCRouter({)SELECTt.*,+ t."external_id" AS "externalId",+ t."user_id" AS "userId",COALESCE(u."promptTokens", 0)::int AS "promptTokens",COALESCE(u."completionTokens", 0)::int AS "completionTokens",COALESCE(u."totalTokens", 0)::int AS "totalTokens"@@ -107,7 +109,10 @@ export const traceRouter = createTRPCRouter({const scores = traces.length? await ctx.prisma.$queryRaw<Score[]>(Prisma.sql`- SELECT s.*+ SELECT+ s.*,+ s."trace_id" AS "traceId",+ s."observation_id" AS "observationId"FROM "scores" sWHERE s."trace_id" IN (${Prisma.join(traces.map((trace) => trace.id)@@ -115,10 +120,12 @@ export const traceRouter = createTRPCRouter({): [];- return traces.map((trace) => ({+ const res = traces.map((trace) => ({...trace,scores: scores.filter((score) => score.traceId === trace.id),}));+ console.log(res);+ return res;}),availableFilterOptions: protectedProjectProcedure.input(TraceFilterOptions)