mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-20 12:56:55 +08:00
add support for Tencent Hunyuan (#2015)
### What problem does this PR solve? #1853 ### Type of change - [X] New Feature (non-breaking change which adds functionality) Co-authored-by: Zhedong Cen <cenzhedong2@126.com>
This commit is contained in:
@ -30,8 +30,9 @@ export const IconMap = {
|
||||
Upstage: 'upstage',
|
||||
'novita.ai': 'novita-ai',
|
||||
SILICONFLOW: 'siliconflow',
|
||||
"01.AI": 'yi',
|
||||
"Replicate": 'replicate'
|
||||
'01.AI': 'yi',
|
||||
Replicate: 'replicate',
|
||||
'Tencent Hunyuan': 'hunyuan',
|
||||
};
|
||||
|
||||
export const BedrockRegionList = [
|
||||
|
||||
@ -163,6 +163,33 @@ export const useSubmitVolcEngine = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useSubmitHunyuan = () => {
|
||||
const { addLlm, loading } = useAddLlm();
|
||||
const {
|
||||
visible: HunyuanAddingVisible,
|
||||
hideModal: hideHunyuanAddingModal,
|
||||
showModal: showHunyuanAddingModal,
|
||||
} = useSetModalState();
|
||||
|
||||
const onHunyuanAddingOk = useCallback(
|
||||
async (payload: IAddLlmRequestBody) => {
|
||||
const ret = await addLlm(payload);
|
||||
if (ret === 0) {
|
||||
hideHunyuanAddingModal();
|
||||
}
|
||||
},
|
||||
[hideHunyuanAddingModal, addLlm],
|
||||
);
|
||||
|
||||
return {
|
||||
HunyuanAddingLoading: loading,
|
||||
onHunyuanAddingOk,
|
||||
HunyuanAddingVisible,
|
||||
hideHunyuanAddingModal,
|
||||
showHunyuanAddingModal,
|
||||
};
|
||||
};
|
||||
|
||||
export const useSubmitBedrock = () => {
|
||||
const { addLlm, loading } = useAddLlm();
|
||||
const {
|
||||
|
||||
@ -0,0 +1,78 @@
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { IModalProps } from '@/interfaces/common';
|
||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import { Form, Input, Modal, Select } from 'antd';
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
type FieldType = IAddLlmRequestBody & {
|
||||
vision: boolean;
|
||||
hunyuan_sid: string;
|
||||
hunyuan_sk: string;
|
||||
};
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
const HunyuanModal = ({
|
||||
visible,
|
||||
hideModal,
|
||||
onOk,
|
||||
loading,
|
||||
llmFactory,
|
||||
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
||||
const [form] = Form.useForm<FieldType>();
|
||||
|
||||
const { t } = useTranslate('setting');
|
||||
|
||||
const handleOk = async () => {
|
||||
const values = await form.validateFields();
|
||||
const modelType =
|
||||
values.model_type === 'chat' && values.vision
|
||||
? 'image2text'
|
||||
: values.model_type;
|
||||
|
||||
const data = {
|
||||
...omit(values, ['vision']),
|
||||
model_type: modelType,
|
||||
llm_factory: llmFactory,
|
||||
};
|
||||
console.info(data);
|
||||
|
||||
onOk?.(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('addLlmTitle', { name: llmFactory })}
|
||||
open={visible}
|
||||
onOk={handleOk}
|
||||
onCancel={hideModal}
|
||||
okButtonProps={{ loading }}
|
||||
confirmLoading={loading}
|
||||
>
|
||||
<Form
|
||||
name="basic"
|
||||
style={{ maxWidth: 600 }}
|
||||
autoComplete="off"
|
||||
layout={'vertical'}
|
||||
form={form}
|
||||
>
|
||||
<Form.Item<FieldType>
|
||||
label={t('addHunyuanSID')}
|
||||
name="hunyuan_sid"
|
||||
rules={[{ required: true, message: t('HunyuanSIDMessage') }]}
|
||||
>
|
||||
<Input placeholder={t('HunyuanSIDMessage')} />
|
||||
</Form.Item>
|
||||
<Form.Item<FieldType>
|
||||
label={t('addHunyuanSK')}
|
||||
name="hunyuan_sk"
|
||||
rules={[{ required: true, message: t('HunyuanSKMessage') }]}
|
||||
>
|
||||
<Input placeholder={t('HunyuanSKMessage')} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default HunyuanModal;
|
||||
@ -34,10 +34,12 @@ import {
|
||||
useHandleDeleteLlm,
|
||||
useSubmitApiKey,
|
||||
useSubmitBedrock,
|
||||
useSubmitHunyuan,
|
||||
useSubmitOllama,
|
||||
useSubmitSystemModelSetting,
|
||||
useSubmitVolcEngine,
|
||||
} from './hooks';
|
||||
import HunyuanModal from './hunyuan-modal';
|
||||
import styles from './index.less';
|
||||
import OllamaModal from './ollama-modal';
|
||||
import SystemModelSettingModal from './system-model-setting-modal';
|
||||
@ -88,7 +90,9 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
||||
<Col span={12} className={styles.factoryOperationWrapper}>
|
||||
<Space size={'middle'}>
|
||||
<Button onClick={handleApiKeyClick}>
|
||||
{isLocalLlmFactory(item.name) || item.name === 'VolcEngine'
|
||||
{isLocalLlmFactory(item.name) ||
|
||||
item.name === 'VolcEngine' ||
|
||||
item.name === 'Tencent Hunyuan'
|
||||
? t('addTheModel')
|
||||
: 'API-Key'}
|
||||
<SettingOutlined />
|
||||
@ -162,6 +166,14 @@ const UserSettingModel = () => {
|
||||
volcAddingLoading,
|
||||
} = useSubmitVolcEngine();
|
||||
|
||||
const {
|
||||
HunyuanAddingVisible,
|
||||
hideHunyuanAddingModal,
|
||||
showHunyuanAddingModal,
|
||||
onHunyuanAddingOk,
|
||||
HunyuanAddingLoading,
|
||||
} = useSubmitHunyuan();
|
||||
|
||||
const {
|
||||
bedrockAddingLoading,
|
||||
onBedrockAddingOk,
|
||||
@ -174,8 +186,9 @@ const UserSettingModel = () => {
|
||||
() => ({
|
||||
Bedrock: showBedrockAddingModal,
|
||||
VolcEngine: showVolcAddingModal,
|
||||
'Tencent Hunyuan': showHunyuanAddingModal,
|
||||
}),
|
||||
[showBedrockAddingModal, showVolcAddingModal],
|
||||
[showBedrockAddingModal, showVolcAddingModal, showHunyuanAddingModal],
|
||||
);
|
||||
|
||||
const handleAddModel = useCallback(
|
||||
@ -286,6 +299,13 @@ const UserSettingModel = () => {
|
||||
loading={volcAddingLoading}
|
||||
llmFactory={'VolcEngine'}
|
||||
></VolcEngineModal>
|
||||
<HunyuanModal
|
||||
visible={HunyuanAddingVisible}
|
||||
hideModal={hideHunyuanAddingModal}
|
||||
onOk={onHunyuanAddingOk}
|
||||
loading={HunyuanAddingLoading}
|
||||
llmFactory={'Tencent Hunyuan'}
|
||||
></HunyuanModal>
|
||||
<BedrockModal
|
||||
visible={bedrockAddingVisible}
|
||||
hideModal={hideBedrockAddingModal}
|
||||
|
||||
Reference in New Issue
Block a user