🪢 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
fix(llm-connections): don't update bedrock llm connection empty values (#10437)
Nimar2c4e6fd34532
diff --git a/web/src/components/ChatMessages/index.tsx b/web/src/components/ChatMessages/index.tsxindex a24e687542..a7d4085df8 100644--- a/web/src/components/ChatMessages/index.tsx+++ b/web/src/components/ChatMessages/index.tsx@@ -1,4 +1,4 @@-import { PlusCircleIcon } from "lucide-react";+import { ChevronDownIcon, PlusCircleIcon } from "lucide-react";import { useEffect, useRef } from "react";import { Button } from "@/src/components/ui/button";@@ -8,6 +8,12 @@ import {TooltipProvider,TooltipTrigger,} from "@/src/components/ui/tooltip";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/src/components/ui/dropdown-menu";import {ChatMessageRole,ChatMessageType,@@ -147,6 +153,49 @@ const AddMessageButton: React.FC<AddMessageButtonProps> = ({}};+ const addMessageWithRole = (role: ChatMessageRole) => {+ switch (role) {+ case ChatMessageRole.User:+ addMessage({+ role: ChatMessageRole.User,+ content: "",+ type: ChatMessageType.User,+ });+ break;+ case ChatMessageRole.Assistant:+ addMessage({+ role: ChatMessageRole.Assistant,+ content: "",+ type: ChatMessageType.AssistantText,+ });+ break;+ case ChatMessageRole.System:+ addMessage({+ role: ChatMessageRole.System,+ content: "",+ type: ChatMessageType.System,+ });+ break;+ case ChatMessageRole.Developer:+ addMessage({+ role: ChatMessageRole.Developer,+ content: "",+ type: ChatMessageType.Developer,+ });+ break;+ case ChatMessageRole.Tool:+ addMessage({+ role: ChatMessageRole.Tool,+ content: "",+ type: ChatMessageType.ToolResult,+ toolCallId: "",+ });+ break;+ default:+ addRegularMessage();+ }+ };+const addPlaceholderMessage = () => {addMessage({type: ChatMessageType.Placeholder,@@ -156,15 +205,55 @@ const AddMessageButton: React.FC<AddMessageButtonProps> = ({return (<div className="flex gap-2">- <Button- type="button"- variant="outline"- className="flex-1"- onClick={addRegularMessage}- >- <PlusCircleIcon size={14} className="mr-2" />- <p>Message</p>- </Button>+ <div className="flex flex-1 gap-0">+ <Button+ type="button"+ variant="outline"+ className="flex-1 rounded-r-none border-r-0"+ onClick={addRegularMessage}+ >+ <PlusCircleIcon size={14} className="mr-2" />+ <p>Message</p>+ </Button>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ type="button"+ variant="outline"+ className="rounded-l-none border-l px-2"+ >+ <ChevronDownIcon size={14} />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem+ onClick={() => addMessageWithRole(ChatMessageRole.User)}+ >+ User Message+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => addMessageWithRole(ChatMessageRole.Assistant)}+ >+ Assistant Message+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => addMessageWithRole(ChatMessageRole.System)}+ >+ System Message+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => addMessageWithRole(ChatMessageRole.Developer)}+ >+ Developer Message+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => addMessageWithRole(ChatMessageRole.Tool)}+ >+ Tool Message+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </div><TooltipProvider><Tooltip><TooltipTrigger asChild>diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsxindex 507cd0fd88..04753627d5 100644--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx@@ -65,11 +65,18 @@ const createFormSchema = (mode: "create" | "update") =>}),),})- // 1) If adapter requires custom models, enforce that first+ // 1) Bedrock validation - credentials required in create mode.refine((data) => {if (data.adapter !== LLMAdapter.Bedrock) return true;+ // In update mode, credentials are optional (existing ones are preserved)+ if (mode === "update") {+ // Only validate region is present+ return data.awsRegion;+ }++ // In create mode, validate credentials// For cloud deployments, AWS credentials are requiredif (isLangfuseCloud) {return (@@ -81,9 +88,12 @@ const createFormSchema = (mode: "create" | "update") =>return data.awsRegion;},{- message: isLangfuseCloud- ? "AWS credentials are required for Bedrock"- : "AWS region is required.",+ message:+ mode === "update"+ ? "AWS region is required."+ : isLangfuseCloud+ ? "AWS credentials are required for Bedrock"+ : "AWS region is required.",path: ["adapter"],},)@@ -210,6 +220,12 @@ export function CreateLLMApiKeyForm({existingKey.adapter === LLMAdapter.VertexAI && existingKey.config? ((existingKey.config as VertexAIConfig).location ?? ""): "",+ awsRegion:+ existingKey.adapter === LLMAdapter.Bedrock && existingKey.config+ ? ((existingKey.config as BedrockConfig).region ?? "")+ : "",+ awsAccessKeyId: "",+ awsSecretAccessKey: "",}: {adapter: defaultAdapter,@@ -220,6 +236,9 @@ export function CreateLLMApiKeyForm({customModels: [],extraHeaders: [],vertexAILocation: "",+ awsRegion: "",+ awsAccessKeyId: "",+ awsSecretAccessKey: "",},});@@ -387,18 +406,33 @@ export function CreateLLMApiKeyForm({let config: BedrockConfig | VertexAIConfig | undefined;if (currentAdapter === LLMAdapter.Bedrock) {- // For self-hosted deployments, allow empty credentials to use default provider chain- if (- !isLangfuseCloud &&- (!values.awsAccessKeyId || !values.awsSecretAccessKey)- ) {- secretKey = BEDROCK_USE_DEFAULT_CREDENTIALS;+ // In update mode, only update credentials if provided+ if (mode === "update") {+ // Only update secretKey if both credentials are provided+ if (values.awsAccessKeyId && values.awsSecretAccessKey) {+ const credentials: BedrockCredential = {+ accessKeyId: values.awsAccessKeyId,+ secretAccessKey: values.awsSecretAccessKey,+ };+ secretKey = JSON.stringify(credentials);+ } else {+ // Keep existing credentials by not setting secretKey+ secretKey = undefined;+ }} else {- const credentials: BedrockCredential = {- accessKeyId: values.awsAccessKeyId ?? "",- secretAccessKey: values.awsSecretAccessKey ?? "",- };- secretKey = JSON.stringify(credentials);+ // In create mode, handle as before+ if (+ !isLangfuseCloud &&+ (!values.awsAccessKeyId || !values.awsSecretAccessKey)+ ) {+ secretKey = BEDROCK_USE_DEFAULT_CREDENTIALS;+ } else {+ const credentials: BedrockCredential = {+ accessKeyId: values.awsAccessKeyId ?? "",+ secretAccessKey: values.awsSecretAccessKey ?? "",+ };+ secretKey = JSON.stringify(credentials);+ }}config = {@@ -550,8 +584,29 @@ export function CreateLLMApiKeyForm({render={({ field }) => (<FormItem><FormLabel>AWS Region</FormLabel>+ <FormDescription>+ {mode === "update" &&+ existingKey?.config &&+ (existingKey.config as BedrockConfig).region && (+ <span className="text-sm">+ Current:{" "}+ <code className="rounded bg-muted px-1 py-0.5">+ {(existingKey.config as BedrockConfig).region}+ </code>+ </span>+ )}+ </FormDescription><FormControl>- <Input {...field} data-1p-ignore />+ <Input+ {...field}+ placeholder={+ mode === "update" && existingKey?.config+ ? ((existingKey.config as BedrockConfig).region ??+ "")+ : "e.g., us-east-1"+ }+ data-1p-ignore+ /></FormControl><FormMessage /></FormItem>@@ -572,12 +627,26 @@ export function CreateLLMApiKeyForm({)}</FormLabel><FormDescription>- {isLangfuseCloud- ? "These should be long-lived credentials for an AWS user with `bedrock:InvokeModel` permission."- : "For self-hosted deployments, AWS credentials are optional. When omitted, authentication will use the AWS SDK default credential provider chain."}+ {mode === "update"+ ? "Leave empty to keep existing credentials. To update, provide both Access Key ID and Secret Access Key."+ : isLangfuseCloud+ ? "These should be long-lived credentials for an AWS user with `bedrock:InvokeModel` permission."+ : "For self-hosted deployments, AWS credentials are optional. When omitted, authentication will use the AWS SDK default credential provider chain."}</FormDescription><FormControl>- <Input {...field} data-1p-ignore />+ <Input+ {...field}+ placeholder={+ mode === "update"+ ? existingKey?.displaySecretKey ===+ "Default AWS credentials"+ ? "Using default AWS credentials"+ : "•••••••• (existing credentials preserved if empty)"+ : undefined+ }+ autoComplete="off"+ data-1p-ignore+ /></FormControl><FormMessage /></FormItem>@@ -598,7 +667,22 @@ export function CreateLLMApiKeyForm({)}</FormLabel><FormControl>- <Input {...field} data-1p-ignore />+ <Input+ {...field}+ type="password"+ placeholder={+ mode === "update"+ ? existingKey?.displaySecretKey ===+ "Default AWS credentials"+ ? "Using default AWS credentials"+ : existingKey?.displaySecretKey+ ? `${existingKey.displaySecretKey} (preserved if empty)`+ : "•••••••• (existing credentials preserved if empty)"+ : undefined+ }+ autoComplete="new-password"+ data-1p-ignore+ /></FormControl><FormMessage /></FormItem>