Skip to content

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

chore(ui): improve consistency of prompt and eval template forms (#5679)

Marc Klingen5c5dfcbac621
diff --git a/web/src/ee/features/evals/components/template-form.tsx b/web/src/ee/features/evals/components/template-form.tsx
index 66f611e482..e6a930b7fe 100644
--- a/web/src/ee/features/evals/components/template-form.tsx
+++ b/web/src/ee/features/evals/components/template-form.tsx
@@ -12,7 +12,6 @@ import {
FormLabel,
FormMessage,
} from "@/src/components/ui/form";
-import { Textarea } from "@/src/components/ui/textarea";
import { api } from "@/src/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
import { extractVariables, getIsCharOrUnderscore } from "@langfuse/shared";
@@ -40,6 +39,7 @@ import { useModelParams } from "@/src/ee/features/playground/page/hooks/useModel
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
import { RadioGroup, RadioGroupItem } from "@/src/components/ui/radio-group";
import { EvalReferencedEvaluators } from "@/src/ee/features/evals/types";
+import { CodeMirrorEditor } from "@/src/components/editor";
export const EvalTemplateForm = (props: {
projectId: string;
@@ -70,7 +70,7 @@ export const EvalTemplateForm = (props: {
<SelectTrigger className="text-primary ring-transparent focus:ring-0 focus:ring-offset-0">
<SelectValue
className="text-sm font-semibold text-primary"
- placeholder={"Select a Langfuse managed template"}
+ placeholder={"Select a Langfuse managed template (optional)"}
/>
</SelectTrigger>
<SelectContent className="max-h-60 max-w-80">
@@ -411,11 +411,18 @@ export const InnerEvalTemplateForm = (props: {
<>
<FormItem>
<FormLabel>Prompt</FormLabel>
+ <FormDescription>
+ Define your llm-as-a-judge evaluation template. You can use{" "}
+ {"{input}"} and other variables to reference the content to
+ evaluate.
+ </FormDescription>
<FormControl>
- <Textarea
- {...field}
- placeholder="{{input}} Please evaluate the input on toxicity."
- className="min-h-[350px] flex-1 font-mono text-xs"
+ <CodeMirrorEditor
+ value={field.value}
+ onChange={field.onChange}
+ editable
+ mode="prompt"
+ minHeight={200}
/>
</FormControl>
<FormMessage />
@@ -429,17 +436,21 @@ export const InnerEvalTemplateForm = (props: {
<FormField
control={form.control}
- name="outputScore"
+ name="outputReasoning"
render={({ field }) => (
<FormItem>
- <FormLabel>Score</FormLabel>
- <FormControl>
- <Input {...field} placeholder="Score between 0 and 1" />
- </FormControl>
+ <FormLabel>Reasoning</FormLabel>
<FormDescription>
- We use function calls to extract data from the LLM. Specify
- what the LLM should return for the score.
+ Define how the LLM should explain its evaluation. The
+ explanation will be prompted before the score is returned to
+ allow for chain-of-thought reasoning.
</FormDescription>
+ <FormControl>
+ <Input
+ placeholder="One sentence reasoning for the score"
+ {...field}
+ />
+ </FormControl>
<FormMessage />
</FormItem>
)}
@@ -447,20 +458,17 @@ export const InnerEvalTemplateForm = (props: {
<FormField
control={form.control}
- name="outputReasoning"
+ name="outputScore"
render={({ field }) => (
<FormItem>
- <FormLabel>Reasoning</FormLabel>
- <FormControl>
- <Input
- placeholder="One sentence reasoning for the score"
- {...field}
- />
- </FormControl>
+ <FormLabel>Score</FormLabel>
<FormDescription>
- We use function calls to extract data from the LLM. Specify
- what the LLM should return for the reasoning.
+ Define how the LLM should return the evaluation score in
+ natural language. Needs to yield a numeric value.
</FormDescription>
+ <FormControl>
+ <Input {...field} placeholder="Score between 0 and 1" />
+ </FormControl>
<FormMessage />
</FormItem>
)}
@@ -473,6 +481,15 @@ export const InnerEvalTemplateForm = (props: {
render={({ field }) => (
<FormItem>
<FormLabel>Referenced evaluators</FormLabel>
+ <FormDescription>
+ {evaluatorsByTemplateNameQuery.data?.evaluators.length ?? 0}{" "}
+ evaluator(s) are currently using this template.
+ {Boolean(
+ evaluatorsByTemplateNameQuery.data?.evaluators.length,
+ )
+ ? " Choose how to handle existing evaluators with this update."
+ : " No evaluators to update."}
+ </FormDescription>
<FormControl>
<RadioGroup
{...field}
@@ -509,15 +526,6 @@ export const InnerEvalTemplateForm = (props: {
</FormItem>
</RadioGroup>
</FormControl>
- <FormDescription>
- {evaluatorsByTemplateNameQuery.data?.evaluators.length ?? 0}{" "}
- evaluator(s) are currently using this template.{" "}
- {Boolean(
- evaluatorsByTemplateNameQuery.data?.evaluators.length,
- )
- ? "Would you like to update them to use this version?"
- : "No evaluators to update."}
- </FormDescription>
<FormMessage />
</FormItem>
)}
diff --git a/web/src/features/prompts/components/NewPromptForm/index.tsx b/web/src/features/prompts/components/NewPromptForm/index.tsx
index 881270e9aa..e1e6b8e9de 100644
--- a/web/src/features/prompts/components/NewPromptForm/index.tsx
+++ b/web/src/features/prompts/components/NewPromptForm/index.tsx
@@ -240,6 +240,13 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
<>
<FormItem>
<FormLabel>Prompt</FormLabel>
+ <FormDescription>
+ Define your prompt template. You can use{" "}
+ <code className="text-xs">{"{{variable}}"}</code> to insert
+ variables into your prompt.
+ <b className="font-semibold"> Note:</b> Variables must be
+ alphabetical characters or underscores.
+ </FormDescription>
<Tabs
value={form.watch("type")}
onValueChange={(e) => {
@@ -319,6 +326,11 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
render={({ field }) => (
<FormItem>
<FormLabel>Config</FormLabel>
+ <FormDescription>
+ Arbitrary JSON configuration that is available on the prompt.
+ Use this to track LLM parameters, function definitions, or any
+ other metadata.
+ </FormDescription>
<CodeMirrorEditor
value={field.value}
onChange={field.onChange}
@@ -327,10 +339,6 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
mode="json"
minHeight="none"
/>
- <FormDescription>
- Track configs for LLM API calls such as function definitions or
- LLM parameters.
- </FormDescription>
<FormMessage />
</FormItem>
)}
@@ -343,6 +351,10 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
render={({ field }) => (
<FormItem>
<FormLabel>Labels</FormLabel>
+ <FormDescription>
+ This version will be labeled as the version to be used in
+ production for this prompt. Labels can be updated later.
+ </FormDescription>
<div className="flex flex-row items-center space-x-3 space-y-0 rounded-md border p-3">
<FormControl>
<Checkbox
@@ -354,10 +366,6 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
<FormLabel>Set the &quot;production&quot; label</FormLabel>
</div>
</div>
- <FormDescription>
- This version will be labeled as the version to be used in
- production for this prompt. Can be updated later.
- </FormDescription>
</FormItem>
)}
/>
diff --git a/web/src/features/prompts/components/prompt-description.tsx b/web/src/features/prompts/components/prompt-description.tsx
index a15fc01fca..dccb82ec10 100644
--- a/web/src/features/prompts/components/prompt-description.tsx
+++ b/web/src/features/prompts/components/prompt-description.tsx
@@ -5,16 +5,14 @@ export const PromptDescription = ({
}: {
currentExtractedVariables: string[];
}) => {
+ if (currentExtractedVariables.length === 0) {
+ return null;
+ }
+
return (
- <>
- <p className="text-sm text-muted-foreground">
- You can use <code className="text-xs">{"{{variable}}"}</code> to insert
- variables into your prompt.
- <b className="font-semibold"> Note:</b> Variables must be alphabetical
- characters or underscores.
- {currentExtractedVariables.length > 0
- ? " The following variables are available:"
- : ""}
+ <div>
+ <p className="mb-2 text-sm text-muted-foreground">
+ The following variables are available:
</p>
<div className="flex min-h-6 flex-wrap gap-2">
{currentExtractedVariables.map((variable) => (
@@ -23,6 +21,6 @@ export const PromptDescription = ({
</Badge>
))}
</div>
- </>
+ </div>
);
};