🪢 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(ui): standardize the prompt variable list preview across views (#6027)
Marc Klingen4d387cc35cbf
diff --git a/web/src/ee/features/evals/components/template-form.tsx b/web/src/ee/features/evals/components/template-form.tsxindex e6a930b7fe..69bd8065e6 100644--- a/web/src/ee/features/evals/components/template-form.tsx+++ b/web/src/ee/features/evals/components/template-form.tsx@@ -24,7 +24,7 @@ import {type ModelParams,ZodModelConfig,} from "@langfuse/shared";-import { PromptDescription } from "@/src/features/prompts/components/prompt-description";+import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";import {Select,SelectContent,@@ -426,8 +426,8 @@ export const InnerEvalTemplateForm = (props: {/></FormControl><FormMessage />- <PromptDescription- currentExtractedVariables={extractedVariables ?? []}+ <PromptVariableListPreview+ variables={extractedVariables ?? []}/></FormItem></>diff --git a/web/src/features/prompts/components/NewPromptForm/index.tsx b/web/src/features/prompts/components/NewPromptForm/index.tsxindex a752e2ff5d..dbc15306a3 100644--- a/web/src/features/prompts/components/NewPromptForm/index.tsx+++ b/web/src/features/prompts/components/NewPromptForm/index.tsx@@ -43,7 +43,7 @@ import {import { Input } from "@/src/components/ui/input";import Link from "next/link";import { ArrowTopRightIcon } from "@radix-ui/react-icons";-import { PromptDescription } from "@/src/features/prompts/components/prompt-description";+import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { PromptLinkingEditor } from "@/src/components/editor/PromptLinkingEditor";import { PRODUCTION_LABEL } from "@/src/features/prompts/constants";@@ -318,9 +318,7 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {</TabsContent></Tabs></FormItem>- <PromptDescription- currentExtractedVariables={currentExtractedVariables}- />+ <PromptVariableListPreview variables={currentExtractedVariables} /></>{/* Prompt Config field */}diff --git a/web/src/features/prompts/components/prompt-description.tsx b/web/src/features/prompts/components/PromptVariableListPreview.tsxsimilarity index 66%rename from web/src/features/prompts/components/prompt-description.tsxrename to web/src/features/prompts/components/PromptVariableListPreview.tsxindex dccb82ec10..54c260e551 100644--- a/web/src/features/prompts/components/prompt-description.tsx+++ b/web/src/features/prompts/components/PromptVariableListPreview.tsx@@ -1,11 +1,11 @@import { Badge } from "@/src/components/ui/badge";-export const PromptDescription = ({- currentExtractedVariables,+export const PromptVariableListPreview = ({+ variables,}: {- currentExtractedVariables: string[];+ variables: string[];}) => {- if (currentExtractedVariables.length === 0) {+ if (variables.length === 0) {return null;}@@ -15,7 +15,7 @@ export const PromptDescription = ({The following variables are available:</p><div className="flex min-h-6 flex-wrap gap-2">- {currentExtractedVariables.map((variable) => (+ {variables.map((variable) => (<Badge key={variable} variant="outline">{variable}</Badge>diff --git a/web/src/features/prompts/components/prompt-detail.tsx b/web/src/features/prompts/components/prompt-detail.tsxindex 89ea486c42..3905badf3c 100644--- a/web/src/features/prompts/components/prompt-detail.tsx+++ b/web/src/features/prompts/components/prompt-detail.tsx@@ -54,6 +54,7 @@ import { CommentDrawerButton } from "@/src/features/comments/CommentDrawerButtonimport { Command, CommandInput } from "@/src/components/ui/command";import { PRODUCTION_LABEL } from "@/src/features/prompts/constants";import { renderContentWithPromptButtons } from "@/src/features/prompts/components/renderContentWithPromptButtons";+import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";const getPythonCode = (name: string,@@ -536,23 +537,7 @@ export const PromptDetail = () => {) : (<JSONView json={prompt.prompt} title="Prompt" />)}- {extractedVariables.length > 0 && (- <div className="flex flex-col">- <div className="my-1 flex flex-shrink-0 items-center justify-between pl-1 text-sm font-medium">- Variables- </div>- <div className="flex flex-wrap gap-2 rounded-md">- {extractedVariables.map((variable) => (- <div- key={variable}- className="flex flex-col gap-1 rounded-md border p-2 text-sm"- >- {`{{${variable}}}`}- </div>- ))}- </div>- </div>- )}+ <PromptVariableListPreview variables={extractedVariables} /></div></TabsBarContent><TabsBarContentdiff --git a/web/src/features/prompts/server/routers/promptRouter.ts b/web/src/features/prompts/server/routers/promptRouter.tsindex 06d3475725..5e3dc2b95f 100644--- a/web/src/features/prompts/server/routers/promptRouter.ts+++ b/web/src/features/prompts/server/routers/promptRouter.ts@@ -10,7 +10,7 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { type Prompt, Prisma, prisma } from "@langfuse/shared/src/db";+import { type Prompt, Prisma } from "@langfuse/shared/src/db";import { createPrompt, duplicatePrompt } from "../actions/createPrompt";import { promptsTableCols } from "@/src/server/api/definitions/promptsTable";import { optionalPaginationZod, paginationZod } from "@langfuse/shared";@@ -938,7 +938,9 @@ export const promptRouter = createTRPCRouter({},});- return new PromptService(prisma, redis).buildAndResolvePromptGraph({+ const promptService = new PromptService(ctx.prisma, redis);++ return promptService.buildAndResolvePromptGraph({projectId: input.projectId,parentPrompt: prompt,});