feat: add rerank models to the project #724 #162 (#966)

### 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:
balibabu
2024-05-29 16:19:08 +08:00
committed by GitHub
parent daa4799385
commit a135f9f5b6
15 changed files with 132 additions and 25 deletions

View File

@ -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]);
};

View File

@ -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]);

View File

@ -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

View File

@ -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}>