feat: support Xinference (#319)

### What problem does this PR solve?

support xorbitsai inference as model provider

Issue link:#299

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-04-11 18:17:45 +08:00
committed by GitHub
parent 4fa768e733
commit cb2cbf500c
9 changed files with 77 additions and 19 deletions

View File

@ -25,6 +25,7 @@ import {
} from 'antd';
import { useCallback } from 'react';
import SettingTitle from '../components/setting-title';
import { isLocalLlmFactory } from '../utils';
import ApiKeyModal from './api-key-modal';
import {
useSelectModelProvidersLoading,
@ -43,6 +44,7 @@ const IconMap = {
'ZHIPU-AI': 'zhipu',
: 'wenxin',
Ollama: 'ollama',
Xinference: 'xinference',
};
const LlmIcon = ({ name }: { name: string }) => {
@ -89,7 +91,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
<Col span={12} className={styles.factoryOperationWrapper}>
<Space size={'middle'}>
<Button onClick={handleApiKeyClick}>
{item.name === 'Ollama' ? t('addTheModel') : 'API-Key'}
{isLocalLlmFactory(item.name) ? t('addTheModel') : 'API-Key'}
<SettingOutlined />
</Button>
<Button onClick={handleShowMoreClick}>
@ -147,12 +149,13 @@ const UserSettingModel = () => {
showLlmAddingModal,
onLlmAddingOk,
llmAddingLoading,
selectedLlmFactory,
} = useSubmitOllama();
const handleApiKeyClick = useCallback(
(llmFactory: string) => {
if (llmFactory === 'Ollama') {
showLlmAddingModal();
if (isLocalLlmFactory(llmFactory)) {
showLlmAddingModal(llmFactory);
} else {
showApiKeyModal({ llm_factory: llmFactory });
}
@ -161,8 +164,8 @@ const UserSettingModel = () => {
);
const handleAddModel = (llmFactory: string) => () => {
if (llmFactory === 'Ollama') {
showLlmAddingModal();
if (isLocalLlmFactory(llmFactory)) {
showLlmAddingModal(llmFactory);
} else {
handleApiKeyClick(llmFactory);
}
@ -252,6 +255,7 @@ const UserSettingModel = () => {
hideModal={hideLlmAddingModal}
onOk={onLlmAddingOk}
loading={llmAddingLoading}
llmFactory={selectedLlmFactory}
></OllamaModal>
</>
);