Skip to content

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

chore: support table-level-tab navigation through eval configs, templates, log (#3899)

marliessophief383a3f50fd7
diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsx
index 5fd9a99eca..70310d5ec1 100644
--- a/web/src/components/layouts/layout.tsx
+++ b/web/src/components/layouts/layout.tsx
@@ -158,23 +158,27 @@ export default function Layout(props: PropsWithChildren) {
// check entitlements
if (
- route.entitlement !== undefined &&
- !entitlements.includes(route.entitlement) &&
+ route.entitlements !== undefined &&
+ !route.entitlements.some((entitlement) =>
+ entitlements.includes(entitlement),
+ ) &&
!cloudAdmin
)
return null;
// RBAC
if (
- route.projectRbacScope !== undefined &&
+ route.projectRbacScopes !== undefined &&
!cloudAdmin &&
(!project ||
!organization ||
- !hasProjectAccess({
- projectId: project.id,
- scope: route.projectRbacScope,
- session: session.data,
- }))
+ !route.projectRbacScopes.some((scope) =>
+ hasProjectAccess({
+ projectId: project.id,
+ scope,
+ session: session.data,
+ }),
+ ))
)
return null;
if (
diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsx
index bc97a90dc2..87264db35b 100644
--- a/web/src/components/layouts/routes.tsx
+++ b/web/src/components/layouts/routes.tsx
@@ -13,7 +13,6 @@ import {
Lightbulb,
Grid2X2,
Sparkle,
- ClipboardPen,
FileJson,
} from "lucide-react";
import { LangfuseIcon } from "@/src/components/LangfuseLogo";
@@ -29,14 +28,14 @@ export type Route = {
name: string;
featureFlag?: Flag;
label?: string | ReactNode;
- projectRbacScope?: ProjectScope;
+ projectRbacScopes?: ProjectScope[]; // array treated as OR
organizationRbacScope?: OrganizationScope;
icon?: LucideIcon | typeof LangfuseIcon; // ignored for nested routes
pathname?: string; // link, ignored if children
children?: Array<Route>; // folder
bottom?: boolean; // bottom of the sidebar, only for first level routes
newTab?: boolean; // open in new tab
- entitlement?: Entitlement; // entitlement required
+ entitlements?: Entitlement[]; // entitlements required, array treated as OR
customizableHref?: UiCustomizationOption; // key of useUiCustomization object to use to replace the href
show?: (p: {
organization: User["organizations"][number] | undefined;
@@ -87,37 +86,24 @@ export const ROUTES: Route[] = [
},
],
},
- {
- name: "Annotate",
- pathname: `/project/[projectId]/annotation-queues`,
- icon: ClipboardPen,
- label: "Beta",
- projectRbacScope: "annotationQueues:read",
- entitlement: "annotation-queues",
- },
{
name: "Evaluation",
icon: Lightbulb,
- entitlement: "model-based-evaluations",
label: "Beta",
+ entitlements: ["annotation-queues", "model-based-evaluations"],
+ projectRbacScopes: ["annotationQueues:read", "evalJob:read"],
children: [
{
- name: "Templates",
- pathname: `/project/[projectId]/evals/templates`,
- entitlement: "model-based-evaluations",
- projectRbacScope: "evalTemplate:read",
- },
- {
- name: "Configs",
- pathname: `/project/[projectId]/evals/configs`,
- entitlement: "model-based-evaluations",
- projectRbacScope: "evalJob:read",
+ name: "Human Annotation",
+ pathname: `/project/[projectId]/annotation-queues`,
+ projectRbacScopes: ["annotationQueues:read"],
+ entitlements: ["annotation-queues"],
},
{
- name: "Log",
- pathname: `/project/[projectId]/evals/log`,
- entitlement: "model-based-evaluations",
- projectRbacScope: "evalJobExecution:read",
+ name: "LLM-as-a-Judge",
+ pathname: `/project/[projectId]/evals`,
+ entitlements: ["model-based-evaluations"],
+ projectRbacScopes: ["evalJob:read"],
},
],
},
@@ -130,13 +116,13 @@ export const ROUTES: Route[] = [
name: "Prompts",
pathname: "/project/[projectId]/prompts",
icon: FileJson,
- projectRbacScope: "prompts:read",
+ projectRbacScopes: ["prompts:read"],
},
{
name: "Playground",
pathname: "/project/[projectId]/playground",
icon: TerminalIcon,
- entitlement: "playground",
+ entitlements: ["playground"],
},
{
name: "Datasets",
@@ -148,7 +134,7 @@ export const ROUTES: Route[] = [
icon: Sparkle,
pathname: "/project/[projectId]/settings/billing",
bottom: true,
- entitlement: "cloud-billing",
+ entitlements: ["cloud-billing"],
organizationRbacScope: "langfuseCloudBilling:CRUD",
show: ({ organization }) => organization?.plan === "cloud:hobby",
label: <UsageTracker />,
@@ -158,7 +144,7 @@ export const ROUTES: Route[] = [
icon: Sparkle,
pathname: "/organization/[organizationId]/settings/billing",
bottom: true,
- entitlement: "cloud-billing",
+ entitlements: ["cloud-billing"],
organizationRbacScope: "langfuseCloudBilling:CRUD",
show: ({ organization }) => organization?.plan === "cloud:hobby",
label: <UsageTracker />,
diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsx
index 62de7e0fc7..804d6c7ba1 100644
--- a/web/src/components/table/use-cases/scores.tsx
+++ b/web/src/components/table/use-cases/scores.tsx
@@ -335,7 +335,7 @@ export default function ScoresTable({
return typeof value === "string" ? (
<>
<TableLink
- path={`/project/${projectId}/evals/configs/${value}`}
+ path={`/project/${projectId}/evals/${value}`}
value={value}
/>
</>
diff --git a/web/src/ee/features/evals/components/eval-log.tsx b/web/src/ee/features/evals/components/eval-log.tsx
index e1bb45f0d4..d595e4e449 100644
--- a/web/src/ee/features/evals/components/eval-log.tsx
+++ b/web/src/ee/features/evals/components/eval-log.tsx
@@ -9,6 +9,7 @@ import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrde
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { type RouterOutputs, api } from "@/src/utils/api";
import { createColumnHelper } from "@tanstack/react-table";
+import { type ReactNode } from "react";
import { useQueryParams, withDefault, NumberParam } from "use-query-params";
export type JobExecutionRow = {
@@ -20,16 +21,18 @@ export type JobExecutionRow = {
endTime?: string;
traceId?: string;
templateId: string;
- configId: string;
+ evaluatorId: string;
error?: string;
};
export default function EvalLogTable({
projectId,
jobConfigurationId,
+ menuItems,
}: {
projectId: string;
jobConfigurationId?: string;
+ menuItems?: ReactNode;
}) {
const [rowHeight, setRowHeight] = useRowHeightLocalStorage("evalLogs", "s");
const [paginationState, setPaginationState] = useQueryParams({
@@ -137,15 +140,15 @@ export default function EvalLogTable({
if (!jobConfigurationId) {
columns.push(
- columnHelper.accessor("configId", {
- id: "configId",
- header: "Config",
+ columnHelper.accessor("evaluatorId", {
+ id: "evaluatorId",
+ header: "Evaluator",
cell: (row) => {
- const configId = row.getValue();
- return configId ? (
+ const evaluatorId = row.getValue();
+ return evaluatorId ? (
<TableLink
- path={`/project/${projectId}/evals/configs/${encodeURIComponent(configId)}`}
- value={configId}
+ path={`/project/${projectId}/evals/${encodeURIComponent(evaluatorId)}`}
+ value={evaluatorId}
/>
) : undefined;
},
@@ -173,7 +176,7 @@ export default function EvalLogTable({
endTime: jobConfig.endTime?.toLocaleString() ?? undefined,
traceId: jobConfig.jobInputTraceId ?? undefined,
templateId: jobConfig.jobConfiguration.evalTemplateId ?? "",
- configId: jobConfig.jobConfigurationId,
+ evaluatorId: jobConfig.jobConfigurationId,
error: jobConfig.error ?? undefined,
};
};
@@ -188,6 +191,7 @@ export default function EvalLogTable({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ actionButtons={menuItems}
/>
<DataTable
columns={columns}
diff --git a/web/src/ee/features/evals/components/eval-template-detail.tsx b/web/src/ee/features/evals/components/eval-template-detail.tsx
index da721bc74f..b30b51f52e 100644
--- a/web/src/ee/features/evals/components/eval-template-detail.tsx
+++ b/web/src/ee/features/evals/components/eval-template-detail.tsx
@@ -14,7 +14,7 @@ import {
} from "@/src/components/ui/select";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { Button } from "@/src/components/ui/button";
-import { Pencil } from "lucide-react";
+import { Plus } from "lucide-react";
import { useState } from "react";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
@@ -155,13 +155,13 @@ export function UpdateTemplate({
return (
<Button
- variant="outline"
- size="icon"
+ variant="secondary"
onClick={() => handlePromptEdit()}
disabled={!hasAccess}
loading={isLoading}
>
- <Pencil className="h-5 w-5" />
+ <Plus className="h-4 w-4" />
+ New version
</Button>
);
}
diff --git a/web/src/ee/features/evals/components/eval-templates-table.tsx b/web/src/ee/features/evals/components/eval-templates-table.tsx
index 48c0a38b1b..98bc7d41fa 100644
--- a/web/src/ee/features/evals/components/eval-templates-table.tsx
+++ b/web/src/ee/features/evals/components/eval-templates-table.tsx
@@ -1,9 +1,11 @@
import { DataTable } from "@/src/components/table/data-table";
+import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
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 { type RouterOutputs, api } from "@/src/utils/api";
import { createColumnHelper } from "@tanstack/react-table";
+import { type ReactNode } from "react";
import { useQueryParams, withDefault, NumberParam } from "use-query-params";
export type EvalsTemplateRow = {
@@ -15,8 +17,10 @@ export type EvalsTemplateRow = {
export default function EvalsTemplateTable({
projectId,
+ menuItems,
}: {
projectId: string;
+ menuItems?: ReactNode;
}) {
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
@@ -86,30 +90,35 @@ export default function EvalsTemplateTable({
};
return (
- <DataTable
- columns={columns}
- data={
- templates.isLoading
- ? { isLoading: true, isError: false }
- : templates.isError
- ? {
- isLoading: false,
- isError: true,
- error: templates.error.message,
- }
- : {
- isLoading: false,
- isError: false,
- data: templates.data.templates.map((t) => convertToTableRow(t)),
- }
- }
- pagination={{
- totalCount,
- onChange: setPaginationState,
- state: paginationState,
- }}
- columnVisibility={columnVisibility}
- onColumnVisibilityChange={setColumnVisibility}
- />
+ <>
+ <DataTableToolbar columns={columns} actionButtons={menuItems} />
+ <DataTable
+ columns={columns}
+ data={
+ templates.isLoading
+ ? { isLoading: true, isError: false }
+ : templates.isError
+ ? {
+ isLoading: false,
+ isError: true,
+ error: templates.error.message,
+ }
+ : {
+ isLoading: false,
+ isError: false,
+ data: templates.data.templates.map((t) =>
+ convertToTableRow(t),
+ ),
+ }
+ }
+ pagination={{
+ totalCount,
+ onChange: setPaginationState,
+ state: paginationState,
+ }}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ />
+ </>
);
}
diff --git a/web/src/ee/features/evals/components/eval-config-detail.tsx b/web/src/ee/features/evals/components/evaluator-detail.tsx
similarity index 72%
rename from web/src/ee/features/evals/components/eval-config-detail.tsx
rename to web/src/ee/features/evals/components/evaluator-detail.tsx
index 38c07226bc..e96837d815 100644
--- a/web/src/ee/features/evals/components/eval-config-detail.tsx
+++ b/web/src/ee/features/evals/components/evaluator-detail.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
import Header from "@/src/components/layouts/header";
import { type RouterOutputs, api } from "@/src/utils/api";
import { useRouter } from "next/router";
-import { EvalConfigForm } from "@/src/ee/features/evals/components/eval-config-form";
+import { EvaluatorForm } from "@/src/ee/features/evals/components/evaluator-form";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { Button } from "@/src/components/ui/button";
import {
@@ -24,74 +24,74 @@ 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";
-export const EvalConfigDetail = () => {
+export const EvaluatorDetail = () => {
const router = useRouter();
const projectId = router.query.projectId as string;
- const configId = router.query.configId as string;
+ const evaluatorId = router.query.evaluatorId as string;
// get the current template by id
- const config = api.evals.configById.useQuery({
+ const evaluator = api.evals.configById.useQuery({
projectId: projectId,
- id: configId,
+ id: evaluatorId,
});
// get all templates for the current template name
const allTemplates = api.evals.allTemplatesForName.useQuery(
{
projectId: projectId,
- name: config.data?.evalTemplate?.name ?? "",
+ name: evaluator.data?.evalTemplate?.name ?? "",
},
{
- enabled: !config.isLoading && !config.isError,
+ enabled: !evaluator.isLoading && !evaluator.isError,
},
);
if (
- config.isLoading ||
- !config.data ||
+ evaluator.isLoading ||
+ !evaluator.data ||
allTemplates.isLoading ||
!allTemplates.data
) {
return <div>Loading...</div>;
}
- if (config.data && config.data.evalTemplate === null) {
- return <div>Config not found</div>;
+ if (evaluator.data && evaluator.data.evalTemplate === null) {
+ return <div>Evaluator not found</div>;
}
- const existingEvalConfig =
- config.data && config.data.evalTemplate
- ? { ...config.data, evalTemplate: config.data.evalTemplate }
+ const existingEvaluator =
+ evaluator.data && evaluator.data.evalTemplate
+ ? { ...evaluator.data, evalTemplate: evaluator.data.evalTemplate }
: undefined;
return (
<div className="md:container">
<Header
- title={config.data?.id ?? "Loading..."}
- status={config.data?.status.toLowerCase()}
+ title={evaluator.data?.id ?? "Loading..."}
+ status={evaluator.data?.status.toLowerCase()}
actionButtons={
- <DeactivateConfig
+ <DeactivateEvaluator
projectId={projectId}
- config={config.data ?? undefined}
- isLoading={config.isLoading}
+ evaluator={evaluator.data ?? undefined}
+ isLoading={evaluator.isLoading}
/>
}
breadcrumb={[
{
- name: "Eval Configs",
- href: `/project/${router.query.projectId as string}/evals/configs`,
+ name: "Evaluators",
+ href: `/project/${router.query.projectId as string}/evals`,
},
- { name: config.data?.id },
+ { name: evaluator.data?.id },
]}
/>
- {existingEvalConfig && (
+ {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/${existingEvalConfig.evalTemplateId}`}
+ path={`/project/${projectId}/evals/templates/${existingEvaluator.evalTemplateId}`}
value={
- `${existingEvalConfig.evalTemplate.name} (v${existingEvalConfig.evalTemplate.version})` ??
+ `${existingEvaluator.evalTemplate.name} (v${existingEvaluator.evalTemplate.version})` ??
""
}
/>
@@ -103,10 +103,10 @@ export const EvalConfigDetail = () => {
<TabsTrigger value="configuration">Configuration</TabsTrigger>
</TabsList>
<TabsContent value="configuration">
- <EvalConfigForm
+ <EvaluatorForm
projectId={projectId}
evalTemplates={allTemplates.data?.templates}
- existingEvalConfig={existingEvalConfig}
+ existingEvaluator={existingEvaluator}
disabled={true}
/>
</TabsContent>
@@ -117,7 +117,7 @@ export const EvalConfigDetail = () => {
>
<EvalLogTable
projectId={projectId}
- jobConfigurationId={existingEvalConfig.id}
+ jobConfigurationId={existingEvaluator.id}
/>
</FullScreenPage>
</TabsContent>
@@ -128,13 +128,13 @@ export const EvalConfigDetail = () => {
);
};
-export function DeactivateConfig({
+export function DeactivateEvaluator({
projectId,
- config,
+ evaluator,
isLoading,
}: {
projectId: string;
- config?: RouterOutputs["evals"]["configById"];
+ evaluator?: RouterOutputs["evals"]["configById"];
isLoading: boolean;
}) {
const utils = api.useUtils();
@@ -142,7 +142,7 @@ export function DeactivateConfig({
const [isOpen, setIsOpen] = useState(false);
const capture = usePostHogClientCapture();
- const mutEvalConfig = api.evals.updateEvalJob.useMutation({
+ const mutEvaluator = api.evals.updateEvalJob.useMutation({
onSuccess: () => {
void utils.evals.invalidate();
},
@@ -153,9 +153,9 @@ export function DeactivateConfig({
console.error("Project ID is missing");
return;
}
- mutEvalConfig.mutateAsync({
+ mutEvaluator.mutateAsync({
projectId,
- evalConfigId: config?.id ?? "",
+ evalConfigId: evaluator?.id ?? "",
updatedStatus: "INACTIVE",
});
capture("eval_config:delete");
@@ -168,7 +168,7 @@ export function DeactivateConfig({
<Button
variant="ghost"
size={"sm"}
- disabled={!hasAccess || config?.status !== "ACTIVE"}
+ disabled={!hasAccess || evaluator?.status !== "ACTIVE"}
loading={isLoading}
>
<Trash className="h-5 w-5" />
@@ -184,7 +184,7 @@ export function DeactivateConfig({
<Button
type="button"
variant="destructive"
- loading={mutEvalConfig.isLoading}
+ loading={mutEvaluator.isLoading}
onClick={onClick}
>
Deactivate Eval Job
diff --git a/web/src/ee/features/evals/components/eval-config-form.tsx b/web/src/ee/features/evals/components/evaluator-form.tsx
similarity index 95%
rename from web/src/ee/features/evals/components/eval-config-form.tsx
rename to web/src/ee/features/evals/components/evaluator-form.tsx
index fdd82b04f1..b528010f87 100644
--- a/web/src/ee/features/evals/components/eval-config-form.tsx
+++ b/web/src/ee/features/evals/components/evaluator-form.tsx
@@ -71,24 +71,24 @@ const formSchema = z.object({
delay: z.coerce.number().optional().default(10),
});
-export const EvalConfigForm = (props: {
+export const EvaluatorForm = (props: {
projectId: string;
evalTemplates: EvalTemplate[];
disabled?: boolean;
- existingEvalConfig?: JobConfiguration & { evalTemplate: EvalTemplate };
+ existingEvaluator?: JobConfiguration & { evalTemplate: EvalTemplate };
onFormSuccess?: () => void;
}) => {
const [open, setOpen] = useState(false);
const [evalTemplate, setEvalTemplate] = useState<string | undefined>(
- props.existingEvalConfig?.evalTemplate.id,
+ props.existingEvaluator?.evalTemplate.id,
);
const [isCreateTemplateOpen, setIsCreateTemplateOpen] = useState(false);
const [selectedTemplateName, setSelectedTemplateName] = useState<
string | undefined
- >(props.existingEvalConfig?.evalTemplate.name);
+ >(props.existingEvaluator?.evalTemplate.name);
const [selectedTemplateVersion, setSelectedTemplateVersion] = useState<
number | undefined
- >(props.existingEvalConfig?.evalTemplate.version);
+ >(props.existingEvaluator?.evalTemplate.version);
const utils = api.useUtils();
const currentTemplate = props.evalTemplates.find(
@@ -96,10 +96,10 @@ export const EvalConfigForm = (props: {
);
useEffect(() => {
- if (props.existingEvalConfig?.evalTemplate && !evalTemplate) {
- setEvalTemplate(props.existingEvalConfig.evalTemplate.id);
+ if (props.existingEvaluator?.evalTemplate && !evalTemplate) {
+ setEvalTemplate(props.existingEvaluator.evalTemplate.id);
}
- }, [props.existingEvalConfig, evalTemplate]);
+ }, [props.existingEvaluator, evalTemplate]);
// Group templates by name
const templatesByName = props.evalTemplates.reduce(
@@ -259,9 +259,9 @@ export const EvalConfigForm = (props: {
key={evalTemplate}
projectId={props.projectId}
disabled={props.disabled}
- existingEvalConfig={props.existingEvalConfig}
+ existingEvaluator={props.existingEvaluator}
evalTemplate={
- props.existingEvalConfig?.evalTemplate ?? currentTemplate
+ props.existingEvaluator?.evalTemplate ?? currentTemplate
}
onFormSuccess={props.onFormSuccess}
/>
@@ -274,7 +274,7 @@ export const InnerEvalConfigForm = (props: {
projectId: string;
evalTemplate: EvalTemplate;
disabled?: boolean;
- existingEvalConfig?: JobConfiguration;
+ existingEvaluator?: JobConfiguration;
onFormSuccess?: () => void;
}) => {
const [formError, setFormError] = useState<string | null>(null);
@@ -285,16 +285,16 @@ export const InnerEvalConfigForm = (props: {
disabled: props.disabled,
defaultValues: {
scoreName:
- props.existingEvalConfig?.scoreName ??
+ props.existingEvaluator?.scoreName ??
`${props.evalTemplate.name}-v${props.evalTemplate.version}`,
- target: props.existingEvalConfig?.targetObject ?? "",
- filter: props.existingEvalConfig?.filter
- ? z.array(singleFilter).parse(props.existingEvalConfig.filter)
+ target: props.existingEvaluator?.targetObject ?? "",
+ filter: props.existingEvaluator?.filter
+ ? z.array(singleFilter).parse(props.existingEvaluator.filter)
: [],
- mapping: props.existingEvalConfig?.variableMapping
+ mapping: props.existingEvaluator?.variableMapping
? z
.array(variableMapping)
- .parse(props.existingEvalConfig.variableMapping)
+ .parse(props.existingEvaluator.variableMapping)
: z.array(variableMapping).parse(
props.evalTemplate
? props.evalTemplate.vars.map((v) => ({
@@ -304,11 +304,11 @@ export const InnerEvalConfigForm = (props: {
}))
: [],
),
- sampling: props.existingEvalConfig?.sampling
- ? props.existingEvalConfig.sampling.toNumber()
+ sampling: props.existingEvaluator?.sampling
+ ? props.existingEvaluator.sampling.toNumber()
: 1,
- delay: props.existingEvalConfig?.delay
- ? props.existingEvalConfig.delay / 1000
+ delay: props.existingEvaluator?.delay
+ ? props.existingEvaluator.delay / 1000
: 10,
},
});
@@ -385,7 +385,7 @@ export const InnerEvalConfigForm = (props: {
.then(() => {
props.onFormSuccess?.();
form.reset();
- void router.push(`/project/${props.projectId}/evals/configs/`);
+ void router.push(`/project/${props.projectId}/evals`);
})
.catch((error) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -432,8 +432,8 @@ export const InnerEvalConfigForm = (props: {
<Tabs defaultValue="trace">
<TabsList {...field}>
<TabsTrigger value="trace">Trace</TabsTrigger>
- <TabsTrigger value="observation" disabled={true}>
- Observation (coming soon)
+ <TabsTrigger value="dataset" disabled={true}>
+ Dataset (coming soon)
</TabsTrigger>
</TabsList>
</Tabs>
diff --git a/web/src/ee/features/evals/components/eval-config-table.tsx b/web/src/ee/features/evals/components/evaluator-table.tsx
similarity index 61%
rename from web/src/ee/features/evals/components/eval-config-table.tsx
rename to web/src/ee/features/evals/components/evaluator-table.tsx
index de2d9e5a4f..319466b764 100644
--- a/web/src/ee/features/evals/components/eval-config-table.tsx
+++ b/web/src/ee/features/evals/components/evaluator-table.tsx
@@ -1,5 +1,6 @@
import { StatusBadge } from "@/src/components/layouts/status-badge";
import { DataTable } from "@/src/components/table/data-table";
+import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
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";
@@ -7,6 +8,7 @@ import { InlineFilterState } from "@/src/features/filters/components/filter-buil
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 { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { z } from "zod";
@@ -14,23 +16,33 @@ export type EvalConfigRow = {
id: string;
status: string;
createdAt: string;
- template?: string;
+ template?: {
+ id: string;
+ name: string;
+ version: number;
+ };
scoreName: string;
filter: FilterState;
};
-export default function EvalConfigTable({ projectId }: { projectId: string }) {
+export default function EvaluatorTable({
+ projectId,
+ menuItems,
+}: {
+ projectId: string;
+ menuItems?: ReactNode;
+}) {
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
pageSize: withDefault(NumberParam, 50),
});
- const templates = api.evals.allConfigs.useQuery({
+ const evaluators = api.evals.allConfigs.useQuery({
page: paginationState.pageIndex,
limit: paginationState.pageSize,
projectId,
});
- const totalCount = templates.data?.totalCount ?? null;
+ const totalCount = evaluators.data?.totalCount ?? null;
const columnHelper = createColumnHelper<EvalConfigRow>();
const columns = [
@@ -42,7 +54,7 @@ export default function EvalConfigTable({ projectId }: { projectId: string }) {
const id = row.getValue();
return id ? (
<TableLink
- path={`/project/${projectId}/evals/configs/${encodeURIComponent(id)}`}
+ path={`/project/${projectId}/evals/${encodeURIComponent(id)}`}
value={id}
/>
) : undefined;
@@ -66,6 +78,16 @@ export default function EvalConfigTable({ projectId }: { projectId: string }) {
id: "template",
header: "Template",
size: 200,
+ cell: (row) => {
+ const template = row.getValue();
+ if (!template) return "template not found";
+ return (
+ <TableLink
+ path={`/project/${projectId}/evals/templates/${template.id}`}
+ value={`${template.name} (v${template.version})`}
+ />
+ );
+ },
}),
columnHelper.accessor("scoreName", {
id: "scoreName",
@@ -98,7 +120,11 @@ export default function EvalConfigTable({ projectId }: { projectId: string }) {
status: jobConfig.status,
createdAt: jobConfig.createdAt.toLocaleString(),
template: jobConfig.evalTemplate
- ? `${jobConfig.evalTemplate.name} (v${jobConfig.evalTemplate.version})`
+ ? {
+ id: jobConfig.evalTemplate.id,
+ name: jobConfig.evalTemplate.name,
+ version: jobConfig.evalTemplate.version,
+ }
: undefined,
scoreName: jobConfig.scoreName,
filter: z.array(singleFilter).parse(jobConfig.filter),
@@ -106,30 +132,35 @@ export default function EvalConfigTable({ projectId }: { projectId: string }) {
};
return (
- <DataTable
- columns={columns}
- data={
- templates.isLoading
- ? { isLoading: true, isError: false }
- : templates.isError
- ? {
- isLoading: false,
- isError: true,
- error: templates.error.message,
- }
- : {
- isLoading: false,
- isError: false,
- data: templates.data.configs.map((t) => convertToTableRow(t)),
- }
- }
- pagination={{
- totalCount,
- onChange: setPaginationState,
- state: paginationState,
- }}
- columnVisibility={columnVisibility}
- onColumnVisibilityChange={setColumnVisibility}
- />
+ <>
+ <DataTableToolbar columns={columns} actionButtons={menuItems} />
+ <DataTable
+ columns={columns}
+ data={
+ evaluators.isLoading
+ ? { isLoading: true, isError: false }
+ : evaluators.isError
+ ? {
+ isLoading: false,
+ isError: true,
+ error: evaluators.error.message,
+ }
+ : {
+ isLoading: false,
+ isError: false,
+ data: evaluators.data.configs.map((evaluator) =>
+ convertToTableRow(evaluator),
+ ),
+ }
+ }
+ pagination={{
+ totalCount,
+ onChange: setPaginationState,
+ state: paginationState,
+ }}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ />
+ </>
);
}
diff --git a/web/src/ee/features/evals/pages/configs.tsx b/web/src/ee/features/evals/pages/configs.tsx
deleted file mode 100644
index e641aab517..0000000000
--- a/web/src/ee/features/evals/pages/configs.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import Header from "@/src/components/layouts/header";
-import { useRouter } from "next/router";
-import { Button } from "@/src/components/ui/button";
-import Link from "next/link";
-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { Lock } from "lucide-react";
-import EvalConfigTable from "@/src/ee/features/evals/components/eval-config-table";
-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
-
-export default function ConfigsPage() {
- const router = useRouter();
- const projectId = router.query.projectId as string;
- const capture = usePostHogClientCapture();
- const hasWriteAccess = useHasProjectAccess({
- projectId,
- scope: "evalJob:CUD",
- });
-
- return (
- <FullScreenPage>
- <Header
- title="Eval Configs"
- help={{
- description:
- "Eval configs let you define how your evaluations templates are applied to incoming traces in Langfuse.",
- href: "https://langfuse.com/docs/scores/model-based-evals",
- }}
- actionButtons={
- <Button
- disabled={!hasWriteAccess}
- onClick={() => capture("eval_config:new_form_open")}
- asChild
- >
- <Link
- href={
- hasWriteAccess ? `/project/${projectId}/evals/configs/new` : "#"
- }
- >
- {!hasWriteAccess && <Lock size={16} className="mr-2" />}
- Add eval config
- </Link>
- </Button>
- }
- />
- <EvalConfigTable projectId={projectId} />
- </FullScreenPage>
- );
-}
diff --git a/web/src/ee/features/evals/pages/evaluators.tsx b/web/src/ee/features/evals/pages/evaluators.tsx
new file mode 100644
index 0000000000..5bbe51bee1
--- /dev/null
+++ b/web/src/ee/features/evals/pages/evaluators.tsx
@@ -0,0 +1,79 @@
+import Header from "@/src/components/layouts/header";
+import { useRouter } from "next/router";
+import { Button } from "@/src/components/ui/button";
+import Link from "next/link";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
+import { Lock, Plus } from "lucide-react";
+import EvaluatorTable from "@/src/ee/features/evals/components/evaluator-table";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
+
+export default function EvaluatorsPage() {
+ const router = useRouter();
+ const projectId = router.query.projectId as string;
+ const capture = usePostHogClientCapture();
+ const hasWriteAccess = useHasProjectAccess({
+ projectId,
+ scope: "evalJob:CUD",
+ });
+
+ const hasReadAccess = useHasProjectAccess({
+ projectId,
+ scope: "evalJob:read",
+ });
+
+ if (!hasReadAccess) {
+ return null;
+ }
+
+ return (
+ <FullScreenPage>
+ <Header
+ title="Evaluators"
+ help={{
+ description:
+ "Use LLM-as-a-judge evaluators as practical addition to human annotation. Configure an evaluation prompt and a model as judge to evaluate incoming traces.",
+ href: "https://langfuse.com/docs/scores/model-based-evals",
+ }}
+ actionButtons={
+ <Button
+ disabled={!hasWriteAccess}
+ onClick={() => capture("eval_config:new_form_open")}
+ asChild
+ variant="secondary"
+ >
+ <Link
+ href={hasWriteAccess ? `/project/${projectId}/evals/new` : "#"}
+ >
+ {hasWriteAccess ? (
+ <Plus className="mr-2 h-4 w-4" />
+ ) : (
+ <Lock className="mr-2 h-4 w-4" />
+ )}
+ New evaluator
+ </Link>
+ </Button>
+ }
+ />
+ <EvaluatorTable
+ projectId={projectId}
+ menuItems={
+ <Tabs value="evaluators">
+ <TabsList>
+ <TabsTrigger value="evaluators">Evaluators</TabsTrigger>
+ <TabsTrigger value="templates" asChild>
+ <Link href={`/project/${projectId}/evals/templates`}>
+ Templates
+ </Link>
+ </TabsTrigger>
+ <TabsTrigger value="log" asChild>
+ <Link href={`/project/${projectId}/evals/log`}>Log</Link>
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ }
+ />
+ </FullScreenPage>
+ );
+}
diff --git a/web/src/ee/features/evals/pages/new-configs.tsx b/web/src/ee/features/evals/pages/new-evaluator.tsx
similarity index 66%
rename from web/src/ee/features/evals/pages/new-configs.tsx
rename to web/src/ee/features/evals/pages/new-evaluator.tsx
index 6d144d05d7..c9fad5a6a6 100644
--- a/web/src/ee/features/evals/pages/new-configs.tsx
+++ b/web/src/ee/features/evals/pages/new-evaluator.tsx
@@ -1,10 +1,10 @@
import Header from "@/src/components/layouts/header";
-import { EvalConfigForm } from "@/src/ee/features/evals/components/eval-config-form";
+import { EvaluatorForm } from "@/src/ee/features/evals/components/evaluator-form";
import { api } from "@/src/utils/api";
import { useRouter } from "next/router";
-export default function NewConfigsPage() {
+export default function NewEvaluatorPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
@@ -17,14 +17,14 @@ export default function NewConfigsPage() {
return (
<div>
<Header
- title="Create eval config"
+ title="New evaluator"
help={{
description:
- "Eval configs let you define how your evaluations templates are applied to incoming traces in Langfuse.",
+ "Select a template defining the evaluation prompt and a model as judge to evaluate incoming traces.",
href: "https://langfuse.com/docs/scores/model-based-evals",
}}
/>
- <EvalConfigForm
+ <EvaluatorForm
projectId={projectId}
evalTemplates={evalTemplates.data?.templates ?? []}
/>
diff --git a/web/src/ee/features/evals/pages/templates.tsx b/web/src/ee/features/evals/pages/templates.tsx
index 0972838118..5d9f4c65dd 100644
--- a/web/src/ee/features/evals/pages/templates.tsx
+++ b/web/src/ee/features/evals/pages/templates.tsx
@@ -3,9 +3,10 @@ import { useRouter } from "next/router";
import { Button } from "@/src/components/ui/button";
import Link from "next/link";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { Lock } from "lucide-react";
+import { Lock, Plus } from "lucide-react";
import EvalsTemplateTable from "@/src/ee/features/evals/components/eval-templates-table";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
export default function TemplatesPage() {
const router = useRouter();
@@ -16,6 +17,15 @@ export default function TemplatesPage() {
scope: "evalTemplate:create",
});
+ const hasReadAccess = useHasProjectAccess({
+ projectId,
+ scope: "evalTemplate:read",
+ });
+
+ if (!hasReadAccess) {
+ return null;
+ }
+
return (
<div className="flex h-[calc(100vh-6rem)] flex-col overflow-hidden md:h-[calc(100vh-2rem)]">
<Header
@@ -30,6 +40,7 @@ export default function TemplatesPage() {
disabled={!hasWriteAccess}
onClick={() => capture("eval_templates:new_form_open")}
asChild
+ variant="secondary"
>
<Link
href={
@@ -38,13 +49,32 @@ export default function TemplatesPage() {
: "#"
}
>
- {!hasWriteAccess && <Lock size={16} className="mr-2" />}
- Add eval template
+ {hasWriteAccess ? (
+ <Plus className="mr-2 h-4 w-4" />
+ ) : (
+ <Lock className="mr-2 h-4 w-4" />
+ )}
+ New template
</Link>
</Button>
}
/>
- <EvalsTemplateTable projectId={projectId} />
+ <EvalsTemplateTable
+ projectId={projectId}
+ menuItems={
+ <Tabs value="templates">
+ <TabsList>
+ <TabsTrigger value="evaluators" asChild>
+ <Link href={`/project/${projectId}/evals`}>Evaluators</Link>
+ </TabsTrigger>
+ <TabsTrigger value="templates">Templates</TabsTrigger>
+ <TabsTrigger value="log" asChild>
+ <Link href={`/project/${projectId}/evals/log`}>Log</Link>
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ }
+ />
</div>
);
}
diff --git a/web/src/pages/project/[projectId]/evals/[evaluatorId].tsx b/web/src/pages/project/[projectId]/evals/[evaluatorId].tsx
new file mode 100644
index 0000000000..49b9de7859
--- /dev/null
+++ b/web/src/pages/project/[projectId]/evals/[evaluatorId].tsx
@@ -0,0 +1,3 @@
+import { EvaluatorDetail } from "@/src/ee/features/evals/components/evaluator-detail";
+
+export default EvaluatorDetail;
diff --git a/web/src/pages/project/[projectId]/evals/configs/[configId].tsx b/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
index 05856093ea..e9e6e0ee57 100644
--- a/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
+++ b/web/src/pages/project/[projectId]/evals/configs/[configId].tsx
@@ -1,3 +1,51 @@
-import { EvalConfigDetail } from "@/src/ee/features/evals/components/eval-config-detail";
+import { prisma } from "@langfuse/shared/src/db";
+import { type GetServerSideProps } from "next";
+import { useRouter } from "next/router";
-export default EvalConfigDetail;
+// This url is deprecated, we keep this redirect page for backward compatibility
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ notFound: true,
+ };
+ }
+
+ const projectId = context.params.projectId as string;
+ const evaluatorId = context.params.configId as string;
+
+ const evaluator = await prisma.jobConfiguration.findUnique({
+ where: {
+ id: evaluatorId,
+ projectId,
+ },
+ select: {
+ project: {
+ select: {
+ id: true,
+ },
+ },
+ },
+ });
+
+ if (!evaluator) {
+ return {
+ notFound: true,
+ };
+ }
+
+ return {
+ redirect: {
+ destination: `/project/${projectId}/evals/${evaluatorId}`,
+ permanent: false,
+ },
+ };
+};
+
+export default function RedirectPage() {
+ const router = useRouter();
+ if (router.isFallback) {
+ return <div>Loading...</div>;
+ }
+
+ return <div>Redirecting...</div>;
+}
diff --git a/web/src/pages/project/[projectId]/evals/configs/index.tsx b/web/src/pages/project/[projectId]/evals/configs/index.tsx
index 5a84e3c301..2988721681 100644
--- a/web/src/pages/project/[projectId]/evals/configs/index.tsx
+++ b/web/src/pages/project/[projectId]/evals/configs/index.tsx
@@ -1 +1,28 @@
-export { default as default } from "@/src/ee/features/evals/pages/configs";
+import { type GetServerSideProps } from "next";
+import { useRouter } from "next/router";
+
+// This url is deprecated, we keep this redirect page for backward compatibility
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ notFound: true,
+ };
+ }
+ const projectId = context.params.projectId as string;
+
+ return {
+ redirect: {
+ destination: `/project/${projectId}/evals`,
+ permanent: false,
+ },
+ };
+};
+
+export default function RedirectPage() {
+ const router = useRouter();
+ if (router.isFallback) {
+ return <div>Loading...</div>;
+ }
+
+ return <div>Redirecting...</div>;
+}
diff --git a/web/src/pages/project/[projectId]/evals/configs/new.tsx b/web/src/pages/project/[projectId]/evals/configs/new.tsx
index 23a8a6781c..36741bc10d 100644
--- a/web/src/pages/project/[projectId]/evals/configs/new.tsx
+++ b/web/src/pages/project/[projectId]/evals/configs/new.tsx
@@ -1 +1,28 @@
-export { default as default } from "@/src/ee/features/evals/pages/new-configs";
+import { type GetServerSideProps } from "next";
+import { useRouter } from "next/router";
+
+// This url is deprecated, we keep this redirect page for backward compatibility
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ if (!context.params) {
+ return {
+ notFound: true,
+ };
+ }
+ const projectId = context.params.projectId as string;
+
+ return {
+ redirect: {
+ destination: `/project/${projectId}/evals/new`,
+ permanent: false,
+ },
+ };
+};
+
+export default function RedirectPage() {
+ const router = useRouter();
+ if (router.isFallback) {
+ return <div>Loading...</div>;
+ }
+
+ return <div>Redirecting...</div>;
+}
diff --git a/web/src/pages/project/[projectId]/evals/index.tsx b/web/src/pages/project/[projectId]/evals/index.tsx
new file mode 100644
index 0000000000..ca88942ec5
--- /dev/null
+++ b/web/src/pages/project/[projectId]/evals/index.tsx
@@ -0,0 +1 @@
+export { default as default } from "@/src/ee/features/evals/pages/evaluators";
diff --git a/web/src/pages/project/[projectId]/evals/log.tsx b/web/src/pages/project/[projectId]/evals/log.tsx
index 1d012047bb..6173dd87db 100644
--- a/web/src/pages/project/[projectId]/evals/log.tsx
+++ b/web/src/pages/project/[projectId]/evals/log.tsx
@@ -7,11 +7,23 @@ import Header from "@/src/components/layouts/header";
import { useRouter } from "next/router";
import EvalLogTable from "@/src/ee/features/evals/components/eval-log";
import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
+import Link from "next/link";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-export default function TemplatesPage() {
+export default function LogPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ const hasReadAccess = useHasProjectAccess({
+ projectId,
+ scope: "evalJobExecution:read",
+ });
+
+ if (!hasReadAccess) {
+ return null;
+ }
+
return (
<FullScreenPage>
<Header
@@ -21,7 +33,24 @@ export default function TemplatesPage() {
href: "https://langfuse.com/docs/scores/model-based-evals",
}}
/>
- <EvalLogTable projectId={projectId} />
+ <EvalLogTable
+ projectId={projectId}
+ menuItems={
+ <Tabs value="log">
+ <TabsList>
+ <TabsTrigger value="evaluators" asChild>
+ <Link href={`/project/${projectId}/evals`}>Evaluators</Link>
+ </TabsTrigger>
+ <TabsTrigger value="templates" asChild>
+ <Link href={`/project/${projectId}/evals/templates`}>
+ Templates
+ </Link>
+ </TabsTrigger>
+ <TabsTrigger value="log">Log</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ }
+ />
</FullScreenPage>
);
}
diff --git a/web/src/pages/project/[projectId]/evals/new.tsx b/web/src/pages/project/[projectId]/evals/new.tsx
new file mode 100644
index 0000000000..55a1799539
--- /dev/null
+++ b/web/src/pages/project/[projectId]/evals/new.tsx
@@ -0,0 +1 @@
+export { default as default } from "@/src/ee/features/evals/pages/new-evaluator";