Deprecate unscoped vectors

df3d7a048edf0d3fb2e45e47d0581ae01726f2ee

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

4 files changed, +11 -57Showing whitespace changes
default/config.yaml+0 -3
@@ -110,9 +110,6 @@ enableExtensionsAutoUpdate: true
110110# Additional model tokenizers can be downloaded on demand.
111111# Disabling will fallback to another locally available tokenizer.
112112enableDownloadableTokenizers: true
113-# Vector storage settings
114-vectors:
115- enableModelScopes: false
116113# Extension settings
117114extras:
118115 # Disables automatic model download from HuggingFace
public/scripts/extensions/vectors/index.js+0 -26
@@ -999,25 +999,6 @@ async function purgeAllVectorIndexes() {
999999 }
10001000}
10011001
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-
10211002function toggleSettings() {
10221003 $('#vectors_files_settings').toggle(!!settings.enabled_files);
10231004 $('#vectors_chats_settings').toggle(!!settings.enabled_chats);
@@ -1282,7 +1263,6 @@ jQuery(async () => {
12821263 }
12831264
12841265 Object.assign(settings, extension_settings.vectors);
1285- const scopesEnabled = await isModelScopesEnabled();
12861266
12871267 // Migrate from TensorFlow to Transformers
12881268 settings.source = settings.source !== 'local' ? settings.source : 'transformers';
@@ -1294,7 +1274,6 @@ jQuery(async () => {
12941274 saveSettingsDebounced();
12951275 toggleSettings();
12961276 });
1297- $('#vectors_modelWarning').hide();
12981277 $('#vectors_enabled_files').prop('checked', settings.enabled_files).on('input', () => {
12991278 settings.enabled_files = $('#vectors_enabled_files').prop('checked');
13001279 Object.assign(extension_settings.vectors, settings);
@@ -1334,31 +1313,26 @@ jQuery(async () => {
13341313 saveSettingsDebounced();
13351314 });
13361315 $('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => {
1337- !scopesEnabled && $('#vectors_modelWarning').show();
13381316 settings.togetherai_model = String($('#vectors_togetherai_model').val());
13391317 Object.assign(extension_settings.vectors, settings);
13401318 saveSettingsDebounced();
13411319 });
13421320 $('#vectors_openai_model').val(settings.openai_model).on('change', () => {
1343- !scopesEnabled && $('#vectors_modelWarning').show();
13441321 settings.openai_model = String($('#vectors_openai_model').val());
13451322 Object.assign(extension_settings.vectors, settings);
13461323 saveSettingsDebounced();
13471324 });
13481325 $('#vectors_cohere_model').val(settings.cohere_model).on('change', () => {
1349- !scopesEnabled && $('#vectors_modelWarning').show();
13501326 settings.cohere_model = String($('#vectors_cohere_model').val());
13511327 Object.assign(extension_settings.vectors, settings);
13521328 saveSettingsDebounced();
13531329 });
13541330 $('#vectors_ollama_model').val(settings.ollama_model).on('input', () => {
1355- !scopesEnabled && $('#vectors_modelWarning').show();
13561331 settings.ollama_model = String($('#vectors_ollama_model').val());
13571332 Object.assign(extension_settings.vectors, settings);
13581333 saveSettingsDebounced();
13591334 });
13601335 $('#vectors_vllm_model').val(settings.vllm_model).on('input', () => {
1361- !scopesEnabled && $('#vectors_modelWarning').show();
13621336 settings.vllm_model = String($('#vectors_vllm_model').val());
13631337 Object.assign(extension_settings.vectors, settings);
13641338 saveSettingsDebounced();
public/scripts/extensions/vectors/settings.html+0 -8
@@ -96,14 +96,6 @@
9696 </i>
9797 </div>
9898
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-
10799 <div class="flex-container alignItemsCenter" id="nomicai_apiKey">
108100 <label for="api_key_nomicai" class="flex1">
109101 <span data-i18n="NomicAI API Key">NomicAI API Key</span>
src/endpoints/vectors.js+11 -20
@@ -4,7 +4,7 @@ const fs = require('fs');
44const express = require('express');
55const sanitize = require('sanitize-filename');
66const { jsonParser } = require('../express-common');
77const { getConfigValue, color } = require('../util');
88
99// Don't forget to add new sources to the SOURCES array
1010const SOURCES = [
@@ -150,7 +150,7 @@ function getSourceSettings(source, request) {
150150 extrasUrl: String(request.headers['x-extras-url']),
151151 extrasKey: String(request.headers['x-extras-key']),
152152 };
153153 case 'localtransformers':
154154 return {
155155 model: getConfigValue('extras.embeddingModel', ''),
156156 };
@@ -159,6 +159,14 @@ function getSourceSettings(source, request) {
159159 // TODO: Add support for multiple models
160160 model: 'text-embedding-004',
161161 };
162+ case 'mistral':
163+ return {
164+ model: 'mistral-embed',
165+ };
166+ case 'nomicai':
167+ return {
168+ model: 'nomic-embed-text-v1.5',
169+ };
162170 default:
163171 return {};
164172 }
@@ -170,19 +178,7 @@ function getSourceSettings(source, request) {
170178 * @returns {string} The model scope for the source
171179 */
172180function 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 || '') : '';
186182}
187183
188184/**
@@ -365,11 +361,6 @@ async function regenerateCorruptedIndexErrorHandler(req, res, error) {
365361
366362const router = express.Router();
367363
368-router.get('/scopes-enabled', (_req, res) => {
369- const scopesEnabled = getConfigValue('vectors.enableModelScopes', false);
370- return res.json({ enabled: scopesEnabled });
371-});
372-
373364router.post('/query', jsonParser, async (req, res) => {
374365 try {
375366 if (!req.body.collectionId || !req.body.searchText) {