[feat] less usage
This commit is contained in:
@@ -4,6 +4,7 @@ import App from "./App.svelte";
|
||||
import { loadData } from "./ts/storage/globalApi";
|
||||
import { initHotkey } from "./ts/hotkey";
|
||||
import { polyfill } from "./ts/polyfill";
|
||||
import { runEmbedding } from "./ts/process/embedding/transformers";
|
||||
|
||||
polyfill()
|
||||
|
||||
@@ -13,4 +14,5 @@ const app = new App({
|
||||
|
||||
loadData()
|
||||
initHotkey()
|
||||
runEmbedding("test")
|
||||
export default app;
|
||||
@@ -5,6 +5,7 @@ let pipeline: (task: string, model?: string, { quantized, progress_callback, con
|
||||
async function loadTransformer() {
|
||||
if(!pipeline){
|
||||
const transformersLib = await import('@xenova/transformers')
|
||||
transformersLib.env.localModelPath = "https://sv.risuai.xyz/transformers/"
|
||||
pipeline = transformersLib.pipeline
|
||||
}
|
||||
}
|
||||
@@ -50,6 +51,7 @@ export const runEmbedding = async (text: string):Promise<Float32Array> => {
|
||||
await loadTransformer()
|
||||
let extractor = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
|
||||
let result = await extractor(text, { pooling: 'mean', normalize: true });
|
||||
console.log(result)
|
||||
return result?.data ?? null;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -227,6 +227,9 @@ export async function saveDb(){
|
||||
if(!forageStorage.isAccount){
|
||||
await forageStorage.setItem(`database/dbbackup-${(Date.now()/100).toFixed()}.bin`, dbData)
|
||||
}
|
||||
if(forageStorage.isAccount){
|
||||
await sleep(2500);
|
||||
}
|
||||
}
|
||||
if(!forageStorage.isAccount){
|
||||
await getDbBackups()
|
||||
|
||||
Reference in New Issue
Block a user