mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 22:39:36 +08:00
refactor(llm, migrate): reorganize PH8 provider configuration and migration logic
- Moved the PH8 provider configuration within the INITIAL_PROVIDERS array for better structure. - Updated migration logic to ensure the PH8 provider is added and positioned correctly in the state during configuration migration. - Removed redundant code related to provider initialization in the migration process, streamlining the overall logic.
This commit is contained in:
parent
52d6c372ed
commit
7fae55863e
@ -50,8 +50,8 @@ import { default as GoogleModelLogo, default as GoogleModelLogoDark } from '@ren
|
|||||||
import ChatGPT35ModelLogo from '@renderer/assets/images/models/gpt_3.5.png'
|
import ChatGPT35ModelLogo from '@renderer/assets/images/models/gpt_3.5.png'
|
||||||
import ChatGPT4ModelLogo from '@renderer/assets/images/models/gpt_4.png'
|
import ChatGPT4ModelLogo from '@renderer/assets/images/models/gpt_4.png'
|
||||||
import {
|
import {
|
||||||
default as ChatGPT35ModelLogoDark,
|
|
||||||
default as ChatGPT4ModelLogoDark,
|
default as ChatGPT4ModelLogoDark,
|
||||||
|
default as ChatGPT35ModelLogoDark,
|
||||||
default as ChatGptModelLogoDakr,
|
default as ChatGptModelLogoDakr,
|
||||||
default as ChatGPTo1ModelLogoDark
|
default as ChatGPTo1ModelLogoDark
|
||||||
} from '@renderer/assets/images/models/gpt_dark.png'
|
} from '@renderer/assets/images/models/gpt_dark.png'
|
||||||
|
|||||||
@ -1061,7 +1061,7 @@
|
|||||||
"302ai": "302.AI",
|
"302ai": "302.AI",
|
||||||
"lanyun": "蓝耘科技",
|
"lanyun": "蓝耘科技",
|
||||||
"vertexai": "Vertex AI",
|
"vertexai": "Vertex AI",
|
||||||
"ph8": "PH8大模型开放平台"
|
"ph8": "PH8 大模型开放平台"
|
||||||
},
|
},
|
||||||
"restore": {
|
"restore": {
|
||||||
"confirm": "确定要恢复数据吗?",
|
"confirm": "确定要恢复数据吗?",
|
||||||
|
|||||||
@ -1061,7 +1061,7 @@
|
|||||||
"302ai": "302.AI",
|
"302ai": "302.AI",
|
||||||
"lanyun": "藍耘",
|
"lanyun": "藍耘",
|
||||||
"vertexai": "Vertex AI",
|
"vertexai": "Vertex AI",
|
||||||
"ph8": "PH8大模型開放平台"
|
"ph8": "PH8 大模型開放平台"
|
||||||
},
|
},
|
||||||
"restore": {
|
"restore": {
|
||||||
"confirm": "確定要復原資料嗎?",
|
"confirm": "確定要復原資料嗎?",
|
||||||
|
|||||||
@ -144,16 +144,6 @@ export const INITIAL_PROVIDERS: Provider[] = [
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'ph8',
|
|
||||||
name: 'PH8',
|
|
||||||
type: 'openai',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://ph8.co',
|
|
||||||
models: SYSTEM_MODELS.ph8,
|
|
||||||
isSystem: true,
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'cephalon',
|
id: 'cephalon',
|
||||||
name: 'Cephalon',
|
name: 'Cephalon',
|
||||||
@ -174,6 +164,16 @@ export const INITIAL_PROVIDERS: Provider[] = [
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'ph8',
|
||||||
|
name: 'PH8',
|
||||||
|
type: 'openai',
|
||||||
|
apiKey: '',
|
||||||
|
apiHost: 'https://ph8.co',
|
||||||
|
models: SYSTEM_MODELS.ph8,
|
||||||
|
isSystem: true,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'openrouter',
|
id: 'openrouter',
|
||||||
name: 'OpenRouter',
|
name: 'OpenRouter',
|
||||||
|
|||||||
@ -1699,6 +1699,9 @@ const migrateConfig = {
|
|||||||
},
|
},
|
||||||
'118': (state: RootState) => {
|
'118': (state: RootState) => {
|
||||||
try {
|
try {
|
||||||
|
addProvider(state, 'ph8')
|
||||||
|
state.llm.providers = moveProvider(state.llm.providers, 'ph8', 14)
|
||||||
|
|
||||||
if (!state.settings.userId) {
|
if (!state.settings.userId) {
|
||||||
state.settings.userId = uuid()
|
state.settings.userId = uuid()
|
||||||
}
|
}
|
||||||
@ -1709,56 +1712,6 @@ const migrateConfig = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!state.preprocess) {
|
|
||||||
state.preprocess = {
|
|
||||||
defaultProvider: '',
|
|
||||||
providers: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.preprocess.providers.length === 0) {
|
|
||||||
state.preprocess.providers = [
|
|
||||||
{
|
|
||||||
id: 'doc2x',
|
|
||||||
name: 'Doc2x',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://v2.doc2x.noedgeai.com'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'mistral',
|
|
||||||
name: 'Mistral',
|
|
||||||
model: 'mistral-ocr-latest',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://api.mistral.ai'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'mineru',
|
|
||||||
name: 'MinerU',
|
|
||||||
apiKey: '',
|
|
||||||
apiHost: 'https://mineru.net'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!state.ocr.providers.find((provider) => provider.id === 'system')) {
|
|
||||||
state.ocr.providers.push({
|
|
||||||
id: 'system',
|
|
||||||
name: 'System(Mac Only)',
|
|
||||||
options: {
|
|
||||||
recognitionLevel: 0,
|
|
||||||
minConfidence: 0.5
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return state
|
|
||||||
} catch (error) {
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'119': (state: RootState) => {
|
|
||||||
try {
|
|
||||||
addProvider(state, 'ph8')
|
|
||||||
state.llm.providers = moveProvider(state.llm.providers, 'ph8', 3)
|
|
||||||
return state
|
return state
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return state
|
return state
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user