🪢 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
chore: enable annotation queue on cloud:hobby and remove feature flags (#3712)
marliessophie7e933e89cb9d
diff --git a/packages/shared/prisma/seed.ts b/packages/shared/prisma/seed.tsindex 9654262a75..d6fdcaf086 100644--- a/packages/shared/prisma/seed.ts+++ b/packages/shared/prisma/seed.ts@@ -727,12 +727,10 @@ function createObjects(};const queueItem = [- ...(Math.random() > 0.9+ ...(Math.random() > 0.9 && queueIds.get(projectId)?.[0]? [{- queueId: queueIds.get(projectId)?.[- Math.floor(Math.random() * 2)- ] as string,+ queueId: queueIds.get(projectId)?.[0] as string,objectId: trace.id,objectType: AnnotationQueueObjectType.TRACE,projectId,@@ -1370,41 +1368,28 @@ async function generateQueues(categories: ConfigCategory[] | null;}[]) {- const queueIds: string[] = [];+ const queue = {+ id: `queue-${v4()}`,+ name: "Default",+ description: "Default queue",+ scoreConfigIds: configIdsAndNames.map((config) => config.id),+ projectId: project.id,+ };- const queues = [- {- id: `queue-${v4()}`,- name: "Default",- description: "Default queue",- scoreConfigIds: configIdsAndNames.map((config) => config.id),- projectId: project.id,+ await prisma.annotationQueue.upsert({+ where: {+ projectId_name: {+ projectId: queue.projectId,+ name: queue.name,+ },},- {- id: `queue-${v4()}`,- name: "Correction",- scoreConfigIds: [configIdsAndNames[0].id],- projectId: project.id,+ create: {+ ...queue,},- ];-- for (const queue of queues) {- await prisma.annotationQueue.upsert({- where: {- projectId_name: {- projectId: queue.projectId,- name: queue.name,- },- },- create: {- ...queue,- },- update: {- id: queue.id,- },- });- queueIds.push(queue.id);- }+ update: {+ id: queue.id,+ },+ });- return queueIds;+ return [queue.id];}diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsxindex 445d08eb96..bc97a90dc2 100644--- a/web/src/components/layouts/routes.tsx+++ b/web/src/components/layouts/routes.tsx@@ -88,13 +88,12 @@ export const ROUTES: Route[] = [],},{- name: "Annotation Queues",+ name: "Annotate",pathname: `/project/[projectId]/annotation-queues`,icon: ClipboardPen,label: "Beta",projectRbacScope: "annotationQueues:read",entitlement: "annotation-queues",- featureFlag: "annotationQueues",},{name: "Evaluation",diff --git a/web/src/components/trace/ObservationPreview.tsx b/web/src/components/trace/ObservationPreview.tsxindex d0907c6e4f..b0f2bc6d19 100644--- a/web/src/components/trace/ObservationPreview.tsx+++ b/web/src/components/trace/ObservationPreview.tsx@@ -28,11 +28,10 @@ import useLocalStorage from "@/src/components/useLocalStorage";import { CommentDrawerButton } from "@/src/features/comments/CommentDrawerButton";import { cn } from "@/src/utils/tailwind";import { NewDatasetItemFromTrace } from "@/src/features/datasets/components/NewDatasetItemFromObservationButton";-import { CreateNewAnnotationQueueItem } from "@/src/features/scores/components/CreateNewAnnotationQueueItem";+import { CreateNewAnnotationQueueItem } from "@/src/ee/features/annotation-queues/components/CreateNewAnnotationQueueItem";import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";import { calculateDisplayTotalCost } from "@/src/components/trace/lib/helpers";import { useMemo } from "react";-import useIsFeatureEnabled from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";export const ObservationPreview = ({observations,@@ -53,7 +52,6 @@ export const ObservationPreview = ({viewType?: "focused" | "detailed";className?: string;}) => {- const isFeatureFlagEnabled = useIsFeatureEnabled("annotationQueues");const [selectedTab, setSelectedTab] = useQueryParam("view",withDefault(StringParam, "preview"),@@ -231,9 +229,9 @@ export const ObservationPreview = ({emptySelectedConfigIds={emptySelectedConfigIds}setEmptySelectedConfigIds={setEmptySelectedConfigIds}type="observation"- hasGroupedButton={hasEntitlement && isFeatureFlagEnabled}+ hasGroupedButton={hasEntitlement}/>- {hasEntitlement && isFeatureFlagEnabled && (+ {hasEntitlement && (<CreateNewAnnotationQueueItemprojectId={projectId}objectId={preloadedObservation.id}diff --git a/web/src/components/trace/TracePreview.tsx b/web/src/components/trace/TracePreview.tsxindex dd103b36d8..cd48566b5c 100644--- a/web/src/components/trace/TracePreview.tsx+++ b/web/src/components/trace/TracePreview.tsx@@ -27,12 +27,11 @@ import useLocalStorage from "@/src/components/useLocalStorage";import { CommentDrawerButton } from "@/src/features/comments/CommentDrawerButton";import { cn } from "@/src/utils/tailwind";import { NewDatasetItemFromTrace } from "@/src/features/datasets/components/NewDatasetItemFromObservationButton";-import { CreateNewAnnotationQueueItem } from "@/src/features/scores/components/CreateNewAnnotationQueueItem";+import { CreateNewAnnotationQueueItem } from "@/src/ee/features/annotation-queues/components/CreateNewAnnotationQueueItem";import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";import { useMemo } from "react";import { usdFormatter } from "@/src/utils/numbers";import { calculateDisplayTotalCost } from "@/src/components/trace/lib/helpers";-import useIsFeatureEnabled from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";export const TracePreview = ({trace,@@ -49,7 +48,6 @@ export const TracePreview = ({viewType?: "detailed" | "focused";className?: string;}) => {- const isFeatureFlagEnabled = useIsFeatureEnabled("annotationQueues");const [selectedTab, setSelectedTab] = useQueryParam("view",withDefault(StringParam, "preview"),@@ -157,9 +155,9 @@ export const TracePreview = ({scores={scores}emptySelectedConfigIds={emptySelectedConfigIds}setEmptySelectedConfigIds={setEmptySelectedConfigIds}- hasGroupedButton={hasEntitlement && isFeatureFlagEnabled}+ hasGroupedButton={hasEntitlement}/>- {hasEntitlement && isFeatureFlagEnabled && (+ {hasEntitlement && (<CreateNewAnnotationQueueItemprojectId={trace.projectId}objectId={trace.id}diff --git a/web/src/features/scores/components/AnnotationQueueItemPage.tsx b/web/src/ee/features/annotation-queues/components/AnnotationQueueItemPage.tsxsimilarity index 100%rename from web/src/features/scores/components/AnnotationQueueItemPage.tsxrename to web/src/ee/features/annotation-queues/components/AnnotationQueueItemPage.tsxdiff --git a/web/src/features/scores/components/AnnotationQueueItemsTable.tsx b/web/src/ee/features/annotation-queues/components/AnnotationQueueItemsTable.tsxsimilarity index 100%rename from web/src/features/scores/components/AnnotationQueueItemsTable.tsxrename to web/src/ee/features/annotation-queues/components/AnnotationQueueItemsTable.tsxdiff --git a/web/src/ee/features/annotation-queues/components/AnnotationQueuesItem.tsx b/web/src/ee/features/annotation-queues/components/AnnotationQueuesItem.tsxnew file mode 100644index 0000000000..7d6c21754e--- /dev/null+++ b/web/src/ee/features/annotation-queues/components/AnnotationQueuesItem.tsx@@ -0,0 +1,93 @@+import { FullScreenPage } from "@/src/components/layouts/full-screen-page";+import Header from "@/src/components/layouts/header";+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";+import useSessionStorage from "@/src/components/useSessionStorage";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";+import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { AnnotationQueueItemPage } from "@/src/ee/features/annotation-queues/components/AnnotationQueueItemPage";+import { api } from "@/src/utils/api";+import { Goal, Network } from "lucide-react";++export const AnnotationQueuesItem = ({+ annotationQueueId,+ projectId,+ itemId,+}: {+ annotationQueueId: string;+ projectId: string;+ itemId?: string;+}) => {+ const hasAccess = useHasProjectAccess({+ projectId,+ scope: "annotationQueues:read",+ });+ const hasEntitlement = useHasOrgEntitlement("annotation-queues");++ const queue = api.annotationQueues.byId.useQuery(+ {+ queueId: annotationQueueId,+ projectId,+ },+ {+ trpc: {+ context: {+ skipBatch: true,+ },+ },+ refetchOnMount: false, // prevents refetching loops+ },+ );++ const [view, setView] = useSessionStorage<"hideTree" | "showTree">(+ `annotationQueueView-${projectId}`,+ "hideTree",+ );++ if (!hasAccess || !hasEntitlement) return <SupportOrUpgradePage />;++ return (+ <FullScreenPage>+ <>+ <Header+ title={`${queue.data?.name ?? annotationQueueId}`}+ breadcrumb={[+ {+ name: "Annotation Queues",+ href: `/project/${projectId}/annotation-queues`,+ },+ {+ name: queue.data?.name ?? annotationQueueId,+ href: `/project/${projectId}/annotation-queues/${annotationQueueId}`,+ },+ ]}+ actionButtons={+ <Tabs+ value={view}+ onValueChange={(view: string) => {+ setView(view as "hideTree" | "showTree");+ }}+ >+ <TabsList>+ <TabsTrigger value="hideTree">+ <Goal className="mr-1 h-4 w-4"></Goal>+ Focused+ </TabsTrigger>+ <TabsTrigger value="showTree">+ <Network className="mr-1 h-4 w-4"></Network>+ Detailed+ </TabsTrigger>+ </TabsList>+ </Tabs>+ }+ />+ <AnnotationQueueItemPage+ projectId={projectId}+ annotationQueueId={annotationQueueId}+ view={view}+ queryItemId={itemId}+ />+ </>+ </FullScreenPage>+ );+};diff --git a/web/src/features/scores/components/AnnotationQueuesTable.tsx b/web/src/ee/features/annotation-queues/components/AnnotationQueuesTable.tsxsimilarity index 96%rename from web/src/features/scores/components/AnnotationQueuesTable.tsxrename to web/src/ee/features/annotation-queues/components/AnnotationQueuesTable.tsxindex 12074248f4..ca66b72d01 100644--- a/web/src/features/scores/components/AnnotationQueuesTable.tsx+++ b/web/src/ee/features/annotation-queues/components/AnnotationQueuesTable.tsx@@ -7,7 +7,7 @@ import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumimport { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrder";-import { CreateOrEditAnnotationQueueButton } from "@/src/features/scores/components/CreateOrEditAnnotationQueueButton";+import { CreateOrEditAnnotationQueueButton } from "@/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";import { type ScoreDataType } from "@langfuse/shared";import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";import {@@ -18,11 +18,11 @@ import {} from "@/src/components/ui/dropdown-menu";import { ClipboardPen, Lock, MoreVertical } from "lucide-react";import { Button } from "@/src/components/ui/button";-import { DeleteAnnotationQueueButton } from "@/src/features/scores/components/DeleteAnnotationQueueButton";import { cn } from "@/src/utils/tailwind";import TableLink from "@/src/components/table/table-link";import Link from "next/link";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { DeleteAnnotationQueueButton } from "@/src/ee/features/annotation-queues/components/DeleteAnnotationQueueButton";type RowData = {key: {diff --git a/web/src/features/scores/components/CreateNewAnnotationQueueItem.tsx b/web/src/ee/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsxsimilarity index 100%rename from web/src/features/scores/components/CreateNewAnnotationQueueItem.tsxrename to web/src/ee/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsxdiff --git a/web/src/features/scores/components/CreateOrEditAnnotationQueueButton.tsx b/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsxsimilarity index 81%rename from web/src/features/scores/components/CreateOrEditAnnotationQueueButton.tsxrename to web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsxindex 3478ba189c..c8e6b7073d 100644--- a/web/src/features/scores/components/CreateOrEditAnnotationQueueButton.tsx+++ b/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx@@ -19,7 +19,7 @@ import {import { Input } from "@/src/components/ui/input";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { zodResolver } from "@hookform/resolvers/zod";-import { Edit, LockIcon, PlusIcon } from "lucide-react";+import { CircleAlert, Edit, LockIcon, PlusIcon } from "lucide-react";import { useForm } from "react-hook-form";import { Form } from "@/src/components/ui/form";import { Textarea } from "@/src/components/ui/textarea";@@ -34,6 +34,12 @@ import { MultiSelectKeyValues } from "@/src/features/scores/components/multi-selimport { CommandItem } from "@/src/components/ui/command";import { useRouter } from "next/router";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useOrganizationPlan } from "@/src/features/entitlements/hooks";+import {+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@/src/components/ui/hover-card";export const CreateOrEditAnnotationQueueButton = ({projectId,@@ -50,11 +56,12 @@ export const CreateOrEditAnnotationQueueButton = ({scope: "annotationQueues:CUD",});const router = useRouter();+ const plan = useOrganizationPlan();const capture = usePostHogClientCapture();const queueQuery = api.annotationQueues.byId.useQuery({ projectId, queueId: queueId as string },- { enabled: !!queueId },+ { enabled: !!queueId && hasAccess },);const form = useForm<CreateQueue>({@@ -96,6 +103,11 @@ export const CreateOrEditAnnotationQueueButton = ({},});+ const queueCountData = api.annotationQueues.count.useQuery(+ { projectId },+ { enabled: hasAccess },+ );+const configsData = api.scoreConfigs.all.useQuery({projectId,@@ -111,13 +123,51 @@ export const CreateOrEditAnnotationQueueButton = ({return (<Button variant={variant} disabled={true} className="justify-start"><LockIcon className="-ml-0.5 mr-1.5 h-4 w-4" aria-hidden="true" />- <span className="text-sm font-normal">- {queueId ? "Edit" : "New queue"}- </span>+ <span className="text-sm">{queueId ? "Edit" : "New queue"}</span></Button>);}+ if (queueCountData.isLoading) return null;++ // gate cloud hobby usage of annotation queue+ if (plan === "cloud:hobby" && !!queueCountData.data && !queueId) {+ return (+ <HoverCard>+ <HoverCardTrigger asChild>+ <Button+ variant={variant}+ className="relative grid grid-flow-row items-start justify-start overflow-hidden py-0 disabled:cursor-default"+ disabled+ >+ <div className="mt-2 flex h-6 flex-row items-center justify-center">+ <PlusIcon className="mr-1.5 h-4 w-4" aria-hidden="true" />+ <span className="text-sm">New queue</span>+ </div>+ <div className="absolute top-0 flex h-3 w-full items-center justify-center bg-primary-accent">+ <CircleAlert+ className="mr-1 h-2 w-2 text-white"+ aria-hidden="true"+ />+ <span className="text-xs text-white">At usage limit</span>+ </div>+ </Button>+ </HoverCardTrigger>+ <HoverCardContent className="w-80" align="start" side="right">+ <div className="flex justify-between space-x-4">+ <div className="space-y-1">+ <h4 className="text-sm font-semibold">Usage Limit Reached</h4>+ <p className="text-xs">+ You have reached the maximum number of annotation queues allowed+ on the Hobby plan. Upgrade your plan to create more queues.+ </p>+ </div>+ </div>+ </HoverCardContent>+ </HoverCard>+ );+ }+const onSubmit = (data: CreateQueue) => {if (queueId) {editQueueMutation.mutateAsync({diff --git a/web/src/features/scores/components/DeleteAnnotationQueueButton.tsx b/web/src/ee/features/annotation-queues/components/DeleteAnnotationQueueButton.tsxsimilarity index 100%rename from web/src/features/scores/components/DeleteAnnotationQueueButton.tsxrename to web/src/ee/features/annotation-queues/components/DeleteAnnotationQueueButton.tsxdiff --git a/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx b/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsxnew file mode 100644index 0000000000..a741de9827--- /dev/null+++ b/web/src/ee/features/annotation-queues/pages/AnnotationQueueItems.tsx@@ -0,0 +1,176 @@+import Header from "@/src/components/layouts/header";+import { api } from "@/src/utils/api";+import { useRouter } from "next/router";+import { FullScreenPage } from "@/src/components/layouts/full-screen-page";+import { AnnotationQueueItemsTable } from "@/src/ee/features/annotation-queues/components/AnnotationQueueItemsTable";+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/src/components/ui/card";+import { Button } from "@/src/components/ui/button";+import { ChevronRight, ClipboardPen, Lock } from "lucide-react";+import { Separator } from "@/src/components/ui/separator";+import { useState } from "react";+import { Badge } from "@/src/components/ui/badge";+import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";+import Link from "next/link";+import { CreateOrEditAnnotationQueueButton } from "@/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";+import { Skeleton } from "@/src/components/ui/skeleton";++const TableWithMetadataWrapper = ({+ tableComponent,+ cardTitleChildren,+ cardContentChildren,+}: {+ tableComponent: React.ReactNode;+ cardTitleChildren: React.ReactNode;+ cardContentChildren: React.ReactNode;+}) => {+ const [isCollapsed, setIsCollapsed] = useState(false);++ return (+ <div+ className={`grid h-[calc(100dvh-8rem)] ${isCollapsed ? "grid-cols-[2fr,auto]" : "grid-cols-[2fr,1fr]"} gap-4 overflow-hidden lg:h-[calc(100dvh-4rem)]`}+ >+ <div className="flex h-full flex-col overflow-hidden">+ {tableComponent}+ </div>+ <div+ className={`my-2 flex flex-row ${isCollapsed ? "w-8" : "w-full"} h-full overflow-hidden`}+ >+ <div className="grid h-full w-full grid-cols-[auto,1fr] items-start gap-2 overflow-hidden">+ <div className="grid h-full w-full grid-rows-[auto,1fr] gap-2">+ <Button+ variant="outline"+ size="icon"+ onClick={() => setIsCollapsed(!isCollapsed)}+ >+ <ChevronRight+ className={`h-4 w-4 transform ${isCollapsed ? "rotate-180" : ""}`}+ />+ </Button>+ <Separator orientation="vertical" className="ml-4 h-full" />+ </div>+ <div+ className={`${isCollapsed ? "hidden" : "block"} mt-8 grid h-[calc(100%-2rem)] w-full grid-rows-[auto,1fr] gap-2 overflow-hidden p-2`}+ >+ <Card className="flex h-full flex-col overflow-hidden">+ <div className="flex h-full overflow-y-auto">+ <CardHeader className="flex h-full w-full flex-col space-y-4">+ <CardTitle className="flex justify-between text-xl font-bold leading-7 sm:tracking-tight">+ {cardTitleChildren}+ </CardTitle>+ <CardContent className="flex-1 space-y-4 p-0">+ {cardContentChildren}+ </CardContent>+ </CardHeader>+ </div>+ </Card>+ </div>+ </div>+ </div>+ </div>+ );+};++export default function QueueItems() {+ const router = useRouter();+ const projectId = router.query.projectId as string;+ const queueId = router.query.queueId as string;++ const queue = api.annotationQueues.byId.useQuery({+ queueId,+ projectId,+ });++ const hasReadAccess = useHasProjectAccess({+ projectId,+ scope: "annotationQueues:read",+ });+ const hasWriteAccess = useHasProjectAccess({+ projectId,+ scope: "annotationQueues:CUD",+ });+ const hasEntitlement = useHasOrgEntitlement("annotation-queues");+ if (!hasReadAccess || !hasEntitlement) return <SupportOrUpgradePage />;++ return (+ <FullScreenPage>+ <>+ <Header+ title={queue.data?.name ?? queueId}+ breadcrumb={[+ {+ name: "Annotation Queues",+ href: `/project/${projectId}/annotation-queues`,+ },+ { name: queue.data?.name ?? queueId },+ ]}+ actionButtons={+ !hasWriteAccess ? (+ <Button disabled>+ <Lock className="mr-1 h-4 w-4" />+ <span className="text-sm">Process queue</span>+ </Button>+ ) : (+ <Button asChild>+ <Link+ href={`/project/${projectId}/annotation-queues/${queueId}/items`}+ >+ <ClipboardPen className="mr-1 h-4 w-4" />+ <span className="text-sm">Process queue</span>+ </Link>+ </Button>+ )+ }+ />+ <TableWithMetadataWrapper+ tableComponent={+ <AnnotationQueueItemsTable+ projectId={projectId}+ queueId={queueId}+ />+ }+ cardTitleChildren={+ <div className="flex w-full flex-row items-center justify-between">+ {queue.data ? (+ <span>{queue.data.name}</span>+ ) : (+ <Skeleton className="h-full w-1/2" />+ )}+ <CreateOrEditAnnotationQueueButton+ projectId={projectId}+ queueId={queueId}+ />+ </div>+ }+ cardContentChildren={+ <>+ {queue.data?.description && (+ <CardDescription className="text-sm">+ {queue.data?.description}+ </CardDescription>+ )}+ <Separator orientation="horizontal" />+ <h5 className="text-md font-bold leading-7 sm:tracking-tight">+ Score Configs+ </h5>+ {queue.data?.scoreConfigs.map((scoreConfig) => (+ <Badge key={scoreConfig.id} className="mr-2" variant="outline">+ {getScoreDataTypeIcon(scoreConfig.dataType)}+ <span className="ml-0.5">{scoreConfig.name}</span>+ </Badge>+ ))}+ </>+ }+ />+ </>+ </FullScreenPage>+ );+}diff --git a/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx b/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsxnew file mode 100644index 0000000000..707c290d7a--- /dev/null+++ b/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx@@ -0,0 +1,34 @@+import Header from "@/src/components/layouts/header";+import { useRouter } from "next/router";+import { FullScreenPage } from "@/src/components/layouts/full-screen-page";+import { AnnotationQueuesTable } from "@/src/ee/features/annotation-queues/components/AnnotationQueuesTable";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";++export default function AnnotationQueues() {+ const router = useRouter();+ const projectId = router.query.projectId as string;+ const hasAccess = useHasProjectAccess({+ projectId: projectId,+ scope: "annotationQueues:read",+ });+ const hasEntitlement = useHasOrgEntitlement("annotation-queues");+ if (!hasAccess || !hasEntitlement) return <SupportOrUpgradePage />;++ return (+ <FullScreenPage>+ <>+ <Header+ title="Annotation Queues"+ help={{+ description:+ "Annotation queues are used to manage scoring workflows for your LLM projects. See docs to learn more.",+ href: "https://langfuse.com/docs/scores/annotation",+ }}+ />+ <AnnotationQueuesTable projectId={projectId} />+ </>+ </FullScreenPage>+ );+}diff --git a/web/src/server/api/routers/annotationQueueItems.ts b/web/src/ee/features/annotation-queues/server/annotationQueueItems.tssimilarity index 100%rename from web/src/server/api/routers/annotationQueueItems.tsrename to web/src/ee/features/annotation-queues/server/annotationQueueItems.tsdiff --git a/web/src/server/api/routers/annotationQueues.ts b/web/src/ee/features/annotation-queues/server/annotationQueues.tssimilarity index 92%rename from web/src/server/api/routers/annotationQueues.tsrename to web/src/ee/features/annotation-queues/server/annotationQueues.tsindex bb7f931446..407b578e20 100644--- a/web/src/server/api/routers/annotationQueues.ts+++ b/web/src/ee/features/annotation-queues/server/annotationQueues.ts@@ -146,6 +146,24 @@ export const queueRouter = createTRPCRouter({});}}),+ count: protectedProjectProcedure+ .input(z.object({ projectId: z.string() }))+ .query(async ({ input, ctx }) => {+ try {+ return ctx.prisma.annotationQueue.count({+ where: { projectId: input.projectId },+ });+ } catch (error) {+ logger.error(error);+ if (error instanceof TRPCError) {+ throw error;+ }+ throw new TRPCError({+ code: "INTERNAL_SERVER_ERROR",+ message: "Fetching annotation queue count failed.",+ });+ }+ }),byId: protectedProjectProcedure.input(z.object({ queueId: z.string(), projectId: z.string() })).query(async ({ input, ctx }) => {@@ -281,6 +299,28 @@ export const queueRouter = createTRPCRouter({scope: "annotationQueues:CUD",});+ // gate usage on cloud:hobby+ const org = ctx.session.user.organizations.find((org) =>+ org.projects.some((proj) => proj.id === input.projectId),+ );+ const plan = org?.plan ?? "oss";++ if (plan === "cloud:hobby") {+ if (+ (await ctx.prisma.annotationQueue.count({+ where: {+ projectId: input.projectId,+ },+ })) >= 1+ ) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message:+ "Maximum number of annotation queues reached on Hobby plan.",+ });+ }+ }+const existingQueue = await ctx.prisma.annotationQueue.findFirst({where: {projectId: input.projectId,diff --git a/web/src/features/entitlements/constants/entitlements.ts b/web/src/features/entitlements/constants/entitlements.tsindex c889beabf8..689a058e12 100644--- a/web/src/features/entitlements/constants/entitlements.ts+++ b/web/src/features/entitlements/constants/entitlements.ts@@ -19,19 +19,16 @@ const cloudAllPlansEntitlements: Entitlement[] = ["cloud-billing","integration-posthog","batch-export",+ "annotation-queues",];export const entitlementAccess: Record<Plan, Entitlement[]> = {oss: [],"cloud:hobby": [...cloudAllPlansEntitlements],- "cloud:pro": [...cloudAllPlansEntitlements, "annotation-queues"],- "cloud:team": [- ...cloudAllPlansEntitlements,- "rbac-project-roles",- "annotation-queues",- ],+ "cloud:pro": [...cloudAllPlansEntitlements],+ "cloud:team": [...cloudAllPlansEntitlements, "rbac-project-roles"],"self-hosted:enterprise": [- // "annotation-queues", // TODO: include for non-beta release+ "annotation-queues","playground","rbac-project-roles",// `LANGFUSE_ALLOWED_ORGANIZATION_CREATORS` -> directly checked on instance level in auth.tsdiff --git a/web/src/features/feature-flags/available-flags.ts b/web/src/features/feature-flags/available-flags.tsindex 145b748eb8..276ffb57fe 100644--- a/web/src/features/feature-flags/available-flags.ts+++ b/web/src/features/feature-flags/available-flags.ts@@ -1 +1 @@-export const availableFlags = ["templateFlag", "annotationQueues"] as const;+export const availableFlags = ["templateFlag"] as const;diff --git a/web/src/features/scores/components/AnnotationQueuesItem.tsx b/web/src/features/scores/components/AnnotationQueuesItem.tsxdeleted file mode 100644index 66781dc633..0000000000--- a/web/src/features/scores/components/AnnotationQueuesItem.tsx+++ /dev/null@@ -1,99 +0,0 @@-import { FullScreenPage } from "@/src/components/layouts/full-screen-page";-import Header from "@/src/components/layouts/header";-import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";-import useSessionStorage from "@/src/components/useSessionStorage";-import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";-import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";-import { FeatureFlagToggle } from "@/src/features/feature-flags/components/FeatureFlagToggle";-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { AnnotationQueueItemPage } from "@/src/features/scores/components/AnnotationQueueItemPage";-import { api } from "@/src/utils/api";-import { Goal, Network } from "lucide-react";--export const AnnotationQueuesItem = ({- annotationQueueId,- projectId,- itemId,-}: {- annotationQueueId: string;- projectId: string;- itemId?: string;-}) => {- const hasAccess = useHasProjectAccess({- projectId,- scope: "annotationQueues:read",- });- const hasEntitlement = useHasOrgEntitlement("annotation-queues");-- const queue = api.annotationQueues.byId.useQuery(- {- queueId: annotationQueueId,- projectId,- },- {- trpc: {- context: {- skipBatch: true,- },- },- refetchOnMount: false, // prevents refetching loops- },- );-- const [view, setView] = useSessionStorage<"hideTree" | "showTree">(- `annotationQueueView-${projectId}`,- "hideTree",- );-- if (!hasAccess || !hasEntitlement) return <SupportOrUpgradePage />;-- return (- <FullScreenPage>- <FeatureFlagToggle- featureFlag="annotationQueues"- whenEnabled={- <>- <Header- title={`${queue.data?.name ?? annotationQueueId}`}- breadcrumb={[- {- name: "Annotation Queues",- href: `/project/${projectId}/annotation-queues`,- },- {- name: queue.data?.name ?? annotationQueueId,- href: `/project/${projectId}/annotation-queues/${annotationQueueId}`,- },- ]}- actionButtons={- <Tabs- value={view}- onValueChange={(view: string) => {- setView(view as "hideTree" | "showTree");- }}- >- <TabsList>- <TabsTrigger value="hideTree">- <Goal className="mr-1 h-4 w-4"></Goal>- Focused- </TabsTrigger>- <TabsTrigger value="showTree">- <Network className="mr-1 h-4 w-4"></Network>- Detailed- </TabsTrigger>- </TabsList>- </Tabs>- }- />- <AnnotationQueueItemPage- projectId={projectId}- annotationQueueId={annotationQueueId}- view={view}- queryItemId={itemId}- />- </>- }- />- </FullScreenPage>- );-};diff --git a/web/src/pages/project/[projectId]/annotation-queues.tsx b/web/src/pages/project/[projectId]/annotation-queues.tsxindex fef21aaa5c..1187d4efb7 100644--- a/web/src/pages/project/[projectId]/annotation-queues.tsx+++ b/web/src/pages/project/[projectId]/annotation-queues.tsx@@ -1,40 +1,3 @@-import Header from "@/src/components/layouts/header";-import { useRouter } from "next/router";-import { FullScreenPage } from "@/src/components/layouts/full-screen-page";-import { AnnotationQueuesTable } from "@/src/features/scores/components/AnnotationQueuesTable";-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";-import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";-import { FeatureFlagToggle } from "@/src/features/feature-flags/components/FeatureFlagToggle";+import AnnotationQueues from "@/src/ee/features/annotation-queues/pages/AnnotationQueues";-export default function AnnotationQueues() {- const router = useRouter();- const projectId = router.query.projectId as string;- const hasAccess = useHasProjectAccess({- projectId: projectId,- scope: "annotationQueues:read",- });- const hasEntitlement = useHasOrgEntitlement("annotation-queues");- if (!hasAccess || !hasEntitlement) return <SupportOrUpgradePage />;-- return (- <FullScreenPage>- <FeatureFlagToggle- featureFlag="annotationQueues"- whenEnabled={- <>- <Header- title="Annotation Queues"- help={{- description:- "Annotation queues are used to manage scoring workflows for your LLM projects. See docs to learn more.",- href: "https://langfuse.com/docs/scores/annotation",- }}- />- <AnnotationQueuesTable projectId={projectId} />- </>- }- />- </FullScreenPage>- );-}+export default AnnotationQueues;diff --git a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/index.tsx b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/index.tsxindex 41b9546d57..6baac370ac 100644--- a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/index.tsx+++ b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/index.tsx@@ -1,186 +1,3 @@-import Header from "@/src/components/layouts/header";-import { api } from "@/src/utils/api";-import { useRouter } from "next/router";-import { FullScreenPage } from "@/src/components/layouts/full-screen-page";-import { AnnotationQueueItemsTable } from "@/src/features/scores/components/AnnotationQueueItemsTable";-import {- Card,- CardContent,- CardDescription,- CardHeader,- CardTitle,-} from "@/src/components/ui/card";-import { Button } from "@/src/components/ui/button";-import { ChevronRight, ClipboardPen, Lock } from "lucide-react";-import { Separator } from "@/src/components/ui/separator";-import { useState } from "react";-import { Badge } from "@/src/components/ui/badge";-import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";-import Link from "next/link";-import { CreateOrEditAnnotationQueueButton } from "@/src/features/scores/components/CreateOrEditAnnotationQueueButton";-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";-import { useHasOrgEntitlement } from "@/src/features/entitlements/hooks";-import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";-import { FeatureFlagToggle } from "@/src/features/feature-flags/components/FeatureFlagToggle";-import { Skeleton } from "@/src/components/ui/skeleton";+import QueueItems from "@/src/ee/features/annotation-queues/pages/AnnotationQueueItems";-const TableWithMetadataWrapper = ({- tableComponent,- cardTitleChildren,- cardContentChildren,-}: {- tableComponent: React.ReactNode;- cardTitleChildren: React.ReactNode;- cardContentChildren: React.ReactNode;-}) => {- const [isCollapsed, setIsCollapsed] = useState(false);-- return (- <div- className={`grid h-[calc(100dvh-8rem)] ${isCollapsed ? "grid-cols-[2fr,auto]" : "grid-cols-[2fr,1fr]"} gap-4 overflow-hidden lg:h-[calc(100dvh-4rem)]`}- >- <div className="flex h-full flex-col overflow-hidden">- {tableComponent}- </div>- <div- className={`my-2 flex flex-row ${isCollapsed ? "w-8" : "w-full"} h-full overflow-hidden`}- >- <div className="grid h-full w-full grid-cols-[auto,1fr] items-start gap-2 overflow-hidden">- <div className="grid h-full w-full grid-rows-[auto,1fr] gap-2">- <Button- variant="outline"- size="icon"- onClick={() => setIsCollapsed(!isCollapsed)}- >- <ChevronRight- className={`h-4 w-4 transform ${isCollapsed ? "rotate-180" : ""}`}- />- </Button>- <Separator orientation="vertical" className="ml-4 h-full" />- </div>- <div- className={`${isCollapsed ? "hidden" : "block"} mt-8 grid h-[calc(100%-2rem)] w-full grid-rows-[auto,1fr] gap-2 overflow-hidden p-2`}- >- <Card className="flex h-full flex-col overflow-hidden">- <div className="flex h-full overflow-y-auto">- <CardHeader className="flex h-full w-full flex-col space-y-4">- <CardTitle className="flex justify-between text-xl font-bold leading-7 sm:tracking-tight">- {cardTitleChildren}- </CardTitle>- <CardContent className="flex-1 space-y-4 p-0">- {cardContentChildren}- </CardContent>- </CardHeader>- </div>- </Card>- </div>- </div>- </div>- </div>- );-};--export default function QueueItems() {- const router = useRouter();- const projectId = router.query.projectId as string;- const queueId = router.query.queueId as string;-- const queue = api.annotationQueues.byId.useQuery({- queueId,- projectId,- });-- const hasReadAccess = useHasProjectAccess({- projectId,- scope: "annotationQueues:read",- });- const hasWriteAccess = useHasProjectAccess({- projectId,- scope: "annotationQueues:CUD",- });- const hasEntitlement = useHasOrgEntitlement("annotation-queues");- if (!hasReadAccess || !hasEntitlement) return <SupportOrUpgradePage />;-- return (- <FullScreenPage>- <FeatureFlagToggle- featureFlag="annotationQueues"- whenEnabled={- <>- <Header- title={queue.data?.name ?? queueId}- breadcrumb={[- {- name: "Annotation Queues",- href: `/project/${projectId}/annotation-queues`,- },- { name: queue.data?.name ?? queueId },- ]}- actionButtons={- !hasWriteAccess ? (- <Button disabled>- <Lock className="mr-1 h-4 w-4" />- <span className="text-sm">Process queue</span>- </Button>- ) : (- <Button asChild>- <Link- href={`/project/${projectId}/annotation-queues/${queueId}/items`}- >- <ClipboardPen className="mr-1 h-4 w-4" />- <span className="text-sm">Process queue</span>- </Link>- </Button>- )- }- />- <TableWithMetadataWrapper- tableComponent={- <AnnotationQueueItemsTable- projectId={projectId}- queueId={queueId}- />- }- cardTitleChildren={- <div className="flex w-full flex-row items-center justify-between">- {queue.data ? (- <span>{queue.data.name}</span>- ) : (- <Skeleton className="h-full w-1/2" />- )}- <CreateOrEditAnnotationQueueButton- projectId={projectId}- queueId={queueId}- />- </div>- }- cardContentChildren={- <>- {queue.data?.description && (- <CardDescription className="text-sm">- {queue.data?.description}- </CardDescription>- )}- <Separator orientation="horizontal" />- <h5 className="text-md font-bold leading-7 sm:tracking-tight">- Score Configs- </h5>- {queue.data?.scoreConfigs.map((scoreConfig) => (- <Badge- key={scoreConfig.id}- className="mr-2"- variant="outline"- >- {getScoreDataTypeIcon(scoreConfig.dataType)}- <span className="ml-0.5">{scoreConfig.name}</span>- </Badge>- ))}- </>- }- />- </>- }- />- </FullScreenPage>- );-}+export default QueueItems;diff --git a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/[itemId].tsx b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/[itemId].tsxindex a0a25679ac..57ed291f17 100644--- a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/[itemId].tsx+++ b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/[itemId].tsx@@ -1,4 +1,4 @@-import { AnnotationQueuesItem } from "@/src/features/scores/components/AnnotationQueuesItem";+import { AnnotationQueuesItem } from "@/src/ee/features/annotation-queues/components/AnnotationQueuesItem";import { useRouter } from "next/router";export default function AnnotationQueues() {diff --git a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/index.tsx b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/index.tsxindex 96b1164cf5..aea9b56b10 100644--- a/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/index.tsx+++ b/web/src/pages/project/[projectId]/annotation-queues/[queueId]/items/index.tsx@@ -1,4 +1,4 @@-import { AnnotationQueuesItem } from "@/src/features/scores/components/AnnotationQueuesItem";+import { AnnotationQueuesItem } from "@/src/ee/features/annotation-queues/components/AnnotationQueuesItem";import { useRouter } from "next/router";export default function AnnotationQueues() {diff --git a/web/src/server/api/root.ts b/web/src/server/api/root.tsindex 6052dd3129..016917d464 100644--- a/web/src/server/api/root.ts+++ b/web/src/server/api/root.ts@@ -24,8 +24,8 @@ import { batchExportRouter } from "@/src/server/api/routers/batchExport";import { utilsRouter } from "@/src/server/api/routers/utilities";import { uiCustomizationRouter } from "@/src/ee/features/ui-customization/uiCustomizationRouter";import { commentsRouter } from "@/src/server/api/routers/comments";-import { queueRouter } from "@/src/server/api/routers/annotationQueues";-import { queueItemRouter } from "@/src/server/api/routers/annotationQueueItems";+import { queueRouter } from "@/src/ee/features/annotation-queues/server/annotationQueues";+import { queueItemRouter } from "@/src/ee/features/annotation-queues/server/annotationQueueItems";/*** This is the primary router for your server.