refactor(LLM): Reorganize system providers and add provider reordering utility
This commit is contained in:
parent
0250ec6f2e
commit
3791f30d8f
@ -36,7 +36,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 77,
|
version: 78,
|
||||||
blacklist: ['runtime', 'messages'],
|
blacklist: ['runtime', 'messages'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -36,16 +36,6 @@ const initialState: LlmState = {
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: true
|
enabled: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'o3',
|
|
||||||
name: 'O3',
|
|
||||||
type: 'openai',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://api.o3.fan',
|
|
||||||
models: SYSTEM_MODELS.o3,
|
|
||||||
isSystem: true,
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'aihubmix',
|
id: 'aihubmix',
|
||||||
name: 'AiHubMix',
|
name: 'AiHubMix',
|
||||||
@ -57,12 +47,12 @@ const initialState: LlmState = {
|
|||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'deepseek',
|
id: 'o3',
|
||||||
name: 'deepseek',
|
name: 'O3',
|
||||||
type: 'openai',
|
type: 'openai',
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
apiHost: 'https://api.deepseek.com',
|
apiHost: 'https://api.o3.fan',
|
||||||
models: SYSTEM_MODELS.deepseek,
|
models: SYSTEM_MODELS.o3,
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
@ -77,12 +67,22 @@ const initialState: LlmState = {
|
|||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'baidu-cloud',
|
id: 'openrouter',
|
||||||
name: 'Baidu Cloud',
|
name: 'OpenRouter',
|
||||||
type: 'openai',
|
type: 'openai',
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
apiHost: 'https://qianfan.baidubce.com/v2/',
|
apiHost: 'https://openrouter.ai/api/v1/',
|
||||||
models: SYSTEM_MODELS['baidu-cloud'],
|
models: SYSTEM_MODELS.openrouter,
|
||||||
|
isSystem: true,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'deepseek',
|
||||||
|
name: 'deepseek',
|
||||||
|
type: 'openai',
|
||||||
|
apiKey: '',
|
||||||
|
apiHost: 'https://api.deepseek.com',
|
||||||
|
models: SYSTEM_MODELS.deepseek,
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
@ -106,6 +106,36 @@ const initialState: LlmState = {
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'ppio',
|
||||||
|
name: 'PPIO',
|
||||||
|
type: 'openai',
|
||||||
|
apiKey: '',
|
||||||
|
apiHost: 'https://api.ppinfra.com/v3/openai',
|
||||||
|
models: SYSTEM_MODELS.ppio,
|
||||||
|
isSystem: true,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'infini',
|
||||||
|
name: 'Infini',
|
||||||
|
type: 'openai',
|
||||||
|
apiKey: '',
|
||||||
|
apiHost: 'https://cloud.infini-ai.com/maas',
|
||||||
|
models: SYSTEM_MODELS.infini,
|
||||||
|
isSystem: true,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'baidu-cloud',
|
||||||
|
name: 'Baidu Cloud',
|
||||||
|
type: 'openai',
|
||||||
|
apiKey: '',
|
||||||
|
apiHost: 'https://qianfan.baidubce.com/v2/',
|
||||||
|
models: SYSTEM_MODELS['baidu-cloud'],
|
||||||
|
isSystem: true,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'anthropic',
|
id: 'anthropic',
|
||||||
name: 'Anthropic',
|
name: 'Anthropic',
|
||||||
@ -247,16 +277,6 @@ const initialState: LlmState = {
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'openrouter',
|
|
||||||
name: 'OpenRouter',
|
|
||||||
type: 'openai',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://openrouter.ai/api/v1/',
|
|
||||||
models: SYSTEM_MODELS.openrouter,
|
|
||||||
isSystem: true,
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'groq',
|
id: 'groq',
|
||||||
name: 'Groq',
|
name: 'Groq',
|
||||||
@ -367,16 +387,6 @@ const initialState: LlmState = {
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'ppio',
|
|
||||||
name: 'PPIO',
|
|
||||||
type: 'openai',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://api.ppinfra.com/v3/openai',
|
|
||||||
models: SYSTEM_MODELS.ppio,
|
|
||||||
isSystem: true,
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'perplexity',
|
id: 'perplexity',
|
||||||
name: 'Perplexity',
|
name: 'Perplexity',
|
||||||
@ -387,16 +397,6 @@ const initialState: LlmState = {
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'infini',
|
|
||||||
name: 'Infini',
|
|
||||||
type: 'openai',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://cloud.infini-ai.com/maas',
|
|
||||||
models: SYSTEM_MODELS.infini,
|
|
||||||
isSystem: true,
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'modelscope',
|
id: 'modelscope',
|
||||||
name: 'ModelScope',
|
name: 'ModelScope',
|
||||||
@ -467,6 +467,17 @@ const getIntegratedInitialState = () => {
|
|||||||
} as LlmState
|
} as LlmState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const moveProvider = (providers: Provider[], id: string, position: number) => {
|
||||||
|
const index = providers.findIndex((p) => p.id === id)
|
||||||
|
if (index === -1) return providers
|
||||||
|
|
||||||
|
const provider = providers[index]
|
||||||
|
const newProviders = [...providers]
|
||||||
|
newProviders.splice(index, 1)
|
||||||
|
newProviders.splice(position - 1, 0, provider)
|
||||||
|
return newProviders
|
||||||
|
}
|
||||||
|
|
||||||
const settingsSlice = createSlice({
|
const settingsSlice = createSlice({
|
||||||
name: 'llm',
|
name: 'llm',
|
||||||
initialState: isLocalAi ? getIntegratedInitialState() : initialState,
|
initialState: isLocalAi ? getIntegratedInitialState() : initialState,
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { isEmpty } from 'lodash'
|
|||||||
import { createMigrate } from 'redux-persist'
|
import { createMigrate } from 'redux-persist'
|
||||||
|
|
||||||
import { RootState } from '.'
|
import { RootState } from '.'
|
||||||
|
import { moveProvider } from './llm'
|
||||||
import { DEFAULT_SIDEBAR_ICONS } from './settings'
|
import { DEFAULT_SIDEBAR_ICONS } from './settings'
|
||||||
|
|
||||||
// remove logo base64 data to reduce the size of the state
|
// remove logo base64 data to reduce the size of the state
|
||||||
@ -1238,6 +1239,11 @@ const migrateConfig = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return state
|
||||||
|
},
|
||||||
|
'78': (state: RootState) => {
|
||||||
|
state.llm.providers = moveProvider(state.llm.providers, 'ppio', 9)
|
||||||
|
state.llm.providers = moveProvider(state.llm.providers, 'infini', 10)
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user