Skip to content

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

feat(ui): ui improvements of prompt mgmt (#784)

Marc Klingen2d8a239d6df1
diff --git a/src/components/layouts/header.tsx b/src/components/layouts/header.tsx
index ef64bc351a..8e554b4939 100644
--- a/src/components/layouts/header.tsx
+++ b/src/components/layouts/header.tsx
@@ -3,12 +3,12 @@ import Link from "next/link";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import DocPopup from "@/src/components/layouts/doc-popup";
-import { StatusBadge } from "./live-badge";
+import { type Status, StatusBadge } from "./status-badge";
export default function Header(props: {
title: string;
breadcrumb?: { name: string; href?: string }[];
- live?: boolean;
+ status?: Status;
help?: { description: string; href: string };
actionButtons?: React.ReactNode;
}) {
@@ -96,7 +96,7 @@ export default function Header(props: {
/>
) : null}
</div>
- {props.live ? <StatusBadge type="live" /> : null}
+ {props.status && <StatusBadge type={props.status} />}
</div>
<div className="flex items-center gap-3">
{props.actionButtons ?? null}
diff --git a/src/components/layouts/routes.ts b/src/components/layouts/routes.ts
index b16445e0ba..d05569d027 100644
--- a/src/components/layouts/routes.ts
+++ b/src/components/layouts/routes.ts
@@ -54,7 +54,7 @@ export const ROUTES: Array<{
name: "Prompts",
pathname: "/project/[projectId]/prompts",
icon: PenSquareIcon,
- featureFlag: "promptFlag",
+ label: "Beta",
},
{
name: "Datasets",
diff --git a/src/components/layouts/live-badge.tsx b/src/components/layouts/status-badge.tsx
similarity index 50%
rename from src/components/layouts/live-badge.tsx
rename to src/components/layouts/status-badge.tsx
index de24244995..7c9b4c4ab8 100644
--- a/src/components/layouts/live-badge.tsx
+++ b/src/components/layouts/status-badge.tsx
@@ -1,15 +1,19 @@
import { cn } from "@/src/utils/tailwind";
-export const StatusBadge = (props: {
- className?: string;
+const statusCategories = {
+ active: ["production", "live"],
+ inactive: ["disabled", "inactive"],
+};
+
+export type Status =
+ (typeof statusCategories)[keyof typeof statusCategories][number];
- type: "live" | "disabled";
-}) => {
+export const StatusBadge = (props: { className?: string; type: Status }) => {
return (
<div
className={cn(
"flex items-center gap-2 rounded-sm px-3",
- props.type === "live"
+ statusCategories.active.includes(props.type)
? " bg-green-100 text-green-600"
: "bg-gray-100 text-gray-800",
props.className,
@@ -19,17 +23,21 @@ export const StatusBadge = (props: {
<span
className={cn(
"absolute inline-flex h-full w-full rounded-full opacity-75",
- props.type === "live" ? "animate-ping bg-green-500" : "bg-gray-500",
+ statusCategories.active.includes(props.type)
+ ? "animate-ping bg-green-500"
+ : "bg-gray-500",
)}
></span>
<span
className={cn(
"relative inline-flex h-2 w-2 rounded-full ",
- props.type === "live" ? "bg-green-600" : "bg-gray-600",
+ statusCategories.active.includes(props.type)
+ ? "bg-green-600"
+ : "bg-gray-600",
)}
></span>
</span>
- {props.type === "live" ? "Live" : "Disabled"}
+ {props.type}
</div>
);
};
diff --git a/src/features/feature-flags/available-flags.ts b/src/features/feature-flags/available-flags.ts
index d8b1d52ecd..276ffb57fe 100644
--- a/src/features/feature-flags/available-flags.ts
+++ b/src/features/feature-flags/available-flags.ts
@@ -1 +1 @@
-export const availableFlags = ["templateFlag", "promptFlag"] as const;
+export const availableFlags = ["templateFlag"] as const;
diff --git a/src/features/prompts/components/promote-prompt.tsx b/src/features/prompts/components/promote-prompt.tsx
index 22bf410bc9..eee70558d4 100644
--- a/src/features/prompts/components/promote-prompt.tsx
+++ b/src/features/prompts/components/promote-prompt.tsx
@@ -48,12 +48,12 @@ export function PromotePrompt({
<PopoverContent>
<h2 className="text-md mb-3 font-semibold">Please confirm</h2>
<p className="mb-3 text-sm">
- This action cannot be undone and promotes the prompt to production.
- SDKs requesting a prompt with name{" "}
+ This action promotes the prompt to production. SDKs requesting a
+ prompt with name{" "}
<code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold">
{promptName}
</code>
- , will receive this prompt once confirmed.
+ will receive this prompt. Make sure that the variables match.
</p>
<div className="flex justify-end space-x-4">
<Button
@@ -68,7 +68,7 @@ export function PromotePrompt({
posthog.capture("prompt:promote");
}}
>
- Promote Prompt
+ Promote to production
</Button>
</div>
</PopoverContent>
diff --git a/src/features/prompts/components/prompt-detail.tsx b/src/features/prompts/components/prompt-detail.tsx
index 24a5f9ab4a..5443663a77 100644
--- a/src/features/prompts/components/prompt-detail.tsx
+++ b/src/features/prompts/components/prompt-detail.tsx
@@ -25,21 +25,21 @@ export const PromptDetail = (props: PromptDetailProps) => {
? extractVariables(prompt.data.prompt)
: [];
+ if (!prompt.data) {
+ return <div>Loading...</div>;
+ }
+
return (
<div className="flex flex-col overflow-hidden xl:container md:h-[calc(100vh-100px)] xl:h-[calc(100vh-40px)]">
<Header
- title={
- prompt.data
- ? prompt.data.name + " - " + prompt.data.version
- : "Loading"
- }
- live={prompt.data?.isActive}
+ title={`${prompt.data.name} (v${prompt.data.version})`}
+ status={prompt.data.isActive ? "production" : "disabled"}
breadcrumb={[
{
name: "Prompts",
href: `/project/${props.projectId}/prompts/`,
},
- { name: props.promptId },
+ { name: `${prompt.data.name} (v${prompt.data.version})` },
]}
actionButtons={
<>
@@ -47,8 +47,8 @@ export const PromptDetail = (props: PromptDetailProps) => {
projectId={props.projectId}
title="Update Prompt"
subtitle="We do not update prompts, instead we create a new version of the prompt."
- promptName={prompt.data?.name}
- promptText={prompt.data?.prompt}
+ promptName={prompt.data.name}
+ promptText={prompt.data.prompt}
>
<Button variant="outline" size="icon">
<Pencil className="h-5 w-5" />
@@ -68,9 +68,7 @@ export const PromptDetail = (props: PromptDetailProps) => {
<div className="mx-auto w-full rounded-lg border text-base leading-7 text-gray-700">
<div className="border-b px-3 py-1 text-xs font-medium">Prompt</div>
- <p className="p-3 text-sm leading-8">
- {prompt.data?.prompt ?? "Loading"}
- </p>
+ <p className="p-3 text-sm leading-8">{prompt.data.prompt}</p>
</div>
<div className="mx-auto mt-10 w-full rounded-lg border text-base leading-7 text-gray-700">
<div className="border-b px-3 py-1 text-xs font-medium">Variables</div>
diff --git a/src/features/prompts/components/prompts-table.tsx b/src/features/prompts/components/prompts-table.tsx
index 31fed3a637..5174634367 100644
--- a/src/features/prompts/components/prompts-table.tsx
+++ b/src/features/prompts/components/prompts-table.tsx
@@ -1,4 +1,4 @@
-import { StatusBadge } from "@/src/components/layouts/live-badge";
+import { StatusBadge } from "@/src/components/layouts/status-badge";
import { DataTable } from "@/src/components/table/data-table";
import TableLink from "@/src/components/table/table-link";
import { type LangfuseColumnDef } from "@/src/components/table/types";
@@ -51,7 +51,7 @@ export function PromptTable(props: { projectId: string }) {
cell: ({ row }) => {
const isActive = row.getValue("isActive");
return isActive ? (
- <StatusBadge type="live" className="h-6 w-24" />
+ <StatusBadge type="production" className="h-6 w-24" />
) : (
<StatusBadge type="disabled" className="h-6 w-24" />
);
diff --git a/src/pages/api/public/prompts.ts b/src/pages/api/public/prompts.ts
index 72e475101b..35d764c927 100644
--- a/src/pages/api/public/prompts.ts
+++ b/src/pages/api/public/prompts.ts
@@ -35,7 +35,7 @@ export default async function handler(
try {
console.log(
- "trying to get prompts, project ",
+ "trying to get prompt, project ",
authCheck.scope.projectId,
", body:",
JSON.stringify(req.query, null, 2),
diff --git a/src/pages/project/[projectId]/prompts/[prompt_id].tsx b/src/pages/project/[projectId]/prompts/[promptId].tsx
similarity index 67%
rename from src/pages/project/[projectId]/prompts/[prompt_id].tsx
rename to src/pages/project/[projectId]/prompts/[promptId].tsx
index fd2f5600f9..d9139a6522 100644
--- a/src/pages/project/[projectId]/prompts/[prompt_id].tsx
+++ b/src/pages/project/[projectId]/prompts/[promptId].tsx
@@ -3,8 +3,8 @@ import { useRouter } from "next/router";
export default function PromptDetailPage() {
const router = useRouter();
- const prompt_id = router.query.prompt_id as string;
+ const promptId = router.query.promptId as string;
const projectId = router.query.projectId as string;
- return <PromptDetail projectId={projectId} promptId={prompt_id} />;
+ return <PromptDetail projectId={projectId} promptId={promptId} />;
}
diff --git a/src/pages/project/[projectId]/prompts/index.tsx b/src/pages/project/[projectId]/prompts/index.tsx
index ef6c306a60..2b43ddd6d9 100644
--- a/src/pages/project/[projectId]/prompts/index.tsx
+++ b/src/pages/project/[projectId]/prompts/index.tsx
@@ -8,7 +8,14 @@ export default function Prompts() {
return (
<div>
- <Header title="Prompts" />
+ <Header
+ title="Prompts"
+ help={{
+ description:
+ "Manage and version your prompts in Langfuse. Edit and update them via the UI and SDK. Retrieve the production version via the SDKs. Learn more in the docs.",
+ href: "https://langfuse.com/docs/prompts",
+ }}
+ />
<PromptTable projectId={projectId} />
</div>
);