mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #2495 from Risenafis/fix-change-model
Fix transformers model changes
This commit is contained in:
@@ -94,7 +94,11 @@ function getModelForTask(task) {
|
||||
*/
|
||||
async function getPipeline(task, forceModel = '') {
|
||||
if (tasks[task].pipeline) {
|
||||
return tasks[task].pipeline;
|
||||
if (forceModel === '' || tasks[task].currentModel === forceModel) {
|
||||
return tasks[task].pipeline;
|
||||
}
|
||||
console.log('Disposing transformers.js pipeline for for task', task, 'with model', tasks[task].currentModel);
|
||||
await tasks[task].pipeline.dispose();
|
||||
}
|
||||
|
||||
const cache_dir = path.join(process.cwd(), 'cache');
|
||||
@@ -103,6 +107,7 @@ async function getPipeline(task, forceModel = '') {
|
||||
console.log('Initializing transformers.js pipeline for task', task, 'with model', model);
|
||||
const instance = await pipeline(task, model, { cache_dir, quantized: tasks[task].quantized ?? true, local_files_only: localOnly });
|
||||
tasks[task].pipeline = instance;
|
||||
tasks[task].currentModel = model;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user