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

f362f94c2d56881cffd30c8673a911bdd1b597dc

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +5 -8Showing whitespace changes
public/script.js+4 -2
@@ -9288,10 +9288,12 @@ async function connectAPISlash(args, text) {
92889288 const toast = quiet ? jQuery() : toastr.info(t`API set to ${text}, trying to connect..`);
92899289
92909290 try {
9291- await waitUntilCondition(() => online_status !== 'no_connection', 10000, 100);
9291+ if (connectionRequired) {
9292+ await waitUntilCondition(() => online_status !== 'no_connection', 5000, 500);
9293+ }
92929294 console.log('Connection successful');
92939295 } catch {
92949296 console.log('Could not connect after 105 seconds, skipping.');
92959297 }
92969298
92979299 toastr.clear(toast);
public/scripts/openai.js+1 -6
@@ -3493,7 +3493,7 @@ async function getStatusOpen() {
34933493
34943494 if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM && !isValidUrl(oai_settings.custom_url)) {
34953495 console.debug('Invalid endpoint URL of Custom OpenAI API:', oai_settings.custom_url);
3496- setOnlineStatus('no_connection');
3496+ setOnlineStatus(t`Invalid endpoint URL. Requests may fail.`);
34973497 return resultCheckStatus();
34983498 }
34993499
@@ -4757,11 +4757,6 @@ async function onConnectButtonClick(e) {
47574757 if (api_key_custom.length) {
47584758 await writeSecret(SECRET_KEYS.CUSTOM, api_key_custom);
47594759 }
4760-
4761- if (!oai_settings.custom_url) {
4762- console.log('No API URL saved for Custom');
4763- return;
4764- }
47654760 }
47664761
47674762 if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) {