mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 09:26:33 +01:00
Refactor vector models code
This commit is contained in:
parent
adfb9c5097
commit
b490978142
@ -12,7 +12,7 @@ const settings = {
|
|||||||
// For both
|
// For both
|
||||||
source: 'transformers',
|
source: 'transformers',
|
||||||
include_wi: false,
|
include_wi: false,
|
||||||
model: 'togethercomputer/m2-bert-80M-32k-retrieval',
|
togetherai_model: 'togethercomputer/m2-bert-80M-32k-retrieval',
|
||||||
|
|
||||||
// For chats
|
// For chats
|
||||||
enabled_chats: false,
|
enabled_chats: false,
|
||||||
@ -447,11 +447,10 @@ function addExtrasHeaders(headers) {
|
|||||||
*/
|
*/
|
||||||
function addTogetherAiHeaders(headers) {
|
function addTogetherAiHeaders(headers) {
|
||||||
Object.assign(headers, {
|
Object.assign(headers, {
|
||||||
'X-Togetherai-Model': extension_settings.vectors.model,
|
'X-Togetherai-Model': extension_settings.vectors.togetherai_model,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts vector items into a collection
|
* Inserts vector items into a collection
|
||||||
* @param {string} collectionId - The collection to insert into
|
* @param {string} collectionId - The collection to insert into
|
||||||
@ -580,6 +579,7 @@ async function purgeVectorIndex(collectionId) {
|
|||||||
function toggleSettings() {
|
function toggleSettings() {
|
||||||
$('#vectors_files_settings').toggle(!!settings.enabled_files);
|
$('#vectors_files_settings').toggle(!!settings.enabled_files);
|
||||||
$('#vectors_chats_settings').toggle(!!settings.enabled_chats);
|
$('#vectors_chats_settings').toggle(!!settings.enabled_chats);
|
||||||
|
$('#together_vectorsModel').toggle(settings.source === 'togetherai');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPurgeClick() {
|
async function onPurgeClick() {
|
||||||
@ -634,12 +634,6 @@ jQuery(async () => {
|
|||||||
|
|
||||||
Object.assign(settings, extension_settings.vectors);
|
Object.assign(settings, extension_settings.vectors);
|
||||||
|
|
||||||
if (settings.source === 'togetherai') {
|
|
||||||
$('#vectorsModel').show();
|
|
||||||
} else {
|
|
||||||
$('#vectorsModel').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate from TensorFlow to Transformers
|
// Migrate from TensorFlow to Transformers
|
||||||
settings.source = settings.source !== 'local' ? settings.source : 'transformers';
|
settings.source = settings.source !== 'local' ? settings.source : 'transformers';
|
||||||
$('#extensions_settings2').append(renderExtensionTemplate(MODULE_NAME, 'settings'));
|
$('#extensions_settings2').append(renderExtensionTemplate(MODULE_NAME, 'settings'));
|
||||||
@ -657,17 +651,13 @@ jQuery(async () => {
|
|||||||
});
|
});
|
||||||
$('#vectors_source').val(settings.source).on('change', () => {
|
$('#vectors_source').val(settings.source).on('change', () => {
|
||||||
settings.source = String($('#vectors_source').val());
|
settings.source = String($('#vectors_source').val());
|
||||||
if (settings.source === 'togetherai') {
|
|
||||||
$('#vectorsModel').show();
|
|
||||||
} else {
|
|
||||||
$('#vectorsModel').hide();
|
|
||||||
}
|
|
||||||
Object.assign(extension_settings.vectors, settings);
|
Object.assign(extension_settings.vectors, settings);
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
|
toggleSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#vectors_model').val(settings.model).on('change', () => {
|
$('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => {
|
||||||
settings.model = String($('#vectors_model').val());
|
settings.togetherai_model = String($('#vectors_togetherai_model').val());
|
||||||
Object.assign(extension_settings.vectors, settings);
|
Object.assign(extension_settings.vectors, settings);
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
<option value="togetherai">TogetherAI</option>
|
<option value="togetherai">TogetherAI</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container flexFlowColumn" id="vectorsModel">
|
<div class="flex-container flexFlowColumn" id="together_vectorsModel">
|
||||||
<label for="vectors_model">
|
<label for="vectors_togetherai_model">
|
||||||
Vectorization Model
|
Vectorization Model
|
||||||
</label>
|
</label>
|
||||||
<select id="vectors_model" class="text_pole">
|
<select id="vectors_togetherai_model" class="text_pole">
|
||||||
<option value="togethercomputer/m2-bert-80M-32k-retrieval">M2-BERT-Retrieval-32k</option>
|
<option value="togethercomputer/m2-bert-80M-32k-retrieval">M2-BERT-Retrieval-32k</option>
|
||||||
<option value="togethercomputer/m2-bert-80M-8k-retrieval">M2-BERT-Retrieval-8k</option>
|
<option value="togethercomputer/m2-bert-80M-8k-retrieval">M2-BERT-Retrieval-8k</option>
|
||||||
<option value="togethercomputer/m2-bert-80M-2k-retrieval">M2-BERT-Retrieval-2K</option>
|
<option value="togethercomputer/m2-bert-80M-2k-retrieval">M2-BERT-Retrieval-2K</option>
|
||||||
|
@ -50,7 +50,7 @@ async function getOpenAIBatchVector(texts, source, model = '') {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
input: texts,
|
input: texts,
|
||||||
model: source === 'togetherai' && model !== '' ? model : config.model,
|
model: model || config.model,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user