Deprecate unscoped vectors
| @@ -110,9 +110,6 @@ enableExtensionsAutoUpdate: true | ||
| 110 | 110 | # Additional model tokenizers can be downloaded on demand. |
| 111 | 111 | # Disabling will fallback to another locally available tokenizer. |
| 112 | 112 | enableDownloadableTokenizers: true |
| 113 | -# Vector storage settings | |
| 114 | -vectors: | |
| 115 | - enableModelScopes: false | |
| 116 | 113 | # Extension settings |
| 117 | 114 | extras: |
| 118 | 115 | # Disables automatic model download from HuggingFace |
| @@ -999,25 +999,6 @@ async function purgeAllVectorIndexes() { | ||
| 999 | 999 | } |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | -async function isModelScopesEnabled() { | |
| 1003 | - try { | |
| 1004 | - const response = await fetch('/api/vector/scopes-enabled', { | |
| 1005 | - method: 'GET', | |
| 1006 | - headers: getVectorHeaders(), | |
| 1007 | - }); | |
| 1008 | - | |
| 1009 | - if (!response.ok) { | |
| 1010 | - return false; | |
| 1011 | - } | |
| 1012 | - | |
| 1013 | - const data = await response.json(); | |
| 1014 | - return data?.enabled ?? false; | |
| 1015 | - } catch (error) { | |
| 1016 | - console.error('Vectors: Failed to check model scopes', error); | |
| 1017 | - return false; | |
| 1018 | - } | |
| 1019 | -} | |
| 1020 | - | |
| 1021 | 1002 | function toggleSettings() { |
| 1022 | 1003 | $('#vectors_files_settings').toggle(!!settings.enabled_files); |
| 1023 | 1004 | $('#vectors_chats_settings').toggle(!!settings.enabled_chats); |
| @@ -1282,7 +1263,6 @@ jQuery(async () => { | ||
| 1282 | 1263 | } |
| 1283 | 1264 | |
| 1284 | 1265 | Object.assign(settings, extension_settings.vectors); |
| 1285 | - const scopesEnabled = await isModelScopesEnabled(); | |
| 1286 | 1266 | |
| 1287 | 1267 | // Migrate from TensorFlow to Transformers |
| 1288 | 1268 | settings.source = settings.source !== 'local' ? settings.source : 'transformers'; |
| @@ -1294,7 +1274,6 @@ jQuery(async () => { | ||
| 1294 | 1274 | saveSettingsDebounced(); |
| 1295 | 1275 | toggleSettings(); |
| 1296 | 1276 | }); |
| 1297 | - $('#vectors_modelWarning').hide(); | |
| 1298 | 1277 | $('#vectors_enabled_files').prop('checked', settings.enabled_files).on('input', () => { |
| 1299 | 1278 | settings.enabled_files = $('#vectors_enabled_files').prop('checked'); |
| 1300 | 1279 | Object.assign(extension_settings.vectors, settings); |
| @@ -1334,31 +1313,26 @@ jQuery(async () => { | ||
| 1334 | 1313 | saveSettingsDebounced(); |
| 1335 | 1314 | }); |
| 1336 | 1315 | $('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => { |
| 1337 | - !scopesEnabled && $('#vectors_modelWarning').show(); | |
| 1338 | 1316 | settings.togetherai_model = String($('#vectors_togetherai_model').val()); |
| 1339 | 1317 | Object.assign(extension_settings.vectors, settings); |
| 1340 | 1318 | saveSettingsDebounced(); |
| 1341 | 1319 | }); |
| 1342 | 1320 | $('#vectors_openai_model').val(settings.openai_model).on('change', () => { |
| 1343 | - !scopesEnabled && $('#vectors_modelWarning').show(); | |
| 1344 | 1321 | settings.openai_model = String($('#vectors_openai_model').val()); |
| 1345 | 1322 | Object.assign(extension_settings.vectors, settings); |
| 1346 | 1323 | saveSettingsDebounced(); |
| 1347 | 1324 | }); |
| 1348 | 1325 | $('#vectors_cohere_model').val(settings.cohere_model).on('change', () => { |
| 1349 | - !scopesEnabled && $('#vectors_modelWarning').show(); | |
| 1350 | 1326 | settings.cohere_model = String($('#vectors_cohere_model').val()); |
| 1351 | 1327 | Object.assign(extension_settings.vectors, settings); |
| 1352 | 1328 | saveSettingsDebounced(); |
| 1353 | 1329 | }); |
| 1354 | 1330 | $('#vectors_ollama_model').val(settings.ollama_model).on('input', () => { |
| 1355 | - !scopesEnabled && $('#vectors_modelWarning').show(); | |
| 1356 | 1331 | settings.ollama_model = String($('#vectors_ollama_model').val()); |
| 1357 | 1332 | Object.assign(extension_settings.vectors, settings); |
| 1358 | 1333 | saveSettingsDebounced(); |
| 1359 | 1334 | }); |
| 1360 | 1335 | $('#vectors_vllm_model').val(settings.vllm_model).on('input', () => { |
| 1361 | - !scopesEnabled && $('#vectors_modelWarning').show(); | |
| 1362 | 1336 | settings.vllm_model = String($('#vectors_vllm_model').val()); |
| 1363 | 1337 | Object.assign(extension_settings.vectors, settings); |
| 1364 | 1338 | saveSettingsDebounced(); |
| @@ -96,14 +96,6 @@ | ||
| 96 | 96 | </i> |
| 97 | 97 | </div> |
| 98 | 98 | |
| 99 | - <small id="vectors_modelWarning"> | |
| 100 | - <i class="fa-solid fa-exclamation-triangle"></i> | |
| 101 | - <span> | |
| 102 | - Set <code>vectors.enableModelScopes</code> to true in config.yaml to switch between vectorization models without needing to purge existing vectors. | |
| 103 | - This option will soon be enabled by default. | |
| 104 | - </span> | |
| 105 | - </small> | |
| 106 | - | |
| 107 | 99 | <div class="flex-container alignItemsCenter" id="nomicai_apiKey"> |
| 108 | 100 | <label for="api_key_nomicai" class="flex1"> |
| 109 | 101 | <span data-i18n="NomicAI API Key">NomicAI API Key</span> |
| @@ -4,7 +4,7 @@ const fs = require('fs'); | ||
| 4 | 4 | const express = require('express'); |
| 5 | 5 | const sanitize = require('sanitize-filename'); |
| 6 | 6 | const { jsonParser } = require('../express-common'); |
| 7 | 7 | const { getConfigValue, color } = require('../util'); |
| 8 | 8 | |
| 9 | 9 | // Don't forget to add new sources to the SOURCES array |
| 10 | 10 | const SOURCES = [ |
| @@ -150,7 +150,7 @@ function getSourceSettings(source, request) { | ||
| 150 | 150 | extrasUrl: String(request.headers['x-extras-url']), |
| 151 | 151 | extrasKey: String(request.headers['x-extras-key']), |
| 152 | 152 | }; |
| 153 | 153 | case 'localtransformers': |
| 154 | 154 | return { |
| 155 | 155 | model: getConfigValue('extras.embeddingModel', ''), |
| 156 | 156 | }; |
| @@ -159,6 +159,14 @@ function getSourceSettings(source, request) { | ||
| 159 | 159 | // TODO: Add support for multiple models |
| 160 | 160 | model: 'text-embedding-004', |
| 161 | 161 | }; |
| 162 | + case 'mistral': | |
| 163 | + return { | |
| 164 | + model: 'mistral-embed', | |
| 165 | + }; | |
| 166 | + case 'nomicai': | |
| 167 | + return { | |
| 168 | + model: 'nomic-embed-text-v1.5', | |
| 169 | + }; | |
| 162 | 170 | default: |
| 163 | 171 | return {}; |
| 164 | 172 | } |
| @@ -170,19 +178,7 @@ function getSourceSettings(source, request) { | ||
| 170 | 178 | * @returns {string} The model scope for the source |
| 171 | 179 | */ |
| 172 | 180 | function getModelScope(sourceSettings) { |
| 173 | - const scopesEnabled = getConfigValue('vectors.enableModelScopes', false); | |
| 181 | + return (sourceSettings?.model || ''); | |
| 174 | - const warningShown = global.process.env.VECTORS_MODEL_SCOPE_WARNING_SHOWN === 'true'; | |
| 175 | - | |
| 176 | - if (!scopesEnabled && !warningShown) { | |
| 177 | - console.log(); | |
| 178 | - console.warn(color.red('[DEPRECATION NOTICE]'), 'Model scopes for Vectore Storage are disabled, but will soon be required.'); | |
| 179 | - console.log(`To enable model scopes, set the ${color.cyan('vectors.enableModelScopes')} in config.yaml to ${color.green(true)}.`); | |
| 180 | - console.log('This message won\'t be shown again in the current session.'); | |
| 181 | - console.log(); | |
| 182 | - global.process.env.VECTORS_MODEL_SCOPE_WARNING_SHOWN = 'true'; | |
| 183 | - } | |
| 184 | - | |
| 185 | - return scopesEnabled ? (sourceSettings?.model || '') : ''; | |
| 186 | 182 | } |
| 187 | 183 | |
| 188 | 184 | /** |
| @@ -365,11 +361,6 @@ async function regenerateCorruptedIndexErrorHandler(req, res, error) { | ||
| 365 | 361 | |
| 366 | 362 | const router = express.Router(); |
| 367 | 363 | |
| 368 | -router.get('/scopes-enabled', (_req, res) => { | |
| 369 | - const scopesEnabled = getConfigValue('vectors.enableModelScopes', false); | |
| 370 | - return res.json({ enabled: scopesEnabled }); | |
| 371 | -}); | |
| 372 | - | |
| 373 | 364 | router.post('/query', jsonParser, async (req, res) => { |
| 374 | 365 | try { |
| 375 | 366 | if (!req.body.collectionId || !req.body.searchText) { |