Files
simstudioai--sim/apps/sim/providers/registry.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

83 lines
2.9 KiB
TypeScript

import { createLogger } from '@sim/logger'
import { getErrorMessage } from '@sim/utils/errors'
import { anthropicProvider } from '@/providers/anthropic'
import { azureAnthropicProvider } from '@/providers/azure-anthropic'
import { azureOpenAIProvider } from '@/providers/azure-openai'
import { basetenProvider } from '@/providers/baseten'
import { bedrockProvider } from '@/providers/bedrock'
import { cerebrasProvider } from '@/providers/cerebras'
import { deepseekProvider } from '@/providers/deepseek'
import { fireworksProvider } from '@/providers/fireworks'
import { googleProvider } from '@/providers/google'
import { groqProvider } from '@/providers/groq'
import { litellmProvider } from '@/providers/litellm'
import { metaProvider } from '@/providers/meta'
import { mistralProvider } from '@/providers/mistral'
import { nvidiaProvider } from '@/providers/nvidia'
import { ollamaProvider } from '@/providers/ollama'
import { ollamaCloudProvider } from '@/providers/ollama-cloud'
import { openaiProvider } from '@/providers/openai'
import { openRouterProvider } from '@/providers/openrouter'
import { sakanaProvider } from '@/providers/sakana'
import { togetherProvider } from '@/providers/together'
import type { ProviderConfig, ProviderId } from '@/providers/types'
import { vertexProvider } from '@/providers/vertex'
import { vllmProvider } from '@/providers/vllm'
import { xAIProvider } from '@/providers/xai'
import { zaiProvider } from '@/providers/zai'
const logger = createLogger('ProviderRegistry')
const providerRegistry: Record<ProviderId, ProviderConfig> = {
openai: openaiProvider,
anthropic: anthropicProvider,
'azure-anthropic': azureAnthropicProvider,
google: googleProvider,
vertex: vertexProvider,
deepseek: deepseekProvider,
xai: xAIProvider,
cerebras: cerebrasProvider,
groq: groqProvider,
sakana: sakanaProvider,
nvidia: nvidiaProvider,
meta: metaProvider,
zai: zaiProvider,
vllm: vllmProvider,
litellm: litellmProvider,
mistral: mistralProvider,
'azure-openai': azureOpenAIProvider,
openrouter: openRouterProvider,
fireworks: fireworksProvider,
together: togetherProvider,
baseten: basetenProvider,
ollama: ollamaProvider,
'ollama-cloud': ollamaCloudProvider,
bedrock: bedrockProvider,
}
export async function getProviderExecutor(
providerId: ProviderId
): Promise<ProviderConfig | undefined> {
const provider = providerRegistry[providerId]
if (!provider) {
logger.error(`Provider not found: ${providerId}`)
return undefined
}
return provider
}
export async function initializeProviders(): Promise<void> {
for (const [id, provider] of Object.entries(providerRegistry)) {
if (provider.initialize) {
try {
await provider.initialize()
logger.info(`Initialized provider: ${id}`)
} catch (error) {
logger.error(`Failed to initialize ${id} provider`, {
error: getErrorMessage(error, 'Unknown error'),
})
}
}
}
}