🪢 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
ui
Marc Klingena28a1541d9de
diff --git a/src/components/ui/code.tsx b/src/components/ui/code.tsxnew file mode 100644index 0000000000..438485a845--- /dev/null+++ b/src/components/ui/code.tsx@@ -0,0 +1,18 @@+import { type PropsWithChildren } from "react";++export function JSONview(props: { json: string | any }) {+ const text =+ typeof props.json === "string"+ ? props.json+ : JSON.stringify(props.json, null, 2);++ return <CodeView>{text}</CodeView>;+}++export function CodeView(props: PropsWithChildren) {+ return (+ <pre className="rounded-md border px-4 py-3 font-mono text-sm">+ {props.children}+ </pre>+ );+}diff --git a/src/pages/llm-calls/[llmCallId].tsx b/src/pages/llm-calls/[llmCallId].tsxindex eb13235c7e..09455708ac 100644--- a/src/pages/llm-calls/[llmCallId].tsx+++ b/src/pages/llm-calls/[llmCallId].tsx@@ -1,3 +1,8 @@+import { Button } from "@/src/components/ui/button";+import { CodeView, JSONview } from "@/src/components/ui/code";+import DescriptionList from "@/src/components/ui/descriptionLists";+import { ArrowUpRight } from "lucide-react";+import Link from "next/link";import { useRouter } from "next/router";import Header from "~/components/layouts/header";@@ -20,26 +25,65 @@ export default function LlmCallPage() {{ name: llmCallId as string },]}/>- {llmCall.isSuccess ? (- <>- <div className="flex w-full space-x-3">- <div className="flex-1 border-2 border-gray-300 p-2">- <div className="font-semibold">Prompt</div>- {llmCall.data.attributes.prompt ?? ""}- </div>- <div className="flex-1 border-2 border-gray-300 p-2">- <div className="font-semibold">Completion</div>- {llmCall.data.attributes.completion ?? ""}- </div>- </div>- <div className="mt-2">- Tokens: {llmCall.data.attributes.tokens.prompt} prompt tokens,{" "}- {llmCall.data.attributes.tokens.completion} completion tokens- </div>- </>+ {llmCall.data ? (+ <DescriptionList+ items={[+ {+ label: "Trace",+ value: (+ <Button variant="secondary" asChild>+ <Link href={`/traces/${llmCall.data.traceId}`}>+ {llmCall.data.traceId}+ <ArrowUpRight className="ml-2 h-4 w-4" />+ </Link>+ </Button>+ ),+ },+ {+ label: "Time",+ value:+ llmCall.data.startTime.toLocaleString() ++ (llmCall.data.endTime+ ? ` - ${+ llmCall.data.endTime.getTime() -+ llmCall.data.startTime.getTime()+ }ms`+ : ""),+ },+ {+ label: "Name",+ value: llmCall.data.name,+ },+ {+ label: "Tokens",+ value: [+ llmCall.data.attributes.tokens.prompt &&+ `${llmCall.data.attributes.tokens.prompt} prompt tokens`,+ llmCall.data.attributes.tokens.completion &&+ `${llmCall.data.attributes.tokens.completion} completion tokens`,+ ]+ .filter(Boolean)+ .join(", "),+ },+ {+ label: "Prompt",+ value: <CodeView>{llmCall.data.attributes.prompt}</CodeView>,+ },+ {+ label: "Completion",+ value: <CodeView>{llmCall.data.attributes.completion}</CodeView>,+ },+ {+ label: "Model",+ value: <JSONview json={llmCall.data.attributes.model} />,+ },+ {+ label: "Attributes",+ value: <JSONview json={llmCall.data.attributes} />,+ },+ ]}+ />) : null}-- <pre>{JSON.stringify(llmCall.data, null, 2)}</pre></>);}diff --git a/src/pages/traces/[traceId].tsx b/src/pages/traces/[traceId].tsxindex 3ea00187e0..7282c12195 100644--- a/src/pages/traces/[traceId].tsx+++ b/src/pages/traces/[traceId].tsx@@ -7,11 +7,12 @@ import {CollapsibleTrigger,} from "~/components/ui/collapsible";import { api } from "~/utils/api";-import { ChevronsUpDown, ArrowUpRight } from "lucide-react";+import { ChevronsUpDown, ChevronsDownUp, ArrowUpRight } from "lucide-react";import { useState } from "react";import { type NestedObservation } from "@/src/utils/types";import Link from "next/link";import DescriptionList from "@/src/components/ui/descriptionLists";+import { JSONview } from "@/src/components/ui/code";export default function TracePage() {const router = useRouter();@@ -88,6 +89,16 @@ function ObservationDisplay(props: { obs: NestedObservation }) {props.obs.endTime.getTime() - props.obs.startTime.getTime()} ms`}</span>) : null}+ <CollapsibleTrigger asChild>+ <Button variant="ghost" size="sm" className="w-9 p-0">+ {isOpen ? (+ <ChevronsDownUp className="h-4 w-4" />+ ) : (+ <ChevronsUpDown className="h-4 w-4" />+ )}+ <span className="sr-only">Toggle</span>+ </Button>+ </CollapsibleTrigger>{props.obs.type === "LLMCALL" ? (<Button size="sm" variant="ghost" asChild><Link href={`/llm-calls/${props.obs.id}`}>@@ -95,18 +106,10 @@ function ObservationDisplay(props: { obs: NestedObservation }) {</Link></Button>) : null}- <CollapsibleTrigger asChild>- <Button variant="ghost" size="sm" className="w-9 p-0">- <ChevronsUpDown className="h-4 w-4" />- <span className="sr-only">Toggle</span>- </Button>- </CollapsibleTrigger></div><CollapsibleContent className="ml-6 space-y-2"><span className="text-sm font-semibold">Attributes</span>- <pre className="rounded-md border px-4 py-3 font-mono text-sm">- {JSON.stringify(props.obs.attributes, null, 2)}- </pre>+ <JSONview json={props.obs.attributes} /></CollapsibleContent></Collapsible><div className="ml-5">