mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-03 02:59:07 +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
|
'azure-openai': 'azure', // Azure OpenAI -> azure
|
||||||
'openai-response': 'openai', // OpenAI Responses -> openai
|
'openai-response': 'openai', // OpenAI Responses -> openai
|
||||||
grok: 'xai', // Grok -> xai
|
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',
|
name: 'TokenFlux',
|
||||||
type: 'openai',
|
type: 'openai',
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
apiHost: 'https://tokenflux.ai',
|
apiHost: 'https://api.tokenflux.ai/openai/v1',
|
||||||
|
anthropicApiHost: 'https://api.tokenflux.ai/anthropic',
|
||||||
models: SYSTEM_MODELS.tokenflux,
|
models: SYSTEM_MODELS.tokenflux,
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|||||||
@ -82,7 +82,8 @@ const ANTHROPIC_COMPATIBLE_PROVIDER_IDS = [
|
|||||||
SystemProviderIds.qiniu,
|
SystemProviderIds.qiniu,
|
||||||
SystemProviderIds.dmxapi,
|
SystemProviderIds.dmxapi,
|
||||||
SystemProviderIds.mimo,
|
SystemProviderIds.mimo,
|
||||||
SystemProviderIds.openrouter
|
SystemProviderIds.openrouter,
|
||||||
|
SystemProviderIds.tokenflux
|
||||||
] as const
|
] as const
|
||||||
type AnthropicCompatibleProviderId = (typeof ANTHROPIC_COMPATIBLE_PROVIDER_IDS)[number]
|
type AnthropicCompatibleProviderId = (typeof ANTHROPIC_COMPATIBLE_PROVIDER_IDS)[number]
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 190,
|
version: 191,
|
||||||
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs', 'toolPermissions'],
|
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs', 'toolPermissions'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3129,6 +3129,21 @@ const migrateConfig = {
|
|||||||
logger.error('migrate 190 error', error as Error)
|
logger.error('migrate 190 error', error as Error)
|
||||||
return state
|
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