Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/client/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,30 @@ export const API_PROVIDER_HTTP_ERROR_LINKS: Readonly<
labelKey: 'error.action.createApiKey',
url: EXTERNAL_URLS.deepseek.apiKeys,
},
novita: {
labelKey: 'error.action.createApiKey',
url: EXTERNAL_URLS.novita.apiKeys,
},
},
402: {
deepseek: {
labelKey: 'error.action.viewUsage',
url: EXTERNAL_URLS.deepseek.usage,
},
novita: {
labelKey: 'error.action.viewUsage',
url: EXTERNAL_URLS.novita.usage,
},
},
'5xx': {
deepseek: {
labelKey: 'error.action.checkDeepSeekStatus',
url: EXTERNAL_URLS.deepseek.status,
},
novita: {
labelKey: 'error.action.checkNovitaStatus',
url: EXTERNAL_URLS.novita.status,
},
},
};

Expand Down
10 changes: 8 additions & 2 deletions src/client/error/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isOfficialDeepSeekBaseUrl } from '../../endpoint';
import { isNovitaBaseUrl, isOfficialDeepSeekBaseUrl } from '../../endpoint';
import { t } from '../../i18n';
import { safeStringify } from '../../json';
import { API_PROVIDER_HTTP_ERROR_LINKS, MAX_DIAGNOSTIC_FIELD_LENGTH } from '../consts';
Expand Down Expand Up @@ -319,7 +319,13 @@ function escapeBoldText(value: string): string {
}

function identifyApiProvider(baseUrl: string): ApiProviderId | undefined {
return isOfficialDeepSeekBaseUrl(baseUrl) ? 'deepseek' : undefined;
if (isOfficialDeepSeekBaseUrl(baseUrl)) {
return 'deepseek';
}
if (isNovitaBaseUrl(baseUrl)) {
return 'novita';
}
return undefined;
}

function getHttpErrorLinkStatusKey(status: number): HttpErrorLinkStatusKey | undefined {
Expand Down
2 changes: 1 addition & 1 deletion src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface HttpErrorLinkDefinition {
url: string;
}

export type ApiProviderId = 'deepseek';
export type ApiProviderId = 'deepseek' | 'novita';
export type HttpErrorLinkStatusKey = 401 | 402 | '5xx';

export type DeepSeekRequestErrorKind = 'http' | 'network' | 'unknown';
Expand Down
5 changes: 5 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const EXTERNAL_URLS = {
usage: 'https://platform.deepseek.com/usage',
status: 'https://status.deepseek.com',
},
novita: {
apiKeys: 'https://novita.ai/settings/key-management',
usage: 'https://novita.ai/billing',
status: 'https://status.novita.ai',
},
} as const;

/** URI path handled by this extension to reveal the output log. */
Expand Down
13 changes: 11 additions & 2 deletions src/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
export const OFFICIAL_DEEPSEEK_API_HOST = 'api.deepseek.com';
export const NOVITA_API_HOST = 'api.novita.ai';

export function isOfficialDeepSeekBaseUrl(baseUrl: string): boolean {
return getBaseUrlHostname(baseUrl) === OFFICIAL_DEEPSEEK_API_HOST;
}

export function isNovitaBaseUrl(baseUrl: string): boolean {
return getBaseUrlHostname(baseUrl) === NOVITA_API_HOST;
}

function getBaseUrlHostname(baseUrl: string): string | undefined {
try {
return new URL(baseUrl).hostname.toLowerCase() === OFFICIAL_DEEPSEEK_API_HOST;
return new URL(baseUrl).hostname.toLowerCase();
} catch {
return false;
return undefined;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const zh: Translations = {
'error.action.createApiKey': '创建 API Key',
'error.action.viewUsage': '用量',
'error.action.checkDeepSeekStatus': 'DeepSeek 状态',
'error.action.checkNovitaStatus': 'Novita 状态',
'error.action.viewDetails': '错误详情',
'error.network.dns': '[{0}] DNS 解析失败。请检查网络连接、防火墙或代理设置,以及自定义 baseUrl。',
'error.network.unreachable':
Expand Down Expand Up @@ -396,6 +397,7 @@ const en: Translations = {
'error.action.createApiKey': 'Create API Key',
'error.action.viewUsage': 'Usage',
'error.action.checkDeepSeekStatus': 'DeepSeek Status',
'error.action.checkNovitaStatus': 'Novita Status',
'error.action.viewDetails': 'Error Details',
'error.network.dns':
'[{0}] DNS lookup failed. Check your network connection, firewall, or proxy settings, and your custom baseUrl.',
Expand Down