Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

style(evals): add table metadata view for eval config detail (#3916)

marliessophiee5cbca7f95ad
diff --git a/web/src/components/table/TableWithMetadataWrapper.tsx b/web/src/components/table/TableWithMetadataWrapper.tsx
new file mode 100644
index 0000000000..5d6acc985d
--- /dev/null
+++ b/web/src/components/table/TableWithMetadataWrapper.tsx
@@ -0,0 +1,65 @@
+import { useState, type ReactNode } from "react";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+} from "@/src/components/ui/card";
+import { Button } from "@/src/components/ui/button";
+import { ChevronRight } from "lucide-react";
+import { Separator } from "@/src/components/ui/separator";
+
+export const TableWithMetadataWrapper = ({
+ tableComponent,
+ cardTitleChildren,
+ cardContentChildren,
+}: {
+ tableComponent: ReactNode;
+ cardTitleChildren: ReactNode;
+ cardContentChildren: ReactNode;
+}) => {
+ const [isCollapsed, setIsCollapsed] = useState(false);
+
+ return (
+ <div
+ className={`grid flex-1 ${isCollapsed ? "grid-cols-[2fr,auto]" : "grid-cols-[2fr,1fr]"} gap-4 overflow-hidden`}
+ >
+ <div className="flex h-full flex-col overflow-hidden">
+ {tableComponent}
+ </div>
+ <div
+ className={`flex flex-row ${isCollapsed ? "w-8" : "w-full"} h-full overflow-hidden`}
+ >
+ <div className="grid h-full w-full grid-cols-[auto,1fr] items-start gap-2 overflow-hidden">
+ <div className="grid h-full w-full grid-rows-[auto,1fr] gap-2">
+ <Button
+ variant="outline"
+ size="icon"
+ onClick={() => setIsCollapsed(!isCollapsed)}
+ >
+ <ChevronRight
+ className={`h-4 w-4 transform ${isCollapsed ? "rotate-180" : ""}`}
+ />
+ </Button>
+ <Separator orientation="vertical" className="ml-4 h-full" />
+ </div>
+ <div
+ className={`${isCollapsed ? "hidden" : "block"} grid max-h-full w-full grid-rows-[auto,1fr] overflow-hidden p-2`}
+ >
+ <div className="my-2 flex h-6 flex-wrap items-center gap-2 @container" />
+ <Card className="flex h-full flex-col overflow-hidden">
+ <CardHeader className="flex h-full w-full flex-col space-y-4">
+ <CardTitle className="flex justify-between text-xl font-bold leading-7 sm:tracking-tight">
+ {cardTitleChildren}
+ </CardTitle>
+ <CardContent className="flex-1 space-y-4 overflow-y-auto p-0">
+ {cardContentChildren}
+ </CardContent>
+ </CardHeader>
+ </Card>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx b/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx
index a741de9827..3e178e0932 100644
--- a/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx
+++ b/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx
@@ -3,17 +3,10 @@ import { api } from "@/src/utils/api";
import { useRouter } from "next/router";
import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
import { AnnotationQueueItemsTable } from "@/src/ee/features/annotation-queues/components/AnnotationQueueItemsTable";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/src/components/ui/card";
+import { CardDescription } from "@/src/components/ui/card";
import { Button } from "@/src/components/ui/button";
-import { ChevronRight, ClipboardPen, Lock } from "lucide-react";
+import { ClipboardPen, Lock } from "lucide-react";
import { Separator } from "@/src/components/ui/separator";
-import { useState } from "react";
import { Badge } from "@/src/components/ui/badge";
import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";
import Link from "next/link";
@@ -22,62 +15,7 @@ import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAcces
import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";
import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";
import { Skeleton } from "@/src/components/ui/skeleton";
-
-const TableWithMetadataWrapper = ({
- tableComponent,
- cardTitleChildren,
- cardContentChildren,
-}: {
- tableComponent: React.ReactNode;
- cardTitleChildren: React.ReactNode;
- cardContentChildren: React.ReactNode;
-}) => {
- const [isCollapsed, setIsCollapsed] = useState(false);
-
- return (
- <div
- className={`grid h-[calc(100dvh-8rem)] ${isCollapsed ? "grid-cols-[2fr,auto]" : "grid-cols-[2fr,1fr]"} gap-4 overflow-hidden lg:h-[calc(100dvh-4rem)]`}
- >
- <div className="flex h-full flex-col overflow-hidden">
- {tableComponent}
- </div>
- <div
- className={`my-2 flex flex-row ${isCollapsed ? "w-8" : "w-full"} h-full overflow-hidden`}
- >
- <div className="grid h-full w-full grid-cols-[auto,1fr] items-start gap-2 overflow-hidden">
- <div className="grid h-full w-full grid-rows-[auto,1fr] gap-2">
- <Button
- variant="outline"
- size="icon"
- onClick={() => setIsCollapsed(!isCollapsed)}
- >
- <ChevronRight
- className={`h-4 w-4 transform ${isCollapsed ? "rotate-180" : ""}`}
- />
- </Button>
- <Separator orientation="vertical" className="ml-4 h-full" />
- </div>
- <div
- className={`${isCollapsed ? "hidden" : "block"} mt-8 grid h-[calc(100%-2rem)] w-full grid-rows-[auto,1fr] gap-2 overflow-hidden p-2`}
- >
- <Card className="flex h-full flex-col overflow-hidden">
- <div className="flex h-full overflow-y-auto">
- <CardHeader className="flex h-full w-full flex-col space-y-4">
- <CardTitle className="flex justify-between text-xl font-bold leading-7 sm:tracking-tight">
- {cardTitleChildren}
- </CardTitle>
- <CardContent className="flex-1 space-y-4 p-0">
- {cardContentChildren}
- </CardContent>
- </CardHeader>
- </div>
- </Card>
- </div>
- </div>
- </div>
- </div>
- );
-};
+import { TableWithMetadataWrapper } from "@/src/components/table/TableWithMetadataWrapper";
export default function QueueItems() {
const router = useRouter();
diff --git a/web/src/ee/features/evals/components/evaluator-detail.tsx b/web/src/ee/features/evals/components/evaluator-detail.tsx
index e96837d815..40616d09b7 100644
--- a/web/src/ee/features/evals/components/evaluator-detail.tsx
+++ b/web/src/ee/features/evals/components/evaluator-detail.tsx
@@ -12,17 +12,14 @@ import {
} from "@/src/components/ui/popover";
import { useState } from "react";
import { Trash } from "lucide-react";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/src/components/ui/tabs";
-import { Label } from "@/src/components/ui/label";
import TableLink from "@/src/components/table/table-link";
import EvalLogTable from "@/src/ee/features/evals/components/eval-log";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
+import { TableWithMetadataWrapper } from "@/src/components/table/TableWithMetadataWrapper";
+import { StatusBadge } from "@/src/components/layouts/status-badge";
+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";
+import { CardDescription } from "@/src/components/ui/card";
export const EvaluatorDetail = () => {
const router = useRouter();
@@ -65,66 +62,84 @@ export const EvaluatorDetail = () => {
: undefined;
return (
- <div className="md:container">
- <Header
- title={evaluator.data?.id ?? "Loading..."}
- status={evaluator.data?.status.toLowerCase()}
- actionButtons={
- <DeactivateEvaluator
- projectId={projectId}
- evaluator={evaluator.data ?? undefined}
- isLoading={evaluator.isLoading}
- />
- }
- breadcrumb={[
- {
- name: "Evaluators",
- href: `/project/${router.query.projectId as string}/evals`,
- },
- { name: evaluator.data?.id },
- ]}
- />
- {existingEvaluator && (
- <>
- <div className="my-5 flex items-center gap-4 rounded-md border p-2">
- <Label>Eval Template</Label>
- <TableLink
- path={`/project/${projectId}/evals/templates/${existingEvaluator.evalTemplateId}`}
- value={
- `${existingEvaluator.evalTemplate.name} (v${existingEvaluator.evalTemplate.version})` ??
- ""
- }
- />
- </div>
-
- <Tabs defaultValue="logs">
- <TabsList>
- <TabsTrigger value="logs">Logs</TabsTrigger>
- <TabsTrigger value="configuration">Configuration</TabsTrigger>
- </TabsList>
- <TabsContent value="configuration">
- <EvaluatorForm
+ <FullScreenPage>
+ <>
+ <Header
+ title={`${evaluator.data?.id}` ?? "Loading..."}
+ breadcrumb={[
+ {
+ name: "Evaluators",
+ href: `/project/${router.query.projectId as string}/evals`,
+ },
+ { name: evaluator.data?.id },
+ ]}
+ actionButtons={
+ <>
+ <DeactivateEvaluator
projectId={projectId}
- evalTemplates={allTemplates.data?.templates}
- existingEvaluator={existingEvaluator}
- disabled={true}
+ evaluator={evaluator.data ?? undefined}
+ isLoading={evaluator.isLoading}
/>
- </TabsContent>
- <TabsContent value="logs">
- <FullScreenPage
- lgHeight="lg:h-[calc(100dvh-13rem)]"
- mobileHeight="h-[calc(100dvh-17rem)]"
- >
- <EvalLogTable
- projectId={projectId}
- jobConfigurationId={existingEvaluator.id}
+ {evaluator.data && (
+ <DetailPageNav
+ key="nav"
+ currentId={encodeURIComponent(evaluator.data.id)}
+ path={(id) =>
+ `/project/${projectId}/evals/${encodeURIComponent(id)}`
+ }
+ listKey="evals"
/>
- </FullScreenPage>
- </TabsContent>
- </Tabs>
- </>
- )}
- </div>
+ )}
+ </>
+ }
+ />
+ {existingEvaluator && (
+ <TableWithMetadataWrapper
+ tableComponent={
+ <EvalLogTable
+ projectId={projectId}
+ jobConfigurationId={existingEvaluator.id}
+ />
+ }
+ cardTitleChildren={
+ <div className="flex w-full flex-row items-center justify-between">
+ <span>Evaluator</span>
+ <StatusBadge
+ type={evaluator.data?.status.toLowerCase()}
+ isLive
+ className="max-h-8"
+ />
+ </div>
+ }
+ cardContentChildren={
+ <>
+ <CardDescription className="flex items-center justify-between text-sm">
+ <span className="text-sm font-medium">Eval Template</span>
+ <TableLink
+ path={`/project/${projectId}/evals/templates/${existingEvaluator.evalTemplateId}`}
+ value={
+ `${existingEvaluator.evalTemplate.name} (v${existingEvaluator.evalTemplate.version})` ??
+ ""
+ }
+ className="flex min-h-6 items-center"
+ />
+ </CardDescription>
+ <div className="flex w-full flex-col items-start justify-between space-y-2 pb-4">
+ <EvaluatorForm
+ key={existingEvaluator.id}
+ projectId={projectId}
+ evalTemplates={allTemplates.data?.templates}
+ existingEvaluator={existingEvaluator}
+ disabled={true}
+ shouldWrapVariables={true}
+ />
+ </div>
+ </>
+ }
+ />
+ )}
+ </>
+ </FullScreenPage>
);
};
@@ -166,8 +181,8 @@ export function DeactivateEvaluator({
<Popover open={isOpen} onOpenChange={() => setIsOpen(!isOpen)}>
<PopoverTrigger asChild>
<Button
- variant="ghost"
- size={"sm"}
+ variant="outline"
+ size={"icon"}
disabled={!hasAccess || evaluator?.status !== "ACTIVE"}
loading={isLoading}
>
@@ -177,8 +192,8 @@ export function DeactivateEvaluator({
<PopoverContent>
<h2 className="text-md mb-3 font-semibold">Please confirm</h2>
<p className="mb-3 text-sm">
- This action permanently deactivates the evaluation job. No more traces
- will be evaluated for this job.
+ This action permanently deactivates the evaluator. No more traces will
+ be evaluated based on this evaluator.
</p>
<div className="flex justify-end space-x-4">
<Button
@@ -187,7 +202,7 @@ export function DeactivateEvaluator({
loading={mutEvaluator.isLoading}
onClick={onClick}
>
- Deactivate Eval Job
+ Deactivate evaluator
</Button>
</div>
</PopoverContent>
diff --git a/web/src/ee/features/evals/components/evaluator-form.tsx b/web/src/ee/features/evals/components/evaluator-form.tsx
index b528010f87..5a4c2e8259 100644
--- a/web/src/ee/features/evals/components/evaluator-form.tsx
+++ b/web/src/ee/features/evals/components/evaluator-form.tsx
@@ -77,6 +77,7 @@ export const EvaluatorForm = (props: {
disabled?: boolean;
existingEvaluator?: JobConfiguration & { evalTemplate: EvalTemplate };
onFormSuccess?: () => void;
+ shouldWrapVariables?: boolean;
}) => {
const [open, setOpen] = useState(false);
const [evalTemplate, setEvalTemplate] = useState<string | undefined>(
@@ -264,6 +265,7 @@ export const EvaluatorForm = (props: {
props.existingEvaluator?.evalTemplate ?? currentTemplate
}
onFormSuccess={props.onFormSuccess}
+ shouldWrapVariables={props.shouldWrapVariables}
/>
) : null}
</>
@@ -276,6 +278,7 @@ export const InnerEvalConfigForm = (props: {
disabled?: boolean;
existingEvaluator?: JobConfiguration;
onFormSuccess?: () => void;
+ shouldWrapVariables?: boolean;
}) => {
const [formError, setFormError] = useState<string | null>(null);
const capture = usePostHogClientCapture();
@@ -421,7 +424,7 @@ export const InnerEvalConfigForm = (props: {
</FormItem>
)}
/>
- <Card className="flex flex-col gap-6 p-4">
+ <Card className="flex max-w-full flex-col gap-6 overflow-y-auto p-4">
<FormField
control={form.control}
name="target"
@@ -478,13 +481,26 @@ export const InnerEvalConfigForm = (props: {
<FormControl>
Here will some variable mapping be added.
</FormControl>
- <div className="my-2 flex flex-col gap-2 lg:flex-row">
+ <div
+ className={cn(
+ "my-2 flex flex-col gap-2",
+ !props.shouldWrapVariables && "lg:flex-row",
+ )}
+ >
<JSONView
title={"Eval Template"}
json={props.evalTemplate.prompt ?? null}
- className={"min-h-48 bg-muted lg:w-1/2"}
+ className={cn(
+ "min-h-48 bg-muted",
+ !props.shouldWrapVariables && "lg:w-1/2",
+ )}
/>
- <div className="flex flex-col gap-2 lg:w-1/3">
+ <div
+ className={cn(
+ "flex flex-col gap-2",
+ !props.shouldWrapVariables && "lg:w-1/3",
+ )}
+ >
{fields.map((mappingField, index) => (
<Card className="flex flex-col gap-2 p-4" key={index}>
<div className="text-sm font-semibold">
diff --git a/web/src/ee/features/evals/components/evaluator-table.tsx b/web/src/ee/features/evals/components/evaluator-table.tsx
index 319466b764..56d67e0737 100644
--- a/web/src/ee/features/evals/components/evaluator-table.tsx
+++ b/web/src/ee/features/evals/components/evaluator-table.tsx
@@ -5,10 +5,11 @@ import TableLink from "@/src/components/table/table-link";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { InlineFilterState } from "@/src/features/filters/components/filter-builder";
+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { type RouterOutputs, api } from "@/src/utils/api";
import { type FilterState, singleFilter } from "@langfuse/shared";
import { createColumnHelper } from "@tanstack/react-table";
-import { type ReactNode } from "react";
+import { type ReactNode, useEffect } from "react";
import { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { z } from "zod";
@@ -32,6 +33,7 @@ export default function EvaluatorTable({
projectId: string;
menuItems?: ReactNode;
}) {
+ const { setDetailPageList } = useDetailPageLists();
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
pageSize: withDefault(NumberParam, 50),
@@ -44,6 +46,16 @@ export default function EvaluatorTable({
});
const totalCount = evaluators.data?.totalCount ?? null;
+ useEffect(() => {
+ if (evaluators.isSuccess) {
+ setDetailPageList(
+ "evals",
+ evaluators.data.configs.map((evaluator) => evaluator.id),
+ );
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [evaluators.isSuccess, evaluators.data]);
+
const columnHelper = createColumnHelper<EvalConfigRow>();
const columns = [
columnHelper.accessor("id", {