processAddTracesToQueue (batchAction/processAddToQueue.ts)

langfuse · worker/src/features/batchAction/processAddToQueue.ts · typescript · MIT
database

Module exposing: processAddTracesToQueue, processAddSessionsToQueue, processAddObservationsToQueue

// Source: https://github.com/langfuse/langfuse | License: MIT | Copyright 2023-2026 ClickHouse, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { logger, traceException } from "@langfuse/shared/src/server";
import { AnnotationQueueObjectType, prisma } from "@langfuse/shared/src/db";

const addToQueue = async ({
  projectId,
  objectIds,
  objectType,
  targetId,
}: {
  projectId: string;
  objectIds: string[];
  objectType: AnnotationQueueObjectType;
  targetId: string;
}) => {
  // cannot use prisma `createMany` operation as we do not have unique constraint enforced on schema level
  // conflict must be handled on query level by reading existing items and filtering out traces that already exist

  // First get existing items
  const existingItems = await prism

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key