MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / validateProviderBaseUrl

Function validateProviderBaseUrl

apps/desktop/main/ai/llm/index.ts:401–426  ·  view source on GitHub ↗
(provider: LLMProvider, baseUrl?: string)

Source from the content-addressed store, hash-verified

399}
400
401function validateProviderBaseUrl(provider: LLMProvider, baseUrl?: string): void {
402 if (!baseUrl) return
403
404 const normalized = baseUrl.replace(/\/+$/, '')
405
406 if (provider === 'deepseek') {
407 if (normalized.endsWith('/chat/completions')) {
408 throw new Error('DeepSeek Base URL 请填写到 /v1 层级,不要包含 /chat/completions')
409 }
410 if (!normalized.endsWith('/v1')) {
411 throw new Error('DeepSeek Base URL 需要以 /v1 结尾')
412 }
413 }
414
415 if (provider === 'qwen') {
416 if (normalized.endsWith('/chat/completions')) {
417 throw new Error('通义千问 Base URL 请填写到 /v1 层级,不要包含 /chat/completions')
418 }
419 if (!normalized.endsWith('/v1')) {
420 throw new Error('通义千问 Base URL 需要以 /v1 结尾')
421 }
422 if (normalized.includes('dashscope.aliyuncs.com') && !normalized.includes('/compatible-mode/')) {
423 throw new Error('通义千问 Base URL 需要包含 /compatible-mode/v1')
424 }
425 }
426}
427
428export function getProviderInfo(provider: LLMProvider): ProviderInfo | null {
429 return PROVIDERS.find((p) => p.id === provider) || null

Callers 1

buildPiModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected