mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-30 15:59:09 +08:00
feat(tokenflux): add Anthropic host support using OpenRouter package (#12188)
* feat(tokenflux): add Anthropic host support using OpenRouter package - Add anthropicApiHost to TokenFlux provider config - Map TokenFlux to OpenRouter in STATIC_PROVIDER_MAPPING for full compatibility * feat(tokenflux): update API URLs and add migration - Update apiHost to https://api.tokenflux.ai/openai/v1 - Update anthropicApiHost to https://api.tokenflux.ai/anthropic - Add migration 191 to update existing TokenFlux users * fix(tokenflux): add to Anthropic compatible providers list Enable Anthropic API host configuration in TokenFlux provider settings UI
This commit is contained in:
parent
cccf9bb7be
commit
efbe64e5da
@ -31,7 +31,8 @@ const STATIC_PROVIDER_MAPPING: Record<string, ProviderId> = {
|
||||
'azure-openai': 'azure', // Azure OpenAI -> azure
|
||||
'openai-response': 'openai', // OpenAI Responses -> openai
|
||||
grok: 'xai', // Grok -> xai
|
||||
copilot: 'github-copilot-openai-compatible'
|
||||
copilot: 'github-copilot-openai-compatible',
|
||||
tokenflux: 'openrouter' // TokenFlux -> openrouter (fully compatible)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -200,7 +200,8 @@ export const SYSTEM_PROVIDERS_CONFIG: Record<SystemProviderId, SystemProvider> =
|
||||
name: 'TokenFlux',
|
||||
type: 'openai',
|
||||
apiKey: '',
|
||||
apiHost: 'https://tokenflux.ai',
|
||||
apiHost: 'https://api.tokenflux.ai/openai/v1',
|
||||
anthropicApiHost: 'https://api.tokenflux.ai/anthropic',
|
||||
models: SYSTEM_MODELS.tokenflux,
|
||||
isSystem: true,
|
||||
enabled: false
|
||||
|
||||
@ -82,7 +82,8 @@ const ANTHROPIC_COMPATIBLE_PROVIDER_IDS = [
|
||||
SystemProviderIds.qiniu,
|
||||
SystemProviderIds.dmxapi,
|
||||
SystemProviderIds.mimo,
|
||||
SystemProviderIds.openrouter
|
||||
SystemProviderIds.openrouter,
|
||||
SystemProviderIds.tokenflux
|
||||
] as const
|
||||
type AnthropicCompatibleProviderId = (typeof ANTHROPIC_COMPATIBLE_PROVIDER_IDS)[number]
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ const persistedReducer = persistReducer(
|
||||
{
|
||||
key: 'cherry-studio',
|
||||
storage,
|
||||
version: 190,
|
||||
version: 191,
|
||||
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs', 'toolPermissions'],
|
||||
migrate
|
||||
},
|
||||
|
||||
@ -3129,6 +3129,21 @@ const migrateConfig = {
|
||||
logger.error('migrate 190 error', error as Error)
|
||||
return state
|
||||
}
|
||||
},
|
||||
'191': (state: RootState) => {
|
||||
try {
|
||||
state.llm.providers.forEach((provider) => {
|
||||
if (provider.id === 'tokenflux') {
|
||||
provider.apiHost = 'https://api.tokenflux.ai/openai/v1'
|
||||
provider.anthropicApiHost = 'https://api.tokenflux.ai/anthropic'
|
||||
}
|
||||
})
|
||||
logger.info('migrate 191 success')
|
||||
return state
|
||||
} catch (error) {
|
||||
logger.error('migrate 191 error', error as Error)
|
||||
return state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user