mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-04 17:45:07 +08:00
Fixes: Added session variable types and modified configuration (#11269)
### What problem does this PR solve? Fixes: Added session variable types and modified configuration - Added more types of session variables - Modified the embedding model switching logic in the knowledge base configuration ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
73
web/src/pages/agent/gobal-variable-sheet/constant.ts
Normal file
73
web/src/pages/agent/gobal-variable-sheet/constant.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import { FormFieldConfig, FormFieldType } from '@/components/dynamic-form';
|
||||
import { buildSelectOptions } from '@/utils/component-util';
|
||||
import { t } from 'i18next';
|
||||
// const TypesWithoutArray = Object.values(JsonSchemaDataType).filter(
|
||||
// (item) => item !== JsonSchemaDataType.Array,
|
||||
// );
|
||||
// const TypesWithArray = [
|
||||
// ...TypesWithoutArray,
|
||||
// ...TypesWithoutArray.map((item) => `array<${item}>`),
|
||||
// ];
|
||||
|
||||
export enum TypesWithArray {
|
||||
String = 'string',
|
||||
Number = 'number',
|
||||
Boolean = 'boolean',
|
||||
Object = 'object',
|
||||
ArrayString = 'array<string>',
|
||||
ArrayNumber = 'array<number>',
|
||||
ArrayBoolean = 'array<boolean>',
|
||||
ArrayObject = 'array<object>',
|
||||
}
|
||||
|
||||
export const GlobalFormFields = [
|
||||
{
|
||||
label: t('flow.name'),
|
||||
name: 'name',
|
||||
placeholder: t('common.namePlaceholder'),
|
||||
required: true,
|
||||
validation: {
|
||||
pattern: /^[a-zA-Z_]+$/,
|
||||
message: t('flow.variableNameMessage'),
|
||||
},
|
||||
type: FormFieldType.Text,
|
||||
},
|
||||
{
|
||||
label: t('flow.type'),
|
||||
name: 'type',
|
||||
placeholder: '',
|
||||
required: true,
|
||||
type: FormFieldType.Select,
|
||||
options: buildSelectOptions(Object.values(TypesWithArray)),
|
||||
},
|
||||
{
|
||||
label: t('flow.defaultValue'),
|
||||
name: 'value',
|
||||
placeholder: '',
|
||||
type: FormFieldType.Textarea,
|
||||
},
|
||||
{
|
||||
label: t('flow.description'),
|
||||
name: 'description',
|
||||
placeholder: t('flow.variableDescription'),
|
||||
type: FormFieldType.Textarea,
|
||||
},
|
||||
] as FormFieldConfig[];
|
||||
|
||||
export const GlobalVariableFormDefaultValues = {
|
||||
name: '',
|
||||
type: TypesWithArray.String,
|
||||
value: '',
|
||||
description: '',
|
||||
};
|
||||
|
||||
export const TypeMaps = {
|
||||
[TypesWithArray.String]: FormFieldType.Textarea,
|
||||
[TypesWithArray.Number]: FormFieldType.Number,
|
||||
[TypesWithArray.Boolean]: FormFieldType.Checkbox,
|
||||
[TypesWithArray.Object]: FormFieldType.Textarea,
|
||||
[TypesWithArray.ArrayString]: FormFieldType.Textarea,
|
||||
[TypesWithArray.ArrayNumber]: FormFieldType.Textarea,
|
||||
[TypesWithArray.ArrayBoolean]: FormFieldType.Textarea,
|
||||
[TypesWithArray.ArrayObject]: FormFieldType.Textarea,
|
||||
};
|
||||
Reference in New Issue
Block a user