perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
@@ -10,6 +10,7 @@ const OPENAI_COMPAT = new Set<string>([
|
||||
'glm',
|
||||
'custom',
|
||||
'lmstudio',
|
||||
'custom_openai',
|
||||
]);
|
||||
|
||||
async function validateOpenAiCompatible(
|
||||
@@ -25,8 +26,14 @@ async function validateOpenAiCompatible(
|
||||
}
|
||||
}
|
||||
|
||||
async function validateAnthropic(apiKey: string): Promise<void> {
|
||||
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
||||
async function validateAnthropic(
|
||||
apiKey: string,
|
||||
baseUrl?: string,
|
||||
): Promise<void> {
|
||||
const url = baseUrl
|
||||
? `${baseUrl.replace(/\/$/, '')}/messages`
|
||||
: 'https://api.anthropic.com/v1/messages';
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-api-key': apiKey,
|
||||
@@ -83,8 +90,12 @@ export async function validateProviderApiKey(
|
||||
return;
|
||||
}
|
||||
|
||||
if (provider === 'anthropic' || provider === 'anthropic_custom') {
|
||||
await validateAnthropic(apiKey);
|
||||
if (
|
||||
provider === 'anthropic' ||
|
||||
provider === 'anthropic_custom' ||
|
||||
provider === 'custom_anthropic'
|
||||
) {
|
||||
await validateAnthropic(apiKey, baseUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,12 +104,18 @@ export async function validateProviderApiKey(
|
||||
return;
|
||||
}
|
||||
|
||||
if (provider === 'minimax') {
|
||||
// MiniMax does not expose a public /models endpoint. Key is valid if not empty.
|
||||
if (!apiKey.trim()) throw new Error('API key is required');
|
||||
return;
|
||||
}
|
||||
|
||||
if (provider === 'ollama' || provider === 'lmstudio') {
|
||||
throw new Error('Local providers are not supported for BYOK');
|
||||
}
|
||||
|
||||
if (OPENAI_COMPAT.has(provider)) {
|
||||
const url = provider === 'custom'
|
||||
const url = (provider === 'custom' || provider === 'custom_openai')
|
||||
? baseUrl
|
||||
: BASE_URLS[provider as AiGatewayProvider];
|
||||
if (!url) {
|
||||
|
||||
Reference in New Issue
Block a user