Decrease connection timeout, set 'valid' status on 'invalid URL', don't wait if not needed Fixes #3683
| @@ -9288,10 +9288,12 @@ async function connectAPISlash(args, text) { | ||
| 9288 | 9288 | const toast = quiet ? jQuery() : toastr.info(t`API set to ${text}, trying to connect..`); |
| 9289 | 9289 | |
| 9290 | 9290 | try { |
| 9291 | - await waitUntilCondition(() => online_status !== 'no_connection', 10000, 100); | |
| 9291 | + if (connectionRequired) { | |
| 9292 | + await waitUntilCondition(() => online_status !== 'no_connection', 5000, 500); | |
| 9293 | + } | |
| 9292 | 9294 | console.log('Connection successful'); |
| 9293 | 9295 | } catch { |
| 9294 | 9296 | console.log('Could not connect after 105 seconds, skipping.'); |
| 9295 | 9297 | } |
| 9296 | 9298 | |
| 9297 | 9299 | toastr.clear(toast); |
| @@ -3493,7 +3493,7 @@ async function getStatusOpen() { | ||
| 3493 | 3493 | |
| 3494 | 3494 | if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM && !isValidUrl(oai_settings.custom_url)) { |
| 3495 | 3495 | 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.`); | |
| 3497 | 3497 | return resultCheckStatus(); |
| 3498 | 3498 | } |
| 3499 | 3499 | |
| @@ -4757,11 +4757,6 @@ async function onConnectButtonClick(e) { | ||
| 4757 | 4757 | if (api_key_custom.length) { |
| 4758 | 4758 | await writeSecret(SECRET_KEYS.CUSTOM, api_key_custom); |
| 4759 | 4759 | } |
| 4760 | - | |
| 4761 | - if (!oai_settings.custom_url) { | |
| 4762 | - console.log('No API URL saved for Custom'); | |
| 4763 | - return; | |
| 4764 | - } | |
| 4765 | 4760 | } |
| 4766 | 4761 | |
| 4767 | 4762 | if (oai_settings.chat_completion_source == chat_completion_sources.COHERE) { |