### What problem does this PR solve? Vector similarity weight is displayed incorrectly #965 feat: add rerank models to the project #724 #162 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -15,7 +15,10 @@ const KnowledgeTesting = () => {
|
||||
|
||||
const handleTesting = async () => {
|
||||
const values = await form.validateFields();
|
||||
testChunk(values);
|
||||
testChunk({
|
||||
...values,
|
||||
vector_similarity_weight: 1 - values.vector_similarity_weight,
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -2,8 +2,11 @@ import SimilaritySlider from '@/components/similarity-slider';
|
||||
import { Button, Card, Divider, Flex, Form, Input } from 'antd';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
|
||||
import Rerank from '@/components/rerank';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useFetchLlmList } from '@/hooks/llmHooks';
|
||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||
import { useEffect } from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
type FieldType = {
|
||||
@@ -23,6 +26,11 @@ const TestingControl = ({ form, handleTesting }: IProps) => {
|
||||
'testDocumentChunk',
|
||||
]);
|
||||
const { t } = useTranslate('knowledgeDetails');
|
||||
const fetchLlmList = useFetchLlmList();
|
||||
|
||||
useEffect(() => {
|
||||
fetchLlmList();
|
||||
}, [fetchLlmList]);
|
||||
|
||||
const buttonDisabled =
|
||||
!question || (typeof question === 'string' && question.trim() === '');
|
||||
@@ -37,6 +45,7 @@ const TestingControl = ({ form, handleTesting }: IProps) => {
|
||||
<section>
|
||||
<Form name="testing" layout="vertical" form={form}>
|
||||
<SimilaritySlider isTooltipShown></SimilaritySlider>
|
||||
<Rerank></Rerank>
|
||||
<Card size="small" title={t('testText')}>
|
||||
<Form.Item<FieldType>
|
||||
name={'question'}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useFetchLlmList } from '@/hooks/llmHooks';
|
||||
import {
|
||||
useFetchTenantInfo,
|
||||
useSelectTenantInfo,
|
||||
@@ -16,3 +17,13 @@ export const useFetchModelId = (visible: boolean) => {
|
||||
|
||||
return tenantInfo?.llm_id ?? '';
|
||||
};
|
||||
|
||||
export const useFetchLlmModelOnVisible = (visible: boolean) => {
|
||||
const fetchLlmList = useFetchLlmList();
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
fetchLlmList();
|
||||
}
|
||||
}, [fetchLlmList, visible]);
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ import { variableEnabledFieldMap } from '../constants';
|
||||
import { IPromptConfigParameters } from '../interface';
|
||||
import { excludeUnEnabledVariables } from '../utils';
|
||||
import AssistantSetting from './assistant-setting';
|
||||
import { useFetchModelId } from './hooks';
|
||||
import { useFetchLlmModelOnVisible, useFetchModelId } from './hooks';
|
||||
import ModelSetting from './model-setting';
|
||||
import PromptEngine from './prompt-engine';
|
||||
|
||||
@@ -92,6 +92,7 @@ const ChatConfigurationModal = ({
|
||||
const finalValues = {
|
||||
dialog_id: initialDialog.id,
|
||||
...nextValues,
|
||||
vector_similarity_weight: 1 - nextValues.vector_similarity_weight,
|
||||
prompt_config: {
|
||||
...nextValues.prompt_config,
|
||||
parameters: promptEngineRef.current,
|
||||
@@ -115,6 +116,8 @@ const ChatConfigurationModal = ({
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
useFetchLlmModelOnVisible(visible);
|
||||
|
||||
const title = (
|
||||
<Flex gap={16}>
|
||||
<ChatConfigurationAtom></ChatConfigurationAtom>
|
||||
@@ -142,6 +145,7 @@ const ChatConfigurationModal = ({
|
||||
settledModelVariableMap[ModelVariableType.Precise],
|
||||
icon: fileList,
|
||||
llm_id: initialDialog.llm_id ?? modelId,
|
||||
vector_similarity_weight: 1 - initialDialog.vector_similarity_weight,
|
||||
});
|
||||
}
|
||||
}, [initialDialog, form, visible, modelId]);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useEffect } from 'react';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks';
|
||||
import { useSelectLlmOptionsByModelType } from '@/hooks/llmHooks';
|
||||
import { Variable } from '@/interfaces/database/chat';
|
||||
import { variableEnabledFieldMap } from '../constants';
|
||||
import styles from './index.less';
|
||||
@@ -30,7 +30,7 @@ const ModelSetting = ({
|
||||
value: x,
|
||||
}));
|
||||
|
||||
const modelOptions = useSelectLlmOptions();
|
||||
const modelOptions = useSelectLlmOptionsByModelType();
|
||||
|
||||
const handleParametersChange = (value: ModelVariableType) => {
|
||||
const variable = settledModelVariableMap[value];
|
||||
@@ -56,8 +56,6 @@ const ModelSetting = ({
|
||||
}
|
||||
}, [form, initialLlmSetting, visible]);
|
||||
|
||||
useFetchLlmList(LlmModelType.Chat);
|
||||
|
||||
return (
|
||||
<section
|
||||
className={classNames({
|
||||
@@ -70,7 +68,7 @@ const ModelSetting = ({
|
||||
tooltip={t('modelTip')}
|
||||
rules={[{ required: true, message: t('modelMessage') }]}
|
||||
>
|
||||
<Select options={modelOptions} showSearch />
|
||||
<Select options={modelOptions[LlmModelType.Chat]} showSearch />
|
||||
</Form.Item>
|
||||
<Divider></Divider>
|
||||
<Form.Item
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
} from '../interface';
|
||||
import { EditableCell, EditableRow } from './editable-cell';
|
||||
|
||||
import Rerank from '@/components/rerank';
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { useSelectPromptConfigParameters } from '../hooks';
|
||||
import styles from './index.less';
|
||||
@@ -172,7 +173,7 @@ const PromptEngine = (
|
||||
>
|
||||
<Slider max={30} />
|
||||
</Form.Item>
|
||||
|
||||
<Rerank></Rerank>
|
||||
<section className={classNames(styles.variableContainer)}>
|
||||
<Row align={'middle'} justify="end">
|
||||
<Col span={7} className={styles.variableAlign}>
|
||||
|
||||
@@ -76,6 +76,13 @@ const SystemModelSettingModal = ({
|
||||
>
|
||||
<Select options={allOptions[LlmModelType.Speech2text]} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t('rerankModel')}
|
||||
name="rerank_id"
|
||||
tooltip={t('rerankModelTip')}
|
||||
>
|
||||
<Select options={allOptions[LlmModelType.Rerank]} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user