feat(ChatKnowledge):chunk add enable_merge parameter (#1014)

Co-authored-by: Aralhi <xiaoping0501@gmail.com>
This commit is contained in:
Aries-ckt
2024-01-04 10:04:41 +08:00
committed by GitHub
parent fd30588e55
commit ca83443c48
26 changed files with 98 additions and 41 deletions

View File

@@ -47,7 +47,7 @@ export default function ArgumentsModal({ space, argumentsShow, setArgumentsShow
</Form.Item>
</Col>
<Col span={12}>
<Form.Item<IArguments> tooltip={t(`Recall_Type`)} rules={[{ required: true }]} label={t('recall_type')} name={['embedding', 'recall_type']}>
<Form.Item<IArguments> tooltip={t(`recall_type`)} rules={[{ required: true }]} label={t('recall_type')} name={['embedding', 'recall_type']}>
<Input className="mb-5 h-12" />
</Form.Item>
</Col>

View File

@@ -1,5 +1,5 @@
import { IChunkStrategyResponse } from '@/types/knowledge';
import { Alert, Form, FormListFieldData, Input, InputNumber, Radio, RadioChangeEvent } from 'antd';
import { Alert, Checkbox, Form, FormListFieldData, Input, InputNumber, Radio, RadioChangeEvent } from 'antd';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
const { TextArea } = Input;
@@ -25,7 +25,7 @@ export default function StrategyForm({ strategies, docType, fileName, field }: I
const [selectedStrategy, setSelectedStrategy] = useState<string>();
const { t } = useTranslation();
const DEFAULT_STRATEGY = {
strategy: t('Automatic'),
strategy: 'Automatic',
name: t('Automatic'),
desc: t('Automatic_desc'),
};
@@ -50,17 +50,30 @@ export default function StrategyForm({ strategies, docType, fileName, field }: I
{parameters?.map((param) => (
<Form.Item
key={`param_${param.param_name}`}
label={`${param.param_name}: ${param.param_type}`}
label={param.param_name}
name={[field!.name, 'chunk_parameters', param.param_name]}
rules={[{ required: true, message: t('Please_input_the_name') }]}
initialValue={param.default_value}
valuePropName={param.param_type === 'boolean' ? 'checked' : 'value'}
tooltip={param.description}
>
{param.param_type === 'int' ? <InputNumber className="w-full" min={1} /> : <TextArea className="w-full" rows={2} maxLength={6} />}
{renderParamByType(param.param_type)}
</Form.Item>
))}
</div>
);
}
function renderParamByType(type: string) {
switch (type) {
case 'int':
return <InputNumber className="w-full" min={1} />;
case 'string':
return <TextArea className="w-full" rows={2} />;
case 'boolean':
return <Checkbox />;
}
}
return (
<>
<Form.Item name={[field!.name, 'chunk_parameters', 'chunk_strategy']} initialValue={DEFAULT_STRATEGY.strategy}>