feat(provider): add AiHubMix provider

This commit is contained in:
kangfenmao 2024-07-20 11:29:24 +08:00
parent 81e66dde0e
commit f2b5ed09c0
9 changed files with 67 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -320,6 +320,22 @@ export const SYSTEM_MODELS: Record<string, SystemModel[]> = {
enabled: true enabled: true
} }
], ],
aihubmix: [
{
id: 'gpt-4o-mini',
provider: 'aihubmix',
name: 'GPT-4o Mini',
group: 'GPT-4o',
enabled: true
},
{
id: 'aihubmix-Llama-3-70B-Instruct',
provider: 'aihubmix',
name: 'Llama 3 70B Instruct',
group: 'Llama3',
enabled: true
}
],
openrouter: [ openrouter: [
{ {
id: 'google/gemma-2-9b-it:free', id: 'google/gemma-2-9b-it:free',

View File

@ -10,6 +10,7 @@ import OpenRouterProviderLogo from '@renderer/assets/images/providers/openrouter
import BaichuanProviderLogo from '@renderer/assets/images/providers/baichuan.png' import BaichuanProviderLogo from '@renderer/assets/images/providers/baichuan.png'
import DashScopeProviderLogo from '@renderer/assets/images/providers/dashscope.png' import DashScopeProviderLogo from '@renderer/assets/images/providers/dashscope.png'
import AnthropicProviderLogo from '@renderer/assets/images/providers/anthropic.jpeg' import AnthropicProviderLogo from '@renderer/assets/images/providers/anthropic.jpeg'
import AiHubMixProviderLogo from '@renderer/assets/images/providers/aihubmix.jpg'
import ChatGPTModelLogo from '@renderer/assets/images/models/chatgpt.jpeg' import ChatGPTModelLogo from '@renderer/assets/images/models/chatgpt.jpeg'
import ChatGLMModelLogo from '@renderer/assets/images/models/chatglm.jpeg' import ChatGLMModelLogo from '@renderer/assets/images/models/chatglm.jpeg'
import DeepSeekModelLogo from '@renderer/assets/images/models/deepseek.png' import DeepSeekModelLogo from '@renderer/assets/images/models/deepseek.png'
@ -49,6 +50,8 @@ export function getProviderLogo(providerId: string) {
return DashScopeProviderLogo return DashScopeProviderLogo
case 'anthropic': case 'anthropic':
return AnthropicProviderLogo return AnthropicProviderLogo
case 'aihubmix':
return AiHubMixProviderLogo
default: default:
return undefined return undefined
} }
@ -175,5 +178,13 @@ export const PROVIDER_CONFIG = {
docs: 'https://docs.anthropic.com/en/docs', docs: 'https://docs.anthropic.com/en/docs',
models: 'https://docs.anthropic.com/en/docs/about-claude/models' models: 'https://docs.anthropic.com/en/docs/about-claude/models'
} }
},
aihubmix: {
websites: {
official: 'https://aihubmix.com/',
apiKey: 'https://aihubmix.com/token',
docs: 'https://doc.aihubmix.com/',
models: 'https://aihubmix.com/models'
}
} }
} }

View File

@ -81,7 +81,8 @@ const resources = {
ollama: 'Ollama', ollama: 'Ollama',
baichuan: 'Baichuan', baichuan: 'Baichuan',
dashscope: 'DashScope', dashscope: 'DashScope',
anthropic: 'Anthropic' anthropic: 'Anthropic',
aihubmix: 'AiHubMix'
}, },
settings: { settings: {
title: 'Settings', title: 'Settings',
@ -202,7 +203,8 @@ const resources = {
ollama: 'Ollama', ollama: 'Ollama',
baichuan: '百川', baichuan: '百川',
dashscope: '阿里云灵积', dashscope: '阿里云灵积',
anthropic: 'Anthropic' anthropic: 'Anthropic',
aihubmix: 'AiHubMix'
}, },
settings: { settings: {
title: '设置', title: '设置',

View File

@ -100,11 +100,11 @@ const ProviderSettings: FC = () => {
key={JSON.stringify(provider)} key={JSON.stringify(provider)}
className={provider.id === selectedProvider?.id ? 'active' : ''} className={provider.id === selectedProvider?.id ? 'active' : ''}
onClick={() => setSelectedProvider(provider)}> onClick={() => setSelectedProvider(provider)}>
{provider.isSystem && <Avatar src={getProviderLogo(provider.id)} size={24} />} {provider.isSystem && <Avatar src={getProviderLogo(provider.id)} size={28} />}
{!provider.isSystem && ( {!provider.isSystem && (
<Avatar <Avatar
size={24} size={28}
style={{ backgroundColor: generateColorFromChar(provider.name), minWidth: 24 }}> style={{ backgroundColor: generateColorFromChar(provider.name), minWidth: 28 }}>
{getFirstCharacter(provider.name)} {getFirstCharacter(provider.name)}
</Avatar> </Avatar>
)} )}
@ -151,7 +151,7 @@ const ProviderListContainer = styled.div`
width: var(--assistants-width); width: var(--assistants-width);
height: calc(100vh - var(--navbar-height)); height: calc(100vh - var(--navbar-height));
border-right: 0.5px solid var(--color-border); border-right: 0.5px solid var(--color-border);
padding: 10px; padding: 10px 8px;
overflow-y: auto; overflow-y: auto;
` `
@ -165,7 +165,7 @@ const ProviderListItem = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding: 6px 10px; padding: 5px 8px;
margin-bottom: 5px; margin-bottom: 5px;
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;

View File

@ -19,7 +19,7 @@ const persistedReducer = persistReducer(
{ {
key: 'cherry-studio', key: 'cherry-studio',
storage, storage,
version: 11, version: 12,
blacklist: ['runtime'], blacklist: ['runtime'],
migrate migrate
}, },

View File

@ -94,6 +94,15 @@ const initialState: LlmState = {
isSystem: true, isSystem: true,
enabled: false enabled: false
}, },
{
id: 'aihubmix',
name: 'AiHubMix',
apiKey: '',
apiHost: 'https://aihubmix.com',
models: SYSTEM_MODELS.aihubmix.filter((m) => m.enabled),
isSystem: true,
enabled: false
},
{ {
id: 'openrouter', id: 'openrouter',
name: 'OpenRouter', name: 'OpenRouter',

View File

@ -207,6 +207,27 @@ const migrate = createMigrate({
] ]
} }
} }
},
// @ts-ignore store type is unknown
'12': (state: RootState) => {
return {
...state,
llm: {
...state.llm,
providers: [
...state.llm.providers,
{
id: 'aihubmix',
name: 'AiHubMix',
apiKey: '',
apiHost: 'https://aihubmix.com',
models: SYSTEM_MODELS.aihubmix.filter((m) => m.enabled),
isSystem: true,
enabled: false
}
]
}
}
} }
}) })