[fix] nai i2i saving at db

This commit is contained in:
kwaroran
2023-11-27 18:39:14 +09:00
parent caa96cb3ef
commit 6bb3fe3712
3 changed files with 21 additions and 32 deletions

View File

@@ -6,7 +6,6 @@ import { globalFetch, readImage } from "../storage/globalApi"
import { CharEmotion } from "../stores"
import type { OpenAIChat } from "."
import { processZip } from "./processzip"
import { convertToBase64 } from "./uinttobase64"
import type { List } from "lodash"
import { generateRandomSeed } from "./generateSeed"
export async function stableDiff(currentChar:character,prompt:string){
@@ -186,10 +185,9 @@ export async function stableDiff(currentChar:character,prompt:string){
const charimg = currentChar.image;
const img = await readImage(charimg)
const base64 = await convertToBase64(img);
base64img = base64.split('base64,')[1];
}else{
base64img = db.NAIImgConfig.image.split('base64,')[1];
base64img = Buffer.from(img).toString('base64');
} else{
base64img = Buffer.from(await readImage(db.NAIImgConfig.image)).toString('base64');
}
let randomseed = generateRandomSeed(10);

View File

@@ -1,17 +0,0 @@
export async function convertToBase64(data: Uint8Array): Promise<string> {
return new Promise((resolve, reject) => {
const blob = new Blob([data]);
const reader = new FileReader();
reader.onloadend = function() {
const base64String = reader.result as string;
resolve(base64String);
};
reader.onerror = function(error) {
reject(error);
};
reader.readAsDataURL(blob);
});
}