🪢 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
feat(evals): Extend job configuration filter options; Evaluators can run based on environments (#6039)
David Alexander Pfeiffer03cf7bccfce9
diff --git a/packages/shared/src/tableDefinitions/tracesTable.ts b/packages/shared/src/tableDefinitions/tracesTable.tsindex 85d1015316..0ac998013b 100644--- a/packages/shared/src/tableDefinitions/tracesTable.ts+++ b/packages/shared/src/tableDefinitions/tracesTable.ts@@ -16,6 +16,13 @@ export const tracesOnlyCols: ColumnDefinition[] = [options: [], // to be filled in at runtimenullable: true,},+ {+ name: "Environment",+ id: "environment",+ type: "stringOptions",+ internal: 't."environment"',+ options: [], // to be filled in at runtime+ },{name: "Timestamp",id: "timestamp",@@ -179,9 +186,10 @@ export const datasetOnlyCols: ColumnDefinition[] = [datasetCol];export const evalTraceTableCols: ColumnDefinition[] = tracesOnlyCols;export const evalDatasetFormFilterCols: ColumnDefinition[] = datasetOnlyCols;export type TraceOptions = {- scores_avg: Array<string>;- name: Array<OptionsDefinition>;- tags: Array<OptionsDefinition>;+ scores_avg?: Array<string>;+ name?: Array<OptionsDefinition>;+ tags?: Array<OptionsDefinition>;+ environment?: Array<OptionsDefinition>;};export type DatasetOptions = {datasetId: Array<OptionsDefinition>;@@ -214,6 +222,9 @@ export function tracesTableColsWithOptions(if (col.id === "tags") {return { ...col, options: options?.tags ?? [] };}+ if (col.id === "environment") {+ return { ...col, options: options?.environment ?? [] };+ }return col;});}diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsxindex f25de825e8..73d15455ce 100644--- a/web/src/components/table/use-cases/traces.tsx+++ b/web/src/components/table/use-cases/traces.tsx@@ -32,7 +32,6 @@ import { useDetailPageLists } from "@/src/features/navigate-detail-pages/contextimport { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {type FilterState,- type TraceOptions,tracesTableColsWithOptions,type ObservationLevelType,BatchExportTableName,@@ -266,20 +265,11 @@ export default function TracesTable({// loading filter options individually from the remaining calls// traces.all should load first together with everything else.// This here happens in the background.- const traceFilterOptions = api.traces.filterOptions.useQuery(- {- projectId,- timestampFilter:- dateRangeFilter[0]?.type === "datetime"- ? dateRangeFilter[0]- : undefined,- },++ const traceFilterOptionsResponse = api.traces.filterOptions.useQuery(+ { projectId },{- trpc: {- context: {- skipBatch: true,- },- },+ trpc: { context: { skipBatch: true } },refetchOnMount: false,refetchOnWindowFocus: false,refetchOnReconnect: false,@@ -287,13 +277,16 @@ export default function TracesTable({},);- const transformFilterOptions = (- traceFilterOptions: TraceOptions | undefined,- ) => {+ const traceFilterOptions = traceFilterOptionsResponse.data;++ const transformedFilterOptions = useMemo(() => {return tracesTableColsWithOptions(traceFilterOptions).filter(- (c) => !omittedFilter?.includes(c.name),+ (c) =>+ c.id !== "environment" &&+ !omittedFilter?.includes(c.name) &&+ !omittedFilter?.includes(c.id),);- };+ }, [traceFilterOptions, omittedFilter]);const [rowHeight, setRowHeight] = useRowHeightLocalStorage("traces", "s");const { scoreColumns, scoreKeysAndProps, isColumnLoading } =@@ -854,7 +847,7 @@ export default function TracesTable({cell: ({ row }) => {const tags: TracesTableRow["tags"] = row.getValue("tags");const traceId: TracesTableRow["id"] = row.getValue("id");- const filterOptionTags = traceFilterOptions.data?.tags ?? [];+ const filterOptionTags = traceFilterOptions?.tags ?? [];const allTags = filterOptionTags.map((t) => t.value);return (<TagTracePopover@@ -966,7 +959,7 @@ export default function TracesTable({<><DataTableToolbarcolumns={columns}- filterColumnDefinition={transformFilterOptions(traceFilterOptions.data)}+ filterColumnDefinition={transformedFilterOptions}searchConfig={{placeholder: "Search (by id, name, trace name, user id)",updateQuery: setSearchQuery,diff --git a/web/src/ee/features/evals/components/inner-evaluator-form.tsx b/web/src/ee/features/evals/components/inner-evaluator-form.tsxindex 27b2706f2b..6001af5bc7 100644--- a/web/src/ee/features/evals/components/inner-evaluator-form.tsx+++ b/web/src/ee/features/evals/components/inner-evaluator-form.tsx@@ -109,16 +109,10 @@ export const InnerEvaluatorForm = (props: {},});- const traceFilterOptions = api.traces.filterOptions.useQuery(+ const traceFilterOptionsResponse = api.traces.filterOptions.useQuery(+ { projectId: props.projectId },{- projectId: props.projectId,- },- {- trpc: {- context: {- skipBatch: true,- },- },+ trpc: { context: { skipBatch: true } },refetchOnMount: false,refetchOnWindowFocus: false,refetchOnReconnect: false,@@ -126,6 +120,27 @@ export const InnerEvaluatorForm = (props: {},);+ const environmentFilterOptionsResponse =+ api.projects.environmentFilterOptions.useQuery(+ { projectId: props.projectId },+ {+ trpc: { context: { skipBatch: true } },+ refetchOnMount: false,+ refetchOnWindowFocus: false,+ refetchOnReconnect: false,+ staleTime: Infinity,+ },+ );++ const traceFilterOptions = useMemo(() => {+ return {+ ...(traceFilterOptionsResponse.data ?? {}),+ environment: environmentFilterOptionsResponse.data?.map((e) => ({+ value: e.environment,+ })),+ };+ }, [traceFilterOptionsResponse.data, environmentFilterOptionsResponse.data]);+const datasets = api.datasets.allDatasetMeta.useQuery({projectId: props.projectId,@@ -450,7 +465,7 @@ export const InnerEvaluatorForm = (props: {<FormControl><InlineFilterBuildercolumns={tracesTableColsWithOptions(- traceFilterOptions.data,+ traceFilterOptions,evalTraceTableCols,)}filterState={field.value ?? []}diff --git a/web/src/features/filters/components/multi-select.tsx b/web/src/features/filters/components/multi-select.tsxindex 669d40fa6f..09ffce42b6 100644--- a/web/src/features/filters/components/multi-select.tsx+++ b/web/src/features/filters/components/multi-select.tsx@@ -98,7 +98,7 @@ export function MultiSelect({<Buttonvariant="outline"className={cn(- "flex h-8 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",+ "flex h-8 w-full items-center justify-between gap-x-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",className,)}disabled={disabled}@@ -107,7 +107,7 @@ export function MultiSelect({<ChevronDown className="h-4 w-4 opacity-50" />{selectedValues.size > 0 && (<>- <Separator orientation="vertical" className="mx-2 h-4" />+ <Separator orientation="vertical" className="mr-auto h-4" /><Badgevariant="secondary"className="rounded-sm px-1 font-normal lg:hidden"@@ -148,6 +148,7 @@ export function MultiSelect({)}<InputCommandGroup>{options.map((option) => {+ if (option.value.length === 0) return;const isSelected = selectedValues.has(option.value);return (<InputCommandItem@@ -172,9 +173,12 @@ export function MultiSelect({><Check className={cn("h-4 w-4")} /></div>- <span className="overflow-x-scroll">+ <div+ className="overflow-x-hidden text-ellipsis whitespace-nowrap"+ title={option.displayValue ?? option.value}+ >{option.displayValue ?? option.value}- </span>+ </div>{option.count !== undefined ? (<span className="ml-auto flex h-4 w-4 items-center justify-center pl-1 font-mono text-xs">{option.count}diff --git a/worker/src/__tests__/evalService.filtering.test.ts b/worker/src/__tests__/evalService.filtering.test.tsnew file mode 100644index 0000000000..9250a3dbca--- /dev/null+++ b/worker/src/__tests__/evalService.filtering.test.ts@@ -0,0 +1,658 @@+import { ObservationLevel, singleFilter } from "@langfuse/shared";+import {+ JobConfiguration,+ kyselyPrisma,+ prisma,+} from "@langfuse/shared/src/db";+import {+ convertDateToClickhouseDateTime,+ createOrgProjectAndApiKey,+ TraceRecordReadType,+ upsertObservation,+ upsertTrace,+} from "@langfuse/shared/src/server";+import { randomUUID } from "crypto";+import Decimal from "decimal.js";+import { afterAll, test as baseTest, beforeAll, describe } from "vitest";+import { z } from "zod";+import { createEvalJobs } from "../ee/evaluation/evalService";+import { OpenAIServer } from "./network";+import { pruneDatabase } from "./utils";++let OPENAI_API_KEY = process.env.OPENAI_API_KEY;+const hasActiveKey = Boolean(OPENAI_API_KEY);+if (!hasActiveKey) {+ OPENAI_API_KEY = "sk-test_not_used_as_network_mocks_are_activated";+}+const openAIServer = new OpenAIServer({+ hasActiveKey,+ useDefaultResponse: false,+});++beforeAll(openAIServer.setup);+beforeAll(async () => {+ await pruneDatabase();+ openAIServer.respondWithDefault();+});+afterAll(openAIServer.teardown);++type EvalJobEventPartial = Omit<+ Parameters<typeof createEvalJobs>[0]["event"],+ "projectId" | "traceId"+>;++type TraceRecordOmitProjectId = Partial<Omit<TraceRecordReadType, "projectId">>;+type TraceRecordOmitProjectIdAndId = Partial<+ Omit<TraceRecordReadType, "projectId" | "id">+>;++const __getJobs = (projectId: string) =>+ kyselyPrisma.$kysely+ .selectFrom("job_executions")+ .selectAll()+ .where("project_id", "=", projectId)+ .execute();++type JobExecutions = Awaited<ReturnType<typeof __getJobs>>;++const test = baseTest.extend<{+ traceId1: string;+ traceId2: string;+ projectId: string;+ upsertTrace: (trace: TraceRecordOmitProjectId) => Promise<void>;+ upsertTwoTraces: (+ traces?: [TraceRecordOmitProjectIdAndId, TraceRecordOmitProjectIdAndId],+ ) => Promise<void>;+ configureJob: (+ job: Partial<+ Omit<JobConfiguration, "projectId" | "evalTemplateId" | "id" | "filter">+ > & {+ filter: z.infer<typeof singleFilter>[];+ },+ ) => Promise<void>;+ configureDefaultJobWithSingleFilter: (+ filter: z.infer<typeof singleFilter>,+ ) => Promise<void>;+ createTwoEvalJobs: (+ events?: [EvalJobEventPartial, EvalJobEventPartial],+ ) => Promise<void>;+ getJobs: () => Promise<JobExecutions>;+}>({+ projectId: async ({}, use) => {+ const projectId = randomUUID();++ await createOrgProjectAndApiKey({+ projectId,+ });++ await use(projectId);+ },+ traceId1: randomUUID(),+ traceId2: randomUUID(),+ upsertTrace: async ({ projectId }, use) => {+ await use(async (trace) => {+ const now = new Date();+ const clickhouseNow = convertDateToClickhouseDateTime(now);+ await upsertTrace({+ id: trace.id,+ project_id: projectId,+ timestamp: clickhouseNow,+ created_at: clickhouseNow,+ updated_at: clickhouseNow,+ ...trace,+ });+ });+ },+ upsertTwoTraces: async ({ traceId1, traceId2, upsertTrace }, use) => {+ await use(async ([trace1, trace2] = [{}, {}]) => {+ await upsertTrace({ ...trace1, id: traceId1 });+ await upsertTrace({ ...trace2, id: traceId2 });+ });+ },+ configureJob: async ({ projectId }, use) => {+ const evalTemplate = await prisma.evalTemplate.create({+ data: {+ id: randomUUID(),+ projectId,+ name: "test-template",+ version: 1,+ prompt: "Evaluate this trace",+ model: "gpt-3.5-turbo",+ provider: "openai",+ modelParams: { temperature: 0 },+ vars: [],+ outputSchema: {+ type: "object",+ properties: { score: { type: "number" } },+ },+ },+ });+ await use(async (job) => {+ await prisma.jobConfiguration.create({+ data: {+ id: randomUUID(),+ projectId,+ evalTemplateId: evalTemplate.id,+ jobType: "EVAL",+ delay: 0,+ sampling: new Decimal("1"),+ targetObject: "trace",+ scoreName: "score",+ variableMapping: JSON.parse("[]"),+ ...job,+ },+ });+ });+ },+ configureDefaultJobWithSingleFilter: async ({ configureJob }, use) => {+ await use(async (filter) => {+ await configureJob({ filter: [filter] });+ });+ },+ createTwoEvalJobs: async ({ projectId, traceId1, traceId2 }, use) => {+ await use(async ([event1, event2] = [{}, {}]) => {+ await createEvalJobs({+ event: {+ projectId,+ traceId: traceId1,+ ...event1,+ },+ });+ await createEvalJobs({+ event: {+ projectId,+ traceId: traceId2,+ ...event2,+ },+ });+ });+ },+ getJobs: async ({ projectId }, use) => {+ await use(async () => await __getJobs(projectId));+ },+});++describe.concurrent("test eval filtering", () => {+ test("creates eval job only for matching environment", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different environments+ await upsertTwoTraces([+ {+ environment: "production",+ },+ {+ environment: "staging",+ },+ ]);++ // Create job configuration with environment filter+ await configureDefaultJobWithSingleFilter({+ type: "stringOptions",+ value: ["production"],+ column: "Environment",+ operator: "any of",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching environment's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1); // Only the production environment trace should have a job+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching name", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different names+ await upsertTwoTraces([+ {+ name: "important-trace",+ },+ {+ name: "unimportant-trace",+ },+ ]);++ // Create job configuration with name filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: "important-trace",+ column: "Name",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching name's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1); // Only the important-trace should have a job+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching ID", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces+ await upsertTwoTraces();++ // Create job configuration with ID filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: traceId1,+ column: "ID",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching ID's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching timestamp range", async ({+ expect,+ upsertTwoTraces,+ configureJob,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ const now = new Date();+ const futureDate = new Date(now.getTime() + 1000 * 60 * 60 * 24); // 24 hours in the future+ const pastDate = new Date(now.getTime() - 1000 * 60 * 60 * 24); // 24 hours in the past++ // Create two traces with different timestamps+ await upsertTwoTraces([+ {+ timestamp: convertDateToClickhouseDateTime(now),+ created_at: convertDateToClickhouseDateTime(now),+ updated_at: convertDateToClickhouseDateTime(now),+ },+ {+ timestamp: convertDateToClickhouseDateTime(futureDate),+ created_at: convertDateToClickhouseDateTime(futureDate),+ updated_at: convertDateToClickhouseDateTime(futureDate),+ },+ ]);++ // Create job configuration with timestamp filter+ await configureJob({+ filter: [+ {+ type: "datetime",+ value: pastDate,+ column: "Timestamp",+ operator: ">=",+ } satisfies z.infer<typeof singleFilter>,+ {+ type: "datetime",+ value: now,+ column: "Timestamp",+ operator: "<=",+ } satisfies z.infer<typeof singleFilter>,+ ],+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs([+ {+ timestamp: now,+ },+ {+ timestamp: futureDate,+ },+ ]);++ // Check that only the trace within the timestamp range got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching user ID", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different user IDs+ await upsertTwoTraces([+ {+ user_id: "user1",+ },+ {+ user_id: "user2",+ },+ ]);++ // Create job configuration with user ID filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: "user1",+ column: "User ID",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching user ID's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching session ID", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different session IDs+ await upsertTwoTraces([+ {+ session_id: "session1",+ },+ {+ session_id: "session2",+ },+ ]);++ // Create job configuration with session ID filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: "session1",+ column: "Session ID",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching session ID's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching metadata", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different metadata+ await upsertTwoTraces([+ {+ metadata: { key: "value1" },+ },+ {+ metadata: { key: "value2" },+ },+ ]);++ // Create job configuration with metadata filter+ await configureDefaultJobWithSingleFilter({+ type: "stringObject",+ key: "key",+ value: "value1",+ column: "metadata",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching metadata's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching version", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different versions+ await upsertTwoTraces([+ {+ version: "v1",+ },+ {+ version: "v2",+ },+ ]);++ // Create job configuration with version filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: "v1",+ column: "Version",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching version's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching release", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different releases+ await upsertTwoTraces([+ {+ release: "release1",+ },+ {+ release: "release2",+ },+ ]);++ // Create job configuration with release filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: "release1",+ column: "Release",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching release's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching level", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ traceId2,+ projectId,+ }) => {+ // Create two traces+ await upsertTwoTraces();++ // Create observations with different levels+ await upsertObservation({+ id: randomUUID(),+ project_id: projectId,+ trace_id: traceId1,+ level: ObservationLevel.DEFAULT.toString(),+ start_time: convertDateToClickhouseDateTime(new Date()),+ end_time: convertDateToClickhouseDateTime(new Date()),+ type: "SPAN",+ created_at: convertDateToClickhouseDateTime(new Date()),+ updated_at: convertDateToClickhouseDateTime(new Date()),+ });++ await upsertObservation({+ id: randomUUID(),+ project_id: projectId,+ trace_id: traceId2,+ level: ObservationLevel.ERROR.toString(),+ start_time: convertDateToClickhouseDateTime(new Date()),+ end_time: convertDateToClickhouseDateTime(new Date()),+ type: "SPAN",+ created_at: convertDateToClickhouseDateTime(new Date()),+ updated_at: convertDateToClickhouseDateTime(new Date()),+ });++ // Create job configuration with level filter+ await configureDefaultJobWithSingleFilter({+ type: "string",+ value: ObservationLevel.DEFAULT.toString(),+ column: "Level",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching level's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for matching tags", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different tags+ await upsertTwoTraces([+ {+ tags: ["tag1"],+ },+ {+ tags: ["tag2"],+ },+ ]);++ // Create job configuration with tags filter+ await configureDefaultJobWithSingleFilter({+ type: "arrayOptions",+ value: ["tag1"],+ column: "Tags",+ operator: "any of",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the matching tags's trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);++ test("creates eval job only for starred traces", async ({+ expect,+ upsertTwoTraces,+ configureDefaultJobWithSingleFilter,+ createTwoEvalJobs,+ getJobs,+ traceId1,+ }) => {+ // Create two traces with different bookmark status+ await upsertTwoTraces([+ {+ bookmarked: true,+ },+ {+ bookmarked: false,+ },+ ]);++ // Create job configuration with starred filter+ await configureDefaultJobWithSingleFilter({+ type: "boolean",+ value: true,+ column: "bookmarked",+ operator: "=",+ });++ // Create eval jobs for both traces+ await createTwoEvalJobs();++ // Check that only the starred trace got a job+ const jobs = await getJobs();++ expect(jobs.length).toBe(1);+ expect(jobs[0].job_input_trace_id).toBe(traceId1);+ expect(jobs[0].status.toString()).toBe("PENDING");+ }, 10_000);+});diff --git a/worker/src/__tests__/evalService.test.ts b/worker/src/__tests__/evalService.test.tsindex 5acf92147a..ca0b316582 100644--- a/worker/src/__tests__/evalService.test.ts+++ b/worker/src/__tests__/evalService.test.ts@@ -1,30 +1,11 @@import {- expect,- test,- describe,- afterAll,- beforeAll,- beforeEach,-} from "vitest";-import {- createEvalJobs,- evaluate,- extractVariablesFromTracingData,-} from "../ee/evaluation/evalService";-import { kyselyPrisma, prisma } from "@langfuse/shared/src/db";-import { randomUUID } from "crypto";-import Decimal from "decimal.js";-import { pruneDatabase } from "./utils";-import { sql } from "kysely";-import {+ ApiError,LLMAdapter,LangfuseNotFoundError,variableMappingList,- ApiError,} from "@langfuse/shared";import { encrypt } from "@langfuse/shared/encryption";-import { OpenAIServer } from "./network";-import { afterEach } from "node:test";+import { kyselyPrisma, prisma } from "@langfuse/shared/src/db";import {convertDateToClickhouseDateTime,createObservation,@@ -34,7 +15,26 @@ import {upsertObservation,upsertTrace,} from "@langfuse/shared/src/server";+import { randomUUID } from "crypto";+import Decimal from "decimal.js";+import { sql } from "kysely";+import { afterEach } from "node:test";+import {+ afterAll,+ beforeAll,+ beforeEach,+ describe,+ expect,+ test,+} from "vitest";+import {+ createEvalJobs,+ evaluate,+ extractVariablesFromTracingData,+} from "../ee/evaluation/evalService";import { compileHandlebarString } from "../features/utilities";+import { OpenAIServer } from "./network";+import { pruneDatabase } from "./utils";let OPENAI_API_KEY = process.env.OPENAI_API_KEY;const hasActiveKey = Boolean(OPENAI_API_KEY);