🪢 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
perf: add exact timestamp match for eval batch actions (#7077)
Max Deichmannf0408b208ed1
diff --git a/packages/shared/src/server/queues.ts b/packages/shared/src/server/queues.tsindex a42f5b2286..8711e65fc2 100644--- a/packages/shared/src/server/queues.ts+++ b/packages/shared/src/server/queues.ts@@ -120,6 +120,7 @@ export const CreateEvalQueueEventSchema = DatasetRunItemUpsertEventSchema.and(z.object({timestamp: z.date(),configId: z.string(),+ exactTimestamp: z.date().optional(),}),),);diff --git a/packages/shared/src/server/repositories/traces.ts b/packages/shared/src/server/repositories/traces.tsindex fc57ec1189..b04f2294ed 100644--- a/packages/shared/src/server/repositories/traces.ts+++ b/packages/shared/src/server/repositories/traces.ts@@ -48,12 +48,14 @@ export const checkTraceExists = async ({timestamp,filter,maxTimeStamp,+ exactTimestamp,}: {projectId: string;traceId: string;timestamp: Date;filter: FilterState;maxTimeStamp: Date | undefined;+ exactTimestamp?: Date;}): Promise<boolean> => {const { tracesFilter } = getProjectIdDefaultFilter(projectId, {tracesPrefix: "t",@@ -111,6 +113,7 @@ export const checkTraceExists = async ({AND timestamp >= {timestamp: DateTime64(3)} - ${TRACE_TO_OBSERVATIONS_INTERVAL}${maxTimeStamp ? `AND timestamp <= {maxTimeStamp: DateTime64(3)}` : ""}${!maxTimeStamp ? `AND timestamp <= {timestamp: DateTime64(3)} + INTERVAL 2 DAY` : ""}+ ${exactTimestamp ? `AND timestamp = {exactTimestamp: DateTime64(3)}` : ""}GROUP BY t.id, t.project_id`;@@ -126,6 +129,9 @@ export const checkTraceExists = async ({...(maxTimeStamp? { maxTimeStamp: convertDateToClickhouseDateTime(maxTimeStamp) }: {}),+ ...(exactTimestamp+ ? { exactTimestamp: convertDateToClickhouseDateTime(exactTimestamp) }+ : {}),},tags: {feature: "tracing",diff --git a/worker/src/ee/evaluation/evalService.ts b/worker/src/ee/evaluation/evalService.tsindex 107f291064..eb0683e2b7 100644--- a/worker/src/ee/evaluation/evalService.ts+++ b/worker/src/ee/evaluation/evalService.ts@@ -211,6 +211,10 @@ export const createEvalJobs = async ({: new Date(jobTimestamp),filter: config.target_object === "trace" ? validatedFilter : [],maxTimeStamp,+ exactTimestamp:+ "exactTimestamp" in event && event.exactTimestamp+ ? new Date(event.exactTimestamp)+ : undefined,});const isDatasetConfig = config.target_object === "dataset";diff --git a/worker/src/features/batchAction/handleBatchActionJob.ts b/worker/src/features/batchAction/handleBatchActionJob.tsindex 0dc01b3b39..bcf937f37a 100644--- a/worker/src/features/batchAction/handleBatchActionJob.ts+++ b/worker/src/features/batchAction/handleBatchActionJob.ts@@ -211,6 +211,7 @@ export const handleBatchActionJob = async (traceId: record.id,configId: configId,timestamp: new Date(record.timestamp),+ exactTimestamp: new Date(record.timestamp),};await evalCreatorQueue.add(QueueJobs.CreateEvalJob, {