diff --git a/src/renderer/src/config/models/default.ts b/src/renderer/src/config/models/default.ts index 02bf37af9e..9fdced6a6a 100644 --- a/src/renderer/src/config/models/default.ts +++ b/src/renderer/src/config/models/default.ts @@ -25,7 +25,7 @@ export const SYSTEM_MODELS: Record = // Default quick assistant model glm45FlashModel ], - cherryin: [], + // cherryin: [], vertexai: [], '302ai': [ { diff --git a/src/renderer/src/config/providers.ts b/src/renderer/src/config/providers.ts index 3b8821905a..543422d212 100644 --- a/src/renderer/src/config/providers.ts +++ b/src/renderer/src/config/providers.ts @@ -78,16 +78,16 @@ export const CHERRYAI_PROVIDER: SystemProvider = { } export const SYSTEM_PROVIDERS_CONFIG: Record = { - cherryin: { - id: 'cherryin', - name: 'CherryIN', - type: 'openai', - apiKey: '', - apiHost: 'https://open.cherryin.ai', - models: [], - isSystem: true, - enabled: true - }, + // cherryin: { + // id: 'cherryin', + // name: 'CherryIN', + // type: 'openai', + // apiKey: '', + // apiHost: 'https://open.cherryin.ai', + // models: [], + // isSystem: true, + // enabled: true + // }, silicon: { id: 'silicon', name: 'Silicon', @@ -708,17 +708,17 @@ type ProviderUrls = { } export const PROVIDER_URLS: Record = { - cherryin: { - api: { - url: 'https://open.cherryin.ai' - }, - websites: { - official: 'https://open.cherryin.ai', - apiKey: 'https://open.cherryin.ai/console/token', - docs: 'https://open.cherryin.ai', - models: 'https://open.cherryin.ai/pricing' - } - }, + // cherryin: { + // api: { + // url: 'https://open.cherryin.ai' + // }, + // websites: { + // official: 'https://open.cherryin.ai', + // apiKey: 'https://open.cherryin.ai/console/token', + // docs: 'https://open.cherryin.ai', + // models: 'https://open.cherryin.ai/pricing' + // } + // }, ph8: { api: { url: 'https://ph8.co' diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index e5f07c4ace..80ee26d7c4 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -2544,6 +2544,15 @@ const migrateConfig = { } }, '158': (state: RootState) => { + try { + state.llm.providers = state.llm.providers.filter((provider) => provider.id !== 'cherryin') + return state + } catch (error) { + logger.error('migrate 158 error', error as Error) + return state + } + }, + '159': (state: RootState) => { try { // @ts-ignore if (state?.agents?.agents) { diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index c93c517b0a..49a86cee9b 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -223,6 +223,159 @@ export type User = { email: string } +// undefined 视为支持,默认支持 +export type ProviderApiOptions = { + /** 是否不支持 message 的 content 为数组类型 */ + isNotSupportArrayContent?: boolean + /** 是否不支持 stream_options 参数 */ + isNotSupportStreamOptions?: boolean + /** + * @deprecated + * 是否不支持 message 的 role 为 developer */ + isNotSupportDeveloperRole?: boolean + /* 是否支持 message 的 role 为 developer */ + isSupportDeveloperRole?: boolean + /** + * @deprecated + * 是否不支持 service_tier 参数. Only for OpenAI Models. */ + isNotSupportServiceTier?: boolean + /* 是否支持 service_tier 参数. Only for OpenAI Models. */ + isSupportServiceTier?: boolean + /** 是否不支持 enable_thinking 参数 */ + isNotSupportEnableThinking?: boolean +} + +export type Provider = { + id: string + type: ProviderType + name: string + apiKey: string + apiHost: string + apiVersion?: string + models: Model[] + enabled?: boolean + isSystem?: boolean + isAuthed?: boolean + rateLimit?: number + + // API options + apiOptions?: ProviderApiOptions + serviceTier?: ServiceTier + + /** @deprecated */ + isNotSupportArrayContent?: boolean + /** @deprecated */ + isNotSupportStreamOptions?: boolean + /** @deprecated */ + isNotSupportDeveloperRole?: boolean + /** @deprecated */ + isNotSupportServiceTier?: boolean + + authType?: 'apiKey' | 'oauth' + isVertex?: boolean + notes?: string + extra_headers?: Record +} + +export const SystemProviderIds = { + // cherryin: 'cherryin', + silicon: 'silicon', + aihubmix: 'aihubmix', + ocoolai: 'ocoolai', + deepseek: 'deepseek', + ppio: 'ppio', + alayanew: 'alayanew', + qiniu: 'qiniu', + dmxapi: 'dmxapi', + burncloud: 'burncloud', + tokenflux: 'tokenflux', + '302ai': '302ai', + cephalon: 'cephalon', + lanyun: 'lanyun', + ph8: 'ph8', + openrouter: 'openrouter', + ollama: 'ollama', + 'new-api': 'new-api', + lmstudio: 'lmstudio', + anthropic: 'anthropic', + openai: 'openai', + 'azure-openai': 'azure-openai', + gemini: 'gemini', + vertexai: 'vertexai', + github: 'github', + copilot: 'copilot', + zhipu: 'zhipu', + yi: 'yi', + moonshot: 'moonshot', + baichuan: 'baichuan', + dashscope: 'dashscope', + stepfun: 'stepfun', + doubao: 'doubao', + infini: 'infini', + minimax: 'minimax', + groq: 'groq', + together: 'together', + fireworks: 'fireworks', + nvidia: 'nvidia', + grok: 'grok', + hyperbolic: 'hyperbolic', + mistral: 'mistral', + jina: 'jina', + perplexity: 'perplexity', + modelscope: 'modelscope', + xirang: 'xirang', + hunyuan: 'hunyuan', + 'tencent-cloud-ti': 'tencent-cloud-ti', + 'baidu-cloud': 'baidu-cloud', + gpustack: 'gpustack', + voyageai: 'voyageai', + 'aws-bedrock': 'aws-bedrock', + poe: 'poe', + aionly: 'aionly' +} as const + +export type SystemProviderId = keyof typeof SystemProviderIds + +export const isSystemProviderId = (id: string): id is SystemProviderId => { + return Object.hasOwn(SystemProviderIds, id) +} + +export type SystemProvider = Provider & { + id: SystemProviderId + isSystem: true + apiOptions?: never +} + +export type VertexProvider = Provider & { + googleCredentials: { + privateKey: string + clientEmail: string + } + project: string + location: string +} + +/** + * 判断是否为系统内置的提供商。比直接使用`provider.isSystem`更好,因为该数据字段不会随着版本更新而变化。 + * @param provider - Provider对象,包含提供商的信息 + * @returns 是否为系统内置提供商 + */ +export const isSystemProvider = (provider: Provider): provider is SystemProvider => { + return isSystemProviderId(provider.id) && !!provider.isSystem +} + +export type ProviderType = + | 'openai' + | 'openai-response' + | 'anthropic' + | 'gemini' + | 'qwenlm' + | 'azure-openai' + | 'vertexai' + | 'mistral' + | 'aws-bedrock' + | 'vertex-anthropic' + export type ModelType = 'text' | 'vision' | 'embedding' | 'reasoning' | 'function_calling' | 'web_search' | 'rerank' export type ModelTag = Exclude | 'free'