fix(web): object/array[object] add format check
This commit is contained in:
@@ -2239,6 +2239,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
addvariable: 'Chat Variables',
|
||||
addChatVariable: 'Add Chat Variable',
|
||||
editChatVariable: 'Edit Chat Variable',
|
||||
invalidJSON: 'Invalid JSON format',
|
||||
|
||||
config: {
|
||||
llm: {
|
||||
|
||||
@@ -2200,6 +2200,7 @@ export const zh = {
|
||||
addvariable: '会话变量',
|
||||
addChatVariable: '添加会话变量',
|
||||
editChatVariable: '编辑会话变量',
|
||||
invalidJSON: 'JSON 格式不正确',
|
||||
|
||||
config: {
|
||||
llm: {
|
||||
|
||||
@@ -124,7 +124,7 @@ const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProp
|
||||
setFileList(list);
|
||||
}
|
||||
} else if (variable.type.includes('object') && variable.defaultValue) {
|
||||
form.setFieldValue('defaultValue', JSON.stringify(variable.defaultValue, null, 2))
|
||||
form.setFieldValue('defaultValue', variable.defaultValue ? JSON.stringify(variable.defaultValue, null, 2) : undefined)
|
||||
}
|
||||
} else {
|
||||
form.resetFields();
|
||||
@@ -342,7 +342,19 @@ const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProp
|
||||
</Form.Item>
|
||||
)
|
||||
: (
|
||||
<Form.Item name="defaultValue" label={t('workflow.config.parameter-extractor.default')}>
|
||||
<Form.Item
|
||||
name="defaultValue"
|
||||
label={t('workflow.config.parameter-extractor.default')}
|
||||
rules={[
|
||||
(type === 'object' || type === 'array[object]') ? {
|
||||
validator: (_, value) => {
|
||||
if (!value) return Promise.resolve();
|
||||
try { JSON.parse(value); return Promise.resolve(); }
|
||||
catch { return Promise.reject(t('workflow.invalidJSON')); }
|
||||
}
|
||||
} : {}
|
||||
]}
|
||||
>
|
||||
{type === 'number'
|
||||
? <InputNumber placeholder={t('common.enter')} style={{ width: '100%' }} />
|
||||
: type === 'boolean'
|
||||
|
||||
Reference in New Issue
Block a user