Add playground and fix embeddings

This commit is contained in:
kwaroran
2024-04-24 21:49:25 +09:00
parent bd2e1a05b7
commit 3d8b3b669d
14 changed files with 202 additions and 31 deletions

View File

@@ -57,7 +57,16 @@ export const runEmbedding = async (texts: string[], model:EmbeddingModel = 'Xeno
extractor = await pipeline('feature-extraction', model);
}
let result = await extractor(texts, { pooling: 'mean', normalize: true });
return (result.data as Float32Array[]) ?? null;
console.log(texts, result)
const data = result.data as Float32Array
const lenPerText = data.length / texts.length
let res:Float32Array[] = []
for(let i = 0; i < texts.length; i++){
res.push(data.subarray(i * lenPerText, (i + 1) * lenPerText))
}
console.log(res)
return res ?? [];
}
export const runImageEmbedding = async (dataurl:string) => {

View File

@@ -986,7 +986,7 @@ export function checkCharOrder() {
const charId = db.characters[i].chaId
charIdList.push(charId)
if(!ordered.includes(charId)){
if(charId !== '§temp'){
if(charId !== '§temp' && charId !== '§playground'){
db.characterOrder.push(charId)
}
}

View File

@@ -40,6 +40,7 @@ export const ShowVN = writable(false)
export const SettingsMenuIndex = writable(-1)
export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean})
export const OpenRealmStore = writable(false)
export const PlaygroundStore = writable(0)
function createSimpleCharacter(char:character|groupChat){
if((!char) || char.type === 'group'){