Decrease connection timeout, set 'valid' status on 'invalid URL', don't wait if not needed

Fixes #3683
This commit is contained in:
Cohee
2025-03-14 10:43:00 +02:00
parent c9e716d42f
commit f362f94c2d
2 changed files with 5 additions and 8 deletions

View File

@ -9288,10 +9288,12 @@ async function connectAPISlash(args, text) {
const toast = quiet ? jQuery() : toastr.info(t`API set to ${text}, trying to connect..`); const toast = quiet ? jQuery() : toastr.info(t`API set to ${text}, trying to connect..`);
try { try {
await waitUntilCondition(() => online_status !== 'no_connection', 10000, 100); if (connectionRequired) {
await waitUntilCondition(() => online_status !== 'no_connection', 5000, 500);
}
console.log('Connection successful'); console.log('Connection successful');
} catch { } catch {
console.log('Could not connect after 10 seconds, skipping.'); console.log('Could not connect after 5 seconds, skipping.');
} }
toastr.clear(toast); toastr.clear(toast);

View File

@ -3493,7 +3493,7 @@ async function getStatusOpen() {
if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM && !isValidUrl(oai_settings.custom_url)) { if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM && !isValidUrl(oai_settings.custom_url)) {
console.debug('Invalid endpoint URL of Custom OpenAI API:', oai_settings.custom_url); console.debug('Invalid endpoint URL of Custom OpenAI API:', oai_settings.custom_url);
setOnlineStatus('no_connection'); setOnlineStatus(t`Invalid endpoint URL. Requests may fail.`);
return resultCheckStatus(); return resultCheckStatus();
} }
@ -4757,11 +4757,6 @@ async function onConnectButtonClick(e) {
if (api_key_custom.length) { if (api_key_custom.length) {
await writeSecret(SECRET_KEYS.CUSTOM, api_key_custom); await writeSecret(SECRET_KEYS.CUSTOM, api_key_custom);
} }
if (!oai_settings.custom_url) {
console.log('No API URL saved for Custom');
return;
}
} }
if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) { if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) {