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:
kangfenmao 2025-07-03 23:22:35 +08:00
parent 52d6c372ed
commit 7fae55863e
5 changed files with 16 additions and 63 deletions

View File

@ -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 ChatGPT4ModelLogo from '@renderer/assets/images/models/gpt_4.png'
import {
default as ChatGPT35ModelLogoDark,
default as ChatGPT4ModelLogoDark,
default as ChatGPT35ModelLogoDark,
default as ChatGptModelLogoDakr,
default as ChatGPTo1ModelLogoDark
} from '@renderer/assets/images/models/gpt_dark.png'

View File

@ -1061,7 +1061,7 @@
"302ai": "302.AI",
"lanyun": "蓝耘科技",
"vertexai": "Vertex AI",
"ph8": "PH8大模型开放平台"
"ph8": "PH8 大模型开放平台"
},
"restore": {
"confirm": "确定要恢复数据吗?",

View File

@ -1061,7 +1061,7 @@
"302ai": "302.AI",
"lanyun": "藍耘",
"vertexai": "Vertex AI",
"ph8": "PH8大模型開放平台"
"ph8": "PH8 大模型開放平台"
},
"restore": {
"confirm": "確定要復原資料嗎?",

View File

@ -144,16 +144,6 @@ export const INITIAL_PROVIDERS: Provider[] = [
isSystem: true,
enabled: false
},
{
id: 'ph8',
name: 'PH8',
type: 'openai',
apiKey: '',
apiHost: 'https://ph8.co',
models: SYSTEM_MODELS.ph8,
isSystem: true,
enabled: false
},
{
id: 'cephalon',
name: 'Cephalon',
@ -174,6 +164,16 @@ export const INITIAL_PROVIDERS: Provider[] = [
isSystem: true,
enabled: false
},
{
id: 'ph8',
name: 'PH8',
type: 'openai',
apiKey: '',
apiHost: 'https://ph8.co',
models: SYSTEM_MODELS.ph8,
isSystem: true,
enabled: false
},
{
id: 'openrouter',
name: 'OpenRouter',

View File

@ -1699,6 +1699,9 @@ const migrateConfig = {
},
'118': (state: RootState) => {
try {
addProvider(state, 'ph8')
state.llm.providers = moveProvider(state.llm.providers, 'ph8', 14)
if (!state.settings.userId) {
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
} catch (error) {
return state