Adjusted naming and validation
| @@ -111,7 +111,7 @@ const settings = { | |||
| 111 | const moduleWorker = new ModuleWorkerWrapper(synchronizeChat); | 111 | const moduleWorker = new ModuleWorkerWrapper(synchronizeChat); |
| 112 | const webllmProvider = new WebLlmVectorProvider(); | 112 | const webllmProvider = new WebLlmVectorProvider(); |
| 113 | const cachedSummaries = new Map(); | 113 | const cachedSummaries = new Map(); |
| 114 | const vector_api_requires_url = ['llamacpp', 'vllm', 'ollama', 'koboldcpp']; | 114 | const vectorApiRequiresUrl = ['llamacpp', 'vllm', 'ollama', 'koboldcpp']; |
| 115 | 115 | ||
| 116 | /** | 116 | /** |
| 117 | * Gets the Collection ID for a file embedded in the chat. | 117 | * Gets the Collection ID for a file embedded in the chat. |
| @@ -886,12 +886,19 @@ function throwIfSourceInvalid() { | |||
| 886 | throw new Error('Vectors: API key missing', { cause: 'api_key_missing' }); | 886 | throw new Error('Vectors: API key missing', { cause: 'api_key_missing' }); |
| 887 | } | 887 | } |
| 888 | 888 | ||
| 889 | if (vectorApiRequiresUrl.includes(settings.source) && settings.use_alt_endpoint) { | ||
| 890 | if (!settings.alt_endpoint_url) { | ||
| 891 | throw new Error('Vectors: API URL missing', { cause: 'api_url_missing' }); | ||
| 892 | } | ||
| 893 | } | ||
| 894 | else { | ||
| 889 | if (settings.source === 'ollama' && !textgenerationwebui_settings.server_urls[textgen_types.OLLAMA] || | 895 | if (settings.source === 'ollama' && !textgenerationwebui_settings.server_urls[textgen_types.OLLAMA] || |
| 890 | settings.source === 'vllm' && !textgenerationwebui_settings.server_urls[textgen_types.VLLM] || | 896 | settings.source === 'vllm' && !textgenerationwebui_settings.server_urls[textgen_types.VLLM] || |
| 891 | settings.source === 'koboldcpp' && !textgenerationwebui_settings.server_urls[textgen_types.KOBOLDCPP] || | 897 | settings.source === 'koboldcpp' && !textgenerationwebui_settings.server_urls[textgen_types.KOBOLDCPP] || |
| 892 | settings.source === 'llamacpp' && !textgenerationwebui_settings.server_urls[textgen_types.LLAMACPP]) { | 898 | settings.source === 'llamacpp' && !textgenerationwebui_settings.server_urls[textgen_types.LLAMACPP]) { |
| 893 | throw new Error('Vectors: API URL missing', { cause: 'api_url_missing' }); | 899 | throw new Error('Vectors: API URL missing', { cause: 'api_url_missing' }); |
| 894 | } | 900 | } |
| 901 | } | ||
| 895 | 902 | ||
| 896 | if (settings.source === 'ollama' && !settings.ollama_model || settings.source === 'vllm' && !settings.vllm_model) { | 903 | if (settings.source === 'ollama' && !settings.ollama_model || settings.source === 'vllm' && !settings.vllm_model) { |
| 897 | throw new Error('Vectors: API model missing', { cause: 'api_model_missing' }); | 904 | throw new Error('Vectors: API model missing', { cause: 'api_model_missing' }); |
| @@ -1090,7 +1097,7 @@ function toggleSettings() { | |||
| 1090 | $('#webllm_vectorsModel').toggle(settings.source === 'webllm'); | 1097 | $('#webllm_vectorsModel').toggle(settings.source === 'webllm'); |
| 1091 | $('#koboldcpp_vectorsModel').toggle(settings.source === 'koboldcpp'); | 1098 | $('#koboldcpp_vectorsModel').toggle(settings.source === 'koboldcpp'); |
| 1092 | $('#google_vectorsModel').toggle(settings.source === 'palm'); | 1099 | $('#google_vectorsModel').toggle(settings.source === 'palm'); |
| 1093 | $('#altEndpointUrl').toggle(vector_api_requires_url.includes(settings.source)); | 1100 | $('#vector_altEndpointUrl').toggle(vectorApiRequiresUrl.includes(settings.source)); |
| 1094 | if (settings.source === 'webllm') { | 1101 | if (settings.source === 'webllm') { |
| 1095 | loadWebLlmModels(); | 1102 | loadWebLlmModels(); |
| 1096 | } | 1103 | } |
| @@ -1471,13 +1478,13 @@ jQuery(async () => { | |||
| 1471 | saveSettingsDebounced(); | 1478 | saveSettingsDebounced(); |
| 1472 | toggleSettings(); | 1479 | toggleSettings(); |
| 1473 | }); | 1480 | }); |
| 1474 | $('#altEndpointUrl_enabled').prop('checked', settings.use_alt_endpoint).on('input', () => { | 1481 | $('#vector_altEndpointUrl_enabled').prop('checked', settings.use_alt_endpoint).on('input', () => { |
| 1475 | settings.use_alt_endpoint = $('#altEndpointUrl_enabled').prop('checked'); | 1482 | settings.use_alt_endpoint = $('#vector_altEndpointUrl_enabled').prop('checked'); |
| 1476 | Object.assign(extension_settings.vectors, settings); | 1483 | Object.assign(extension_settings.vectors, settings); |
| 1477 | saveSettingsDebounced(); | 1484 | saveSettingsDebounced(); |
| 1478 | }); | 1485 | }); |
| 1479 | $('#altEndpoint_address').val(settings.alt_endpoint_url).on('change', () => { | 1486 | $('#vector_altEndpoint_address').val(settings.alt_endpoint_url).on('change', () => { |
| 1480 | settings.alt_endpoint_url = String($('#altEndpoint_address').val()); | 1487 | settings.alt_endpoint_url = String($('#vector_altEndpoint_address').val()); |
| 1481 | Object.assign(extension_settings.vectors, settings); | 1488 | Object.assign(extension_settings.vectors, settings); |
| 1482 | saveSettingsDebounced(); | 1489 | saveSettingsDebounced(); |
| 1483 | }); | 1490 | }); |
| @@ -25,15 +25,15 @@ | |||
| 25 | <option value="webllm" data-i18n="WebLLM Extension">WebLLM Extension</option> | 25 | <option value="webllm" data-i18n="WebLLM Extension">WebLLM Extension</option> |
| 26 | </select> | 26 | </select> |
| 27 | </div> | 27 | </div> |
| 28 | <div class="flex-container flexFlowColumn" id="altEndpointUrl"> | 28 | <div class="flex-container flexFlowColumn" id="vector_altEndpointUrl"> |
| 29 | <label class="checkbox_label" for="altEndpointUrl_enabled" title="Enable secondary endpoint URL usage, instead of the main one."> | 29 | <label class="checkbox_label" for="vector_altEndpointUrl_enabled" title="Enable secondary endpoint URL usage, instead of the main one."> |
| 30 | <input id="altEndpointUrl_enabled" type="checkbox" class="checkbox"> | 30 | <input id="vector_altEndpointUrl_enabled" type="checkbox" class="checkbox"> |
| 31 | <span data-i18n="Use secondary URL">Use secondary URL</span> | 31 | <span data-i18n="Use secondary URL">Use secondary URL</span> |
| 32 | </label> | 32 | </label> |
| 33 | <label for="altEndpoint_address" data-i18n="Secondary Embedding endpoint URL"> | 33 | <label for="vector_altEndpoint_address" data-i18n="Secondary Embedding endpoint URL"> |
| 34 | Secondary Embedding endpoint URL | 34 | Secondary Embedding endpoint URL |
| 35 | </label> | 35 | </label> |
| 36 | <input id="altEndpoint_address" class="text_pole" type="text" placeholder="URL for secondary endpoint" /> | 36 | <input id="vector_altEndpoint_address" class="text_pole" type="text" placeholder="URL for secondary endpoint" /> |
| 37 | </div> | 37 | </div> |
| 38 | <div class="flex-container flexFlowColumn" id="webllm_vectorsModel"> | 38 | <div class="flex-container flexFlowColumn" id="webllm_vectorsModel"> |
| 39 | <label for="vectors_webllm_model" data-i18n="Vectorization Model"> | 39 | <label for="vectors_webllm_model" data-i18n="Vectorization Model"> |