🪢 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
Chart design (#17)
Maximilian Deichmanncf6cc206e077
diff --git a/package-lock.json b/package-lock.jsonindex 65c8f0ad10..d51a0d0fa3 100644--- a/package-lock.json+++ b/package-lock.json@@ -31,6 +31,7 @@"@tailwindcss/forms": "^0.5.3","@tanstack/react-query": "^4.29.12","@tanstack/react-table": "^8.9.1",+ "@tremor/react": "^3.2.2","@trpc/client": "^10.28.1","@trpc/next": "^10.28.1","@trpc/react-query": "^10.28.1",@@ -50,7 +51,6 @@"react-dom": "18.2.0","react-hook-form": "^7.44.2","react-icons": "^4.9.0",- "recharts": "^2.6.2","superjson": "1.12.3","tailwind-merge": "^1.12.0","tailwindcss-animate": "^1.0.5",@@ -497,6 +497,20 @@"@floating-ui/core": "^1.2.6"}},+ "node_modules/@floating-ui/react": {+ "version": "0.19.2",+ "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.19.2.tgz",+ "integrity": "sha512-JyNk4A0Ezirq8FlXECvRtQOX/iBe5Ize0W/pLkrZjfHW9GUV7Xnq6zm6fyZuQzaHHqEnVizmvlA96e1/CkZv+w==",+ "dependencies": {+ "@floating-ui/react-dom": "^1.3.0",+ "aria-hidden": "^1.1.3",+ "tabbable": "^6.0.1"+ },+ "peerDependencies": {+ "react": ">=16.8.0",+ "react-dom": ">=16.8.0"+ }+ },"node_modules/@floating-ui/react-dom": {"version": "2.0.0","resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.0.tgz",@@ -509,6 +523,18 @@"react-dom": ">=16.8.0"}},+ "node_modules/@floating-ui/react/node_modules/@floating-ui/react-dom": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-1.3.0.tgz",+ "integrity": "sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g==",+ "dependencies": {+ "@floating-ui/dom": "^1.2.1"+ },+ "peerDependencies": {+ "react": ">=16.8.0",+ "react-dom": ">=16.8.0"+ }+ },"node_modules/@headlessui/react": {"version": "1.7.14","resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.7.14.tgz",@@ -524,6 +550,17 @@"react-dom": "^16 || ^17 || ^18"}},+ "node_modules/@headlessui/tailwindcss": {+ "version": "0.1.3",+ "resolved": "https://registry.npmjs.org/@headlessui/tailwindcss/-/tailwindcss-0.1.3.tgz",+ "integrity": "sha512-3aMdDyYZx9A15euRehpppSyQnb2gIw2s/Uccn2ELIoLQ9oDy0+9oRygNWNjXCD5Dt+w1pxo7C+XoiYvGcqA4Kg==",+ "engines": {+ "node": ">=10"+ },+ "peerDependencies": {+ "tailwindcss": "^3.0"+ }+ },"node_modules/@heroicons/react": {"version": "2.0.18","resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.18.tgz",@@ -1838,6 +1875,49 @@"url": "https://github.com/sponsors/tannerlinsley"}},+ "node_modules/@tremor/react": {+ "version": "3.2.2",+ "resolved": "https://registry.npmjs.org/@tremor/react/-/react-3.2.2.tgz",+ "integrity": "sha512-H475/bQWtxiT34X6UwmJ2LPIW0Ezwc1eUi1X2HXA+uK+3eVfz9YbOqNDewt4mgPpg+tZSHun0aTCMsb0rVV2rQ==",+ "dependencies": {+ "@floating-ui/react": "^0.19.1",+ "@headlessui/react": "^1.7.14",+ "@headlessui/tailwindcss": "^0.1.3",+ "date-fns": "^2.28.0",+ "react-day-picker": "^8.7.1",+ "react-transition-group": "^4.4.5",+ "recharts": "^2.7.1",+ "tailwind-merge": "^1.9.1"+ },+ "peerDependencies": {+ "react": "^18.0.0",+ "react-dom": ">=16.6.0"+ }+ },+ "node_modules/@tremor/react/node_modules/dom-helpers": {+ "version": "5.2.1",+ "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",+ "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",+ "dependencies": {+ "@babel/runtime": "^7.8.7",+ "csstype": "^3.0.2"+ }+ },+ "node_modules/@tremor/react/node_modules/react-transition-group": {+ "version": "4.4.5",+ "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",+ "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==",+ "dependencies": {+ "@babel/runtime": "^7.5.5",+ "dom-helpers": "^5.0.1",+ "loose-envify": "^1.4.0",+ "prop-types": "^15.6.2"+ },+ "peerDependencies": {+ "react": ">=16.6.0",+ "react-dom": ">=16.6.0"+ }+ },"node_modules/@trpc/client": {"version": "10.28.2","resolved": "https://registry.npmjs.org/@trpc/client/-/client-10.28.2.tgz",@@ -3336,6 +3416,21 @@"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==","dev": true},+ "node_modules/date-fns": {+ "version": "2.30.0",+ "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",+ "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",+ "dependencies": {+ "@babel/runtime": "^7.21.0"+ },+ "engines": {+ "node": ">=0.11"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/date-fns"+ }+ },"node_modules/debug": {"version": "4.3.4","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",@@ -6276,6 +6371,19 @@"node": ">=0.10.0"}},+ "node_modules/react-day-picker": {+ "version": "8.7.1",+ "resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-8.7.1.tgz",+ "integrity": "sha512-Gv426AW8b151CZfh3aP5RUGztLwHB/EyJgWZ5iMgtzbFBkjHfG6Y66CIQFMWGLnYjsQ9DYSJRmJ5S0Pg5HWKjA==",+ "funding": {+ "type": "individual",+ "url": "https://github.com/sponsors/gpbl"+ },+ "peerDependencies": {+ "date-fns": "^2.28.0",+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"+ }+ },"node_modules/react-dom": {"version": "18.2.0","resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",@@ -6457,9 +6565,9 @@}},"node_modules/recharts": {- "version": "2.6.2",- "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.6.2.tgz",- "integrity": "sha512-dVhNfgI21LlF+4AesO3mj+i+9YdAAjoGaDWIctUgH/G2iy14YVtb/DSUeic77xr19rbKCiq+pQGfeg2kJQDHig==",+ "version": "2.7.1",+ "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.7.1.tgz",+ "integrity": "sha512-lr4rVlyddTjhXbX6doElETM/2ya1BJ7L367rdAwMavL68DVn/Zkm1hcdlZtOX2QT2yaR8sQ5Ana66HPT7lFDIA==","dependencies": {"classnames": "^2.2.5","eventemitter3": "^4.0.1",@@ -7121,6 +7229,11 @@"url": "https://opencollective.com/unts"}},+ "node_modules/tabbable": {+ "version": "6.1.2",+ "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.1.2.tgz",+ "integrity": "sha512-qCN98uP7i9z0fIS4amQ5zbGBOq+OSigYeGvPy7NDk8Y9yncqDZ9pRPgfsc2PJIVM9RrJj7GIfuRgmjoUU9zTHQ=="+ },"node_modules/tailwind-merge": {"version": "1.12.0","resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.12.0.tgz",diff --git a/package.json b/package.jsonindex 730030bf62..ff35ba9570 100644--- a/package.json+++ b/package.json@@ -36,6 +36,7 @@"@tailwindcss/forms": "^0.5.3","@tanstack/react-query": "^4.29.12","@tanstack/react-table": "^8.9.1",+ "@tremor/react": "^3.2.2","@trpc/client": "^10.28.1","@trpc/next": "^10.28.1","@trpc/react-query": "^10.28.1",@@ -55,7 +56,6 @@"react-dom": "18.2.0","react-hook-form": "^7.44.2","react-icons": "^4.9.0",- "recharts": "^2.6.2","superjson": "1.12.3","tailwind-merge": "^1.12.0","tailwindcss-animate": "^1.0.5",diff --git a/src/features/dashboard/components/BaseTimeSeriesChart.tsx b/src/features/dashboard/components/BaseTimeSeriesChart.tsxindex a1c916e69d..771187a9d1 100644--- a/src/features/dashboard/components/BaseTimeSeriesChart.tsx+++ b/src/features/dashboard/components/BaseTimeSeriesChart.tsx@@ -1,95 +1,62 @@-import {- LineChart,- Line,- XAxis,- ResponsiveContainer,- Tooltip,- YAxis,- Label,- Legend,-} from "recharts";-import {- dateTimeAggregationSettings,- type DateTimeAggregationOption,-} from "@/src/features/dashboard/lib/timeseriesAggregation";+import { type DateTimeAggregationOption } from "@/src/features/dashboard/lib/timeseriesAggregation";+import { AreaChart } from "@tremor/react";export function BaseTimeSeriesChart(props: {agg: DateTimeAggregationOption;data: { ts: number; values: { label: string; value: number }[] }[];}) {- const series = [- ...new Set(props.data.flatMap((row) => row.values.map((v) => v.label))),- ];+ const labels = new Set(+ props.data.flatMap((d) => d.values.map((v) => v.label))+ );++ type ChartInput = { timestamp: string } & { [key: string]: number };++ function transformArray(+ array: { ts: number; values: { label: string; value: number }[] }[]+ ): ChartInput[] {+ return array.map((item) => {+ const outputObject: ChartInput = {+ timestamp: convertDate(item.ts, props.agg),+ } as ChartInput;++ item.values.forEach((valueObject) => {+ outputObject[valueObject.label] = valueObject.value;+ });- const chartData = props.data.map((d) => ({- ts: d.ts,- ...d.values.reduce((acc, v) => ({ ...acc, [v.label]: v.value }), {}),- }));+ return outputObject;+ });+ }++ const dataFormatter = (number: number) => {+ return Intl.NumberFormat("us").format(number).toString();+ };++ const convertDate = (date: number, agg: DateTimeAggregationOption) => {+ if (agg === "24 hours" || agg === "1 hour") {+ return new Date(date).toLocaleTimeString("en-US", {+ year: "2-digit",+ month: "numeric",+ day: "numeric",+ hour: "2-digit",+ minute: "2-digit",+ });+ }++ return new Date(date).toLocaleDateString("en-US", {+ year: "2-digit",+ month: "numeric",+ day: "numeric",+ });+ };return (- <ResponsiveContainer width={"100%"} height={300}>- <LineChart data={chartData} key={props.agg}>- {series.map((s, i) => (- <Line- key={s}- type="monotone"- dataKey={s}- isAnimationActive={false}- strokeWidth={3}- dot={{ strokeWidth: 2 }}- stroke={chartColors[i % chartColors.length]}- />- ))}- <XAxis- dataKey="ts"- type="number"- domain={["dataMin", "dataMax"]}- interval="preserveStartEnd"- scale="time"- tickLine- tickCount={10}- tickFormatter={(val, _index) =>- dateTimeAggregationSettings[props.agg].date_formatter(- new Date(val as number)- )- }- >- <Label- value={dateTimeAggregationSettings[props.agg].date_trunc}- offset={0}- position="insideBottom"- />- </XAxis>- <YAxis />- <Tooltip- labelFormatter={(val) =>- dateTimeAggregationSettings[props.agg].date_formatter(- new Date(val as number)- )- }- />- {series.length > 1 ? <Legend verticalAlign="top" height={36} /> : null}- </LineChart>- </ResponsiveContainer>+ <AreaChart+ className="mt-4 h-72"+ data={transformArray(props.data)}+ index="timestamp"+ categories={Array.from(labels)}+ colors={["indigo", "cyan"]}+ valueFormatter={dataFormatter}+ />);}--const chartColors = [- "#4c51bf", // Indigo- "#f56565", // Red- "#48bb78", // Green- "#ed8936", // Orange- "#6b46c1", // Purple- "#38a169", // Teal- "#e53e3e", // Pink- "#3182ce", // Blue- "#718096", // Gray- "#9f7aea", // Indigo (lighter shade)- "#f6ad55", // Red (lighter shade)- "#68d391", // Green (lighter shade)- "#f6ad55", // Orange (lighter shade)- "#9f7aea", // Purple (lighter shade)- "#4fd1c5", // Teal (lighter shade)- "#ed64a6", // Pink (lighter shade)- "#4299e1", // Blue (lighter shade)-];diff --git a/tailwind.config.ts b/tailwind.config.tsindex 78e3a8a271..fde2e8e0bd 100644--- a/tailwind.config.ts+++ b/tailwind.config.ts@@ -3,7 +3,10 @@ import { type Config } from "tailwindcss";// Based on: https://ui.shadcn.com/docs/installation#configure-tailwindconfigjsexport default {- content: ["./src/**/*.{js,ts,jsx,tsx}"],+ content: [+ "./src/**/*.{js,ts,jsx,tsx}",+ "./node_modules/@tremor/**/*.{js,ts,jsx,tsx}", // Tremor module+ ],darkMode: ["class"],theme: {container: {@@ -15,6 +18,65 @@ export default {},extend: {colors: {+ tremor: {+ brand: {+ faint: "#eff6ff", // blue-50+ muted: "#bfdbfe", // blue-200+ subtle: "#60a5fa", // blue-400+ DEFAULT: "#3b82f6", // blue-500+ emphasis: "#1d4ed8", // blue-700+ inverted: "#ffffff", // white+ },+ background: {+ muted: "#f9fafb", // gray-50+ subtle: "#f3f4f6", // gray-100+ DEFAULT: "#ffffff", // white+ emphasis: "#374151", // gray-700+ },+ border: {+ DEFAULT: "#e5e7eb", // gray-200+ },+ ring: {+ DEFAULT: "#e5e7eb", // gray-200+ },+ content: {+ subtle: "#9ca3af", // gray-400+ DEFAULT: "#6b7280", // gray-500+ emphasis: "#374151", // gray-700+ strong: "#111827", // gray-900+ inverted: "#ffffff", // white+ },+ },+ // dark mode+ "dark-tremor": {+ brand: {+ faint: "#0B1229", // custom+ muted: "#172554", // blue-950+ subtle: "#1e40af", // blue-800+ DEFAULT: "#3b82f6", // blue-500+ emphasis: "#60a5fa", // blue-400+ inverted: "#030712", // gray-950+ },+ background: {+ muted: "#131A2B", // custom+ subtle: "#1f2937", // gray-800+ DEFAULT: "#111827", // gray-900+ emphasis: "#d1d5db", // gray-300+ },+ border: {+ DEFAULT: "#1f2937", // gray-800+ },+ ring: {+ DEFAULT: "#1f2937", // gray-800+ },+ content: {+ subtle: "#4b5563", // gray-600+ DEFAULT: "#6b7280", // gray-600+ emphasis: "#e5e7eb", // gray-200+ strong: "#f9fafb", // gray-50+ inverted: "#000000", // black+ },+ },border: "hsl(var(--border))",input: "hsl(var(--input))",ring: "hsl(var(--ring))",@@ -49,11 +111,34 @@ export default {foreground: "hsl(var(--card-foreground))",},},+ boxShadow: {+ // light+ "tremor-input": "0 1px 2px 0 rgb(0 0 0 / 0.05)",+ "tremor-card":+ "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",+ "tremor-dropdown":+ "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",+ // dark+ "dark-tremor-input": "0 1px 2px 0 rgb(0 0 0 / 0.05)",+ "dark-tremor-card":+ "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",+ "dark-tremor-dropdown":+ "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",+ },borderRadius: {+ "tremor-small": "0.375rem",+ "tremor-default": "0.5rem",+ "tremor-full": "9999px",lg: `var(--radius)`,md: `calc(var(--radius) - 2px)`,sm: "calc(var(--radius) - 4px)",},+ fontSize: {+ "tremor-label": "0.75rem",+ "tremor-default": ["0.875rem", { lineHeight: "1.25rem" }],+ "tremor-title": ["1.125rem", { lineHeight: "1.75rem" }],+ "tremor-metric": ["1.875rem", { lineHeight: "2.25rem" }],+ },// fontFamily: {// sans: ["var(--font-sans)", ...fontFamily.sans],// },@@ -73,5 +158,34 @@ export default {},},},+ safelist: [+ {+ pattern:+ /^(bg-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ variants: ["hover", "ui-selected"],+ },+ {+ pattern:+ /^(text-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ variants: ["hover", "ui-selected"],+ },+ {+ pattern:+ /^(border-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ variants: ["hover", "ui-selected"],+ },+ {+ pattern:+ /^(ring-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ },+ {+ pattern:+ /^(stroke-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ },+ {+ pattern:+ /^(fill-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/,+ },+ ],plugins: [require("@tailwindcss/forms"), require("tailwindcss-animate")],} satisfies Config;