From c3d04066bc75a045b9ce0ba645dde59a5c8e2040 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:48:59 +0000 Subject: [PATCH] Allow WASM threading for non-Android. Fix eslint for transformers.mjs --- .eslintrc.js | 9 +++++++++ src/transformers.mjs | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b60cf4976..f05a857ad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,15 @@ module.exports = { node: true, }, }, + { + files: ['src/**/*.mjs'], + parserOptions: { + sourceType: 'module', + }, + env: { + node: true, + }, + }, { // Browser-side files files: ['public/**/*.js'], diff --git a/src/transformers.mjs b/src/transformers.mjs index 87f0f49c0..fd308ccb1 100644 --- a/src/transformers.mjs +++ b/src/transformers.mjs @@ -1,13 +1,12 @@ import { pipeline, env, RawImage, Pipeline } from 'sillytavern-transformers'; import { getConfigValue } from './util.js'; import path from 'path'; -import _ from 'lodash'; configureTransformers(); function configureTransformers() { // Limit the number of threads to 1 to avoid issues on Android - env.backends.onnx.wasm.numThreads = 1; + env.backends.onnx.wasm.numThreads = process.platform === 'android' ? 1 : 0; // Use WASM from a local folder to avoid CDN connections env.backends.onnx.wasm.wasmPaths = path.join(process.cwd(), 'dist') + path.sep; } @@ -114,4 +113,4 @@ async function getPipeline(task, forceModel = '') { export default { getPipeline, getRawImage, -} +};