Skip to content

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

686 B
Raw Blame
import { type Prisma } from "@langfuse/shared";

type CheckHasProtectedLabelsParams = {
  labelsToCheck: string[];
  projectId: string;
  prisma: Prisma.TransactionClient;
};

export async function checkHasProtectedLabels(
  params: CheckHasProtectedLabelsParams,
): Promise<{ hasProtectedLabels: boolean; protectedLabels: string[] }> {
  const { labelsToCheck, projectId, prisma } = params;

  const protectedLabels = (
    await prisma.promptProtectedLabels.findMany({
      where: { projectId },
    })
  ).map((l) => l.label);

  const hasProtectedLabels = labelsToCheck.some((label) =>
    protectedLabels.includes(label),
  );

  return { hasProtectedLabels, protectedLabels };
}