🪢 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
fix(evals): do not create duplicate evals for DRI linked at observation level (#10567)
marliessophie782199ee53b7
diff --git a/packages/shared/src/server/repositories/dataset-run-items.ts b/packages/shared/src/server/repositories/dataset-run-items.tsindex ae89ab5048..dad9bfcbea 100644--- a/packages/shared/src/server/repositories/dataset-run-items.ts+++ b/packages/shared/src/server/repositories/dataset-run-items.ts@@ -972,7 +972,9 @@ export const getDatasetRunItemsWithoutIOByItemIds = async (export const getDatasetItemIdsByTraceIdCh = async (opts: DatasetItemIdsByTraceIdQuery,-): Promise<{ id: string; datasetId: string }[]> => {+): Promise<+ { id: string; datasetId: string; observationId: string | null }[]+> => {const { projectId, traceId, filter } = opts;const datasetRunItemsFilter = new FilterList([@@ -1001,6 +1003,7 @@ export const getDatasetItemIdsByTraceIdCh = async (const query = `SELECTdri.dataset_item_id as dataset_item_id,+ dri.observation_id as observation_id,dri.dataset_id as dataset_idFROM dataset_run_items_rmt driWHERE ${appliedFilter.query}@@ -1008,6 +1011,7 @@ export const getDatasetItemIdsByTraceIdCh = async (const res = await queryClickhouse<{dataset_item_id: string;+ observation_id: string | null;dataset_id: string;}>({query,@@ -1025,6 +1029,7 @@ export const getDatasetItemIdsByTraceIdCh = async (return res.map((runItem) => {return {id: runItem.dataset_item_id,+ observationId: runItem.observation_id,datasetId: runItem.dataset_id,};});diff --git a/worker/src/features/evaluation/evalService.ts b/worker/src/features/evaluation/evalService.tsindex 64c4c64304..5ecc2e91a3 100644--- a/worker/src/features/evaluation/evalService.ts+++ b/worker/src/features/evaluation/evalService.ts@@ -413,7 +413,10 @@ export const createEvalJobs = async ({});const isDatasetConfig = config.target_object === "dataset";- let datasetItem: { id: string } | undefined;+ let datasetItem:+ | { id: string }+ | { id: string; observationId: string | null }+ | undefined;if (isDatasetConfig) {const condition = tableColumnsToSqlFilterAndPrefix(config.target_object === "dataset" ? validatedFilter : [],@@ -458,6 +461,20 @@ export const createEvalJobs = async ({}}+ // we must check if the dataset run item is linked at the observation level, if so, we must skip the eval job+ // triggered by the trace-upsert queue as it would prematurely create a score at the trace level which is incorrect.+ if (+ sourceEventType === "trace-upsert" &&+ !!datasetItem &&+ "observationId" in datasetItem &&+ !!datasetItem.observationId+ ) {+ logger.info(+ `Eval job for project ${event.projectId} and dataset item ${datasetItem.id} should be evaluated at observation level`,+ );+ continue;+ }+// We also need to validate that the observation exists in case an observationId is set// If it's not set, we go into the retry loop. For the other events, we expect that the rerun// is unnecessary, as we're triggering this flow if either event comes in.