🪢 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
style: adjust prompt icons, move edit/new version to action button, and always show prompt controls for current version (#3701)
marliessophie3129baa2c60d
diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsxindex bde6386bf2..445d08eb96 100644--- a/web/src/components/layouts/routes.tsx+++ b/web/src/components/layouts/routes.tsx@@ -8,13 +8,13 @@ import {type LucideIcon,Settings,UsersIcon,- PenSquareIcon,LibraryBig,TerminalIcon,Lightbulb,Grid2X2,Sparkle,ClipboardPen,+ FileJson,} from "lucide-react";import { LangfuseIcon } from "@/src/components/LangfuseLogo";import { type ReactNode } from "react";@@ -130,7 +130,7 @@ export const ROUTES: Route[] = [{name: "Prompts",pathname: "/project/[projectId]/prompts",- icon: PenSquareIcon,+ icon: FileJson,projectRbacScope: "prompts:read",},{diff --git a/web/src/ee/features/playground/page/components/JumpToPlaygroundButton.tsx b/web/src/ee/features/playground/page/components/JumpToPlaygroundButton.tsxindex 1cd0794737..5753ae77bd 100644--- a/web/src/ee/features/playground/page/components/JumpToPlaygroundButton.tsx+++ b/web/src/ee/features/playground/page/components/JumpToPlaygroundButton.tsx@@ -62,13 +62,16 @@ export const JumpToPlaygroundButton: React.FC<JumpToPlaygroundButtonProps> = (return (<Buttonvariant={props.variant ?? "secondary"}+ size={props.source === "prompt" ? "icon" : "default"}title="Test in LLM playground"onClick={handleClick}asChild><Link href={`/project/${projectId}/playground`}><Terminal className="h-4 w-4" />- <span className="ml-2">Test in playground</span>+ {props.source === "generation" && (+ <span className="ml-2">Test in playground</span>+ )}</Link></Button>);diff --git a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsxindex 10ad1e138a..0ce71a8200 100644--- a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx+++ b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx@@ -107,92 +107,98 @@ export function SetPromptVersionLabels({aria-label="Set prompt labels"title="Set prompt labels"disabled={!hasAccess}+ onClick={(event) => {+ event.stopPropagation();+ }}><TagIcon className="h-4 w-4" /></Button></PopoverTrigger><PopoverContent>- <h2 className="text-md mb-3 font-semibold">Prompt version labels</h2>- <h2 className="mb-3 text-xs">- Use labels to fetch prompts via SDKs. The <strong>production</strong>{" "}- labeled prompt will be served by default.- </h2>- <Command className="mx-0 my-3 px-0">- <CommandList className="max-h-full overflow-hidden">- <CommandSeparator />- <CommandGroup heading="Promote to production?">- <LabelCommandItem- {...{- selectedLabels,- setSelectedLabels,- label: PRODUCTION_LABEL,- }}- />- </CommandGroup>- <CommandSeparator />- <CommandGroup heading="Custom labels">- <div- className="max-h-[300px] overflow-y-auto overflow-x-hidden"- ref={customLabelScrollRef}- >- {labels- .filter((l) => !isReservedPromptLabel(l))- .map((label) => (- <LabelCommandItem- key={label}- {...{ selectedLabels, setSelectedLabels, label }}- />- ))}- </div>- </CommandGroup>- </CommandList>- <div className="px-1">- {isAddingLabel ? (- <AddLabelForm- {...{- setLabels,- setSelectedLabels,- onAddLabel: () => {- setTimeout(- () =>- customLabelScrollRef.current?.scrollTo({- top: customLabelScrollRef.current?.scrollHeight,- behavior: "smooth",- }),- 0,- );- },- }}- />- ) : (- <Button- variant="ghost"- className="mt-2 w-full justify-start px-2 py-1 text-sm font-normal"- onClick={() => setIsAddingLabel(true)}- >- <PlusIcon className="mr-2 h-4 w-4" />- Add custom label- </Button>- )}- </div>- </Command>- <Button- type="button"- variant={- isPromotingToProduction || isDemotingFromProduction- ? "destructive"- : "default"- }- loading={mutatePromptVersionLabels.isLoading}- className="w-full"- onClick={handleSubmitLabels}- >- {isPromotingToProduction- ? "Save and promote to production"- : isDemotingFromProduction- ? "Save and remove from production"- : "Save"}- </Button>+ <div onClick={(event) => event.stopPropagation()}>+ <h2 className="text-md mb-3 font-semibold">Prompt version labels</h2>+ <h2 className="mb-3 text-xs">+ Use labels to fetch prompts via SDKs. The{" "}+ <strong>production</strong> labeled prompt will be served by+ default.+ </h2>+ <Command className="mx-0 my-3 px-0">+ <CommandList className="max-h-full overflow-hidden">+ <CommandSeparator />+ <CommandGroup heading="Promote to production?">+ <LabelCommandItem+ {...{+ selectedLabels,+ setSelectedLabels,+ label: PRODUCTION_LABEL,+ }}+ />+ </CommandGroup>+ <CommandSeparator />+ <CommandGroup heading="Custom labels">+ <div+ className="max-h-[300px] overflow-y-auto overflow-x-hidden"+ ref={customLabelScrollRef}+ >+ {labels+ .filter((l) => !isReservedPromptLabel(l))+ .map((label) => (+ <LabelCommandItem+ key={label}+ {...{ selectedLabels, setSelectedLabels, label }}+ />+ ))}+ </div>+ </CommandGroup>+ </CommandList>+ <div className="px-1">+ {isAddingLabel ? (+ <AddLabelForm+ {...{+ setLabels,+ setSelectedLabels,+ onAddLabel: () => {+ setTimeout(+ () =>+ customLabelScrollRef.current?.scrollTo({+ top: customLabelScrollRef.current?.scrollHeight,+ behavior: "smooth",+ }),+ 0,+ );+ },+ }}+ />+ ) : (+ <Button+ variant="ghost"+ className="mt-2 w-full justify-start px-2 py-1 text-sm font-normal"+ onClick={() => setIsAddingLabel(true)}+ >+ <PlusIcon className="mr-2 h-4 w-4" />+ Add custom label+ </Button>+ )}+ </div>+ </Command>+ <Button+ type="button"+ variant={+ isPromotingToProduction || isDemotingFromProduction+ ? "destructive"+ : "default"+ }+ loading={mutatePromptVersionLabels.isLoading}+ className="w-full"+ onClick={handleSubmitLabels}+ >+ {isPromotingToProduction+ ? "Save and promote to production"+ : isDemotingFromProduction+ ? "Save and remove from production"+ : "Save"}+ </Button>+ </div></PopoverContent></Popover>);diff --git a/web/src/features/prompts/components/delete-prompt-version.tsx b/web/src/features/prompts/components/delete-prompt-version.tsxindex c0fbb5d111..e9f6a1d621 100644--- a/web/src/features/prompts/components/delete-prompt-version.tsx+++ b/web/src/features/prompts/components/delete-prompt-version.tsx@@ -64,6 +64,9 @@ export function DeletePromptVersion({size="icon"className="h-7 w-7 px-0"disabled={!hasAccess}+ onClick={(event) => {+ event.stopPropagation();+ }}><Trash className="h-4 w-4" /></Button>diff --git a/web/src/features/prompts/components/prompt-detail.tsx b/web/src/features/prompts/components/prompt-detail.tsxindex 26a35589ad..36fd390413 100644--- a/web/src/features/prompts/components/prompt-detail.tsx+++ b/web/src/features/prompts/components/prompt-detail.tsx@@ -25,14 +25,23 @@ import {import { JumpToPlaygroundButton } from "@/src/ee/features/playground/page/components/JumpToPlaygroundButton";import { ChatMlArraySchema } from "@/src/components/schemas/ChatMlSchema";import { CommentList } from "@/src/features/comments/CommentList";+import { Lock, Plus } from "lucide-react";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { Button } from "@/src/components/ui/button";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export const PromptDetail = () => {const projectId = useProjectIdFromURL();+ const capture = usePostHogClientCapture();const promptName = decodeURIComponent(useRouter().query.promptName as string);const [currentPromptVersion, setCurrentPromptVersion] = useQueryParam("version",NumberParam,);+ const hasAccess = useHasProjectAccess({+ projectId,+ scope: "prompts:CUD",+ });const promptHistory = api.prompts.allVersions.useQuery({name: promptName,@@ -49,7 +58,7 @@ export const PromptDetail = () => {const extractedVariables = prompt? extractVariables(prompt?.type === PromptType.Text- ? prompt.prompt?.toString() ?? ""+ ? (prompt.prompt?.toString() ?? ""): JSON.stringify(prompt.prompt),): [];@@ -105,6 +114,30 @@ export const PromptDetail = () => {]}actionButtons={<>+ {hasAccess ? (+ <Button+ variant="outline"+ onClick={() => {+ capture("prompts:update_form_open");+ }}+ >+ <Link+ href={`/project/${projectId}/prompts/new?promptId=${encodeURIComponent(prompt.id)}`}+ >+ <div className="flex flex-row items-center">+ <Plus className="h-4 w-4" />+ <span className="ml-2">New version</span>+ </div>+ </Link>+ </Button>+ ) : (+ <Button variant="outline" disabled>+ <div className="flex flex-row items-center">+ <Lock className="h-3 w-3" />+ <span className="ml-2">New version</span>+ </div>+ </Button>+ )}<JumpToPlaygroundButtonsource="prompt"prompt={prompt}diff --git a/web/src/features/prompts/components/prompt-history.tsx b/web/src/features/prompts/components/prompt-history.tsxindex d6376d4deb..07ddb880d9 100644--- a/web/src/features/prompts/components/prompt-history.tsx+++ b/web/src/features/prompts/components/prompt-history.tsx@@ -1,13 +1,8 @@import { StatusBadge } from "@/src/components/layouts/status-badge";-import { Button } from "@/src/components/ui/button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { DeletePromptVersion } from "@/src/features/prompts/components/delete-prompt-version";import { SetPromptVersionLabels } from "@/src/features/prompts/components/SetPromptVersionLabels";import { PRODUCTION_LABEL } from "@/src/features/prompts/constants";-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type RouterOutputs } from "@/src/utils/api";-import { Pencil, PencilOff } from "lucide-react";-import Link from "next/link";import { type NextRouter, useRouter } from "next/router";import { useState } from "react";@@ -20,13 +15,8 @@ const PromptHistoryTraceNode = (props: {projectId: string;totalCount: number;}) => {- const capture = usePostHogClientCapture();const [isHovered, setIsHovered] = useState(false);const [isLabelPopoverOpen, setIsLabelPopoverOpen] = useState(false);- const hasAccess = useHasProjectAccess({- projectId: props.projectId,- scope: "prompts:CUD",- });const { prompt } = props;let badges: JSX.Element[] = prompt.labels.sort((a, b) =>@@ -80,7 +70,7 @@ const PromptHistoryTraceNode = (props: {</span></div></div>- {isHovered && (+ {(isHovered || props.currentPromptVersion === prompt.version) && (<div className="flex flex-row justify-end space-x-1"><SetPromptVersionLabelsprompt={prompt}@@ -90,31 +80,6 @@ const PromptHistoryTraceNode = (props: {if (!open) setIsHovered(false);}}/>- {hasAccess ? (- <Button- variant="outline"- size="icon"- className="h-7 w-7 px-0"- onClick={() => {- capture("prompts:update_form_open");- }}- >- <Link- href={`/project/${props.projectId}/prompts/new?promptId=${encodeURIComponent(prompt.id)}`}- >- <Pencil className="h-4 w-4" />- </Link>- </Button>- ) : (- <Button- variant="outline"- size="icon"- className="h-7 w-7 px-0"- disabled- >- <PencilOff className="h-4 w-4" />- </Button>- )}<DeletePromptVersionpromptVersionId={prompt.id}version={prompt.version}diff --git a/web/src/features/prompts/components/prompts-table.tsx b/web/src/features/prompts/components/prompts-table.tsxindex 1132a050cf..a15abba467 100644--- a/web/src/features/prompts/components/prompts-table.tsx+++ b/web/src/features/prompts/components/prompts-table.tsx@@ -256,7 +256,10 @@ export function PromptTable() {}}>{hasCUDAccess ? (- <PlusIcon className="-ml-0.5 mr-1.5" aria-hidden="true" />+ <PlusIcon+ className="-ml-0.5 mr-1.5 h-4 w-4"+ aria-hidden="true"+ />) : (<LockIconclassName="-ml-0.5 mr-1.5 h-3 w-3"