From e02ade5a309ea7e8adbf8cd8a652e7d24b6d83c3 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sun, 29 Mar 2026 00:32:26 +0800 Subject: [PATCH] feat: add preset selection options and update translations for select preset --- .../templates/metadata/pipeline/ai.yaml | 14 ++++++ .../dynamic-form/DynamicFormItemComponent.tsx | 47 ++++++++++++++++++- web/src/components/ui/select.tsx | 16 ++++++- web/src/i18n/locales/en-US.ts | 1 + web/src/i18n/locales/es-ES.ts | 1 + web/src/i18n/locales/ja-JP.ts | 1 + web/src/i18n/locales/th-TH.ts | 1 + web/src/i18n/locales/vi-VN.ts | 1 + web/src/i18n/locales/zh-Hans.ts | 1 + web/src/i18n/locales/zh-Hant.ts | 1 + 10 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/langbot/templates/metadata/pipeline/ai.yaml b/src/langbot/templates/metadata/pipeline/ai.yaml index 600fd7a6..0bb201a7 100644 --- a/src/langbot/templates/metadata/pipeline/ai.yaml +++ b/src/langbot/templates/metadata/pipeline/ai.yaml @@ -118,6 +118,11 @@ stages: zh_Hans: 基础 URL type: string required: true + options: + - name: 'https://api.dify.ai/v1' + label: + en_US: Dify Cloud + zh_Hans: Dify 云服务 default: 'https://api.dify.ai/v1' - name: base-prompt label: @@ -341,6 +346,15 @@ stages: en_US: The base URL for the Coze API, please use https://api.coze.com for global Coze edition(coze.com). zh_Hans: Coze API 的基础 URL,请使用 https://api.coze.com 用于全球 Coze 版(coze.com) type: string + options: + - name: 'https://api.coze.cn' + label: + en_US: Coze China + zh_Hans: Coze 中国版 + - name: 'https://api.coze.com' + label: + en_US: Coze Global + zh_Hans: Coze 全球版 default: "https://api.coze.cn" - name: auto-save-history label: diff --git a/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx b/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx index a33309bb..6a6f8707 100644 --- a/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx +++ b/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx @@ -46,12 +46,19 @@ import { Sparkles, Info, Settings, + ChevronDown, } from 'lucide-react'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu'; import ModelsDialog from '@/app/home/components/models-dialog/ModelsDialog'; export default function DynamicFormItemComponent({ @@ -215,6 +222,40 @@ export default function DynamicFormItemComponent({ ); case DynamicFormItemType.STRING: + if (config.options && config.options.length > 0) { + return ( +
+ + + + + + + {config.options.map((option) => ( + field.onChange(option.name)} + > +
+ {extractI18nObject(option.label)} + + {option.name} + +
+
+ ))} +
+
+
+ ); + } return ; case DynamicFormItemType.TEXT: @@ -276,7 +317,11 @@ export default function DynamicFormItemComponent({ {config.options?.map((option) => ( - + {extractI18nObject(option.label)} ))} diff --git a/web/src/components/ui/select.tsx b/web/src/components/ui/select.tsx index a5d19d35..7358cb0b 100644 --- a/web/src/components/ui/select.tsx +++ b/web/src/components/ui/select.tsx @@ -101,8 +101,11 @@ function SelectLabel({ function SelectItem({ className, children, + description, ...props -}: React.ComponentProps) { +}: React.ComponentProps & { + description?: React.ReactNode; +}) { return ( - {children} + {description != null ? ( +
+ {children} + + {description} + +
+ ) : ( + {children} + )}
); } diff --git a/web/src/i18n/locales/en-US.ts b/web/src/i18n/locales/en-US.ts index 22ea474b..681fdc0b 100644 --- a/web/src/i18n/locales/en-US.ts +++ b/web/src/i18n/locales/en-US.ts @@ -46,6 +46,7 @@ const enUS = { confirmDelete: 'Confirm Delete', deleteConfirmation: 'Are you sure you want to delete this?', selectOption: 'Select an option', + selectPreset: 'Select Preset', required: 'Required', enable: 'Enable', name: 'Name', diff --git a/web/src/i18n/locales/es-ES.ts b/web/src/i18n/locales/es-ES.ts index 183ef38d..d118a583 100644 --- a/web/src/i18n/locales/es-ES.ts +++ b/web/src/i18n/locales/es-ES.ts @@ -48,6 +48,7 @@ const esES = { confirmDelete: 'Confirmar eliminación', deleteConfirmation: '¿Estás seguro de que deseas eliminar esto?', selectOption: 'Selecciona una opción', + selectPreset: 'Seleccionar preajuste', required: 'Obligatorio', enable: 'Activar', name: 'Nombre', diff --git a/web/src/i18n/locales/ja-JP.ts b/web/src/i18n/locales/ja-JP.ts index 619282bf..e4c9f5aa 100644 --- a/web/src/i18n/locales/ja-JP.ts +++ b/web/src/i18n/locales/ja-JP.ts @@ -47,6 +47,7 @@ confirmDelete: '削除の確認', deleteConfirmation: '本当に削除しますか?', selectOption: 'オプションを選択', + selectPreset: 'プリセットを選択', required: '必須', enable: '有効にする', name: '名前', diff --git a/web/src/i18n/locales/th-TH.ts b/web/src/i18n/locales/th-TH.ts index c0e6e611..cb1abe7f 100644 --- a/web/src/i18n/locales/th-TH.ts +++ b/web/src/i18n/locales/th-TH.ts @@ -46,6 +46,7 @@ const thTH = { confirmDelete: 'ยืนยันการลบ', deleteConfirmation: 'คุณแน่ใจหรือไม่ว่าต้องการลบสิ่งนี้?', selectOption: 'เลือกตัวเลือก', + selectPreset: 'เลือกค่าที่ตั้งไว้', required: 'จำเป็น', enable: 'เปิดใช้งาน', name: 'ชื่อ', diff --git a/web/src/i18n/locales/vi-VN.ts b/web/src/i18n/locales/vi-VN.ts index 3a8e871c..f32eb681 100644 --- a/web/src/i18n/locales/vi-VN.ts +++ b/web/src/i18n/locales/vi-VN.ts @@ -46,6 +46,7 @@ const viVN = { confirmDelete: 'Xác nhận xóa', deleteConfirmation: 'Bạn có chắc chắn muốn xóa mục này không?', selectOption: 'Chọn một tùy chọn', + selectPreset: 'Chọn mẫu có sẵn', required: 'Bắt buộc', enable: 'Bật', name: 'Tên', diff --git a/web/src/i18n/locales/zh-Hans.ts b/web/src/i18n/locales/zh-Hans.ts index 308cf603..72c3acbb 100644 --- a/web/src/i18n/locales/zh-Hans.ts +++ b/web/src/i18n/locales/zh-Hans.ts @@ -45,6 +45,7 @@ const zhHans = { confirmDelete: '确认删除', deleteConfirmation: '你确定要删除这个吗?', selectOption: '选择一个选项', + selectPreset: '选择预设', required: '必填', enable: '是否启用', name: '名称', diff --git a/web/src/i18n/locales/zh-Hant.ts b/web/src/i18n/locales/zh-Hant.ts index 5804a3fa..9581617f 100644 --- a/web/src/i18n/locales/zh-Hant.ts +++ b/web/src/i18n/locales/zh-Hant.ts @@ -45,6 +45,7 @@ const zhHant = { confirmDelete: '確認刪除', deleteConfirmation: '您確定要刪除這個嗎?', selectOption: '選擇一個選項', + selectPreset: '選擇預設', required: '必填', enable: '是否啟用', name: '名稱',