Add image selection feature to
OtherBotSettings.svelte Signed-off-by: hashcoko <hashcoko@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import Check from "src/lib/UI/GUI/CheckInput.svelte";
|
import Check from "src/lib/UI/GUI/CheckInput.svelte";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import Help from "src/lib/Others/Help.svelte";
|
import Help from "src/lib/Others/Help.svelte";
|
||||||
|
import { selectSingleFile } from "src/ts/util";
|
||||||
import { DataBase } from "src/ts/storage/database";
|
import { DataBase } from "src/ts/storage/database";
|
||||||
import { isTauri } from "src/ts/storage/globalApi";
|
import { isTauri } from "src/ts/storage/globalApi";
|
||||||
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
|
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
|
||||||
@@ -9,6 +10,8 @@
|
|||||||
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
|
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
|
||||||
import OptionInput from "src/lib/UI/GUI/OptionInput.svelte";
|
import OptionInput from "src/lib/UI/GUI/OptionInput.svelte";
|
||||||
import SliderInput from "src/lib/UI/GUI/SliderInput.svelte";
|
import SliderInput from "src/lib/UI/GUI/SliderInput.svelte";
|
||||||
|
import Button from "src/lib/UI/GUI/Button.svelte";
|
||||||
|
import { convertToBase64 } from "src/ts/process/uinttobase64";
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.otherBots}</h2>
|
<h2 class="mb-2 text-2xl font-bold mt-2">{language.otherBots}</h2>
|
||||||
@@ -80,6 +83,23 @@
|
|||||||
<SliderInput min={0} max={0.99} step={0.01} bind:value={$DataBase.NAIImgConfig.noise}/>
|
<SliderInput min={0} max={0.99} step={0.01} bind:value={$DataBase.NAIImgConfig.noise}/>
|
||||||
<span class="text-textcolor2 mb-6 text-sm">{$DataBase.NAIImgConfig.noise}</span>
|
<span class="text-textcolor2 mb-6 text-sm">{$DataBase.NAIImgConfig.noise}</span>
|
||||||
|
|
||||||
|
<span class="text-textcolor">base image</span>
|
||||||
|
<TextInput size="sm" marginBottom placeholder="If empty, a profile picture is sent." bind:value={$DataBase.NAIImgConfig.image}/>
|
||||||
|
<span class="text-textcolor">If empty, a profile picture is sent.</span>
|
||||||
|
|
||||||
|
<Button on:click={async () => {
|
||||||
|
const img = await selectSingleFile([
|
||||||
|
'jpg',
|
||||||
|
'jpeg',
|
||||||
|
'png',
|
||||||
|
'webp'
|
||||||
|
])
|
||||||
|
if(!img){
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const base64 = await convertToBase64(img.data)
|
||||||
|
$DataBase.NAIImgConfig.image = base64
|
||||||
|
}}>Select Image</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<span class="text-textcolor">Width</span>
|
<span class="text-textcolor">Width</span>
|
||||||
|
|||||||
@@ -177,18 +177,21 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const charimg = currentChar.image; // Uint8Array 형태의 이미지 데이터
|
|
||||||
console.log("charimg:" + charimg);
|
|
||||||
|
|
||||||
const img = await readImage(charimg)
|
|
||||||
console.log("img:" + img);
|
|
||||||
const base64 = await convertToBase64(img);
|
|
||||||
const base64img = base64.split('base64,')[1];
|
|
||||||
|
|
||||||
console.log("base64img:" + base64img);
|
|
||||||
let reqlist= {}
|
let reqlist= {}
|
||||||
|
|
||||||
if(db.NAII2I){
|
if(db.NAII2I){
|
||||||
|
let base64img = ''
|
||||||
|
if(db.NAIImgConfig.image === ''){
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
let randomseed = generateRandomSeed(10);
|
let randomseed = generateRandomSeed(10);
|
||||||
let seed = parseInt(randomseed, 10);
|
let seed = parseInt(randomseed, 10);
|
||||||
reqlist = {
|
reqlist = {
|
||||||
|
|||||||
@@ -253,7 +253,8 @@ export function setDatabase(data:Database){
|
|||||||
sm:true,
|
sm:true,
|
||||||
sm_dyn:true,
|
sm_dyn:true,
|
||||||
noise:0.0,
|
noise:0.0,
|
||||||
strength:0.3
|
strength:0.3,
|
||||||
|
image:""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checkNullish(data.customTextTheme)){
|
if(checkNullish(data.customTextTheme)){
|
||||||
@@ -756,7 +757,8 @@ interface NAIImgConfig{
|
|||||||
sm:boolean,
|
sm:boolean,
|
||||||
sm_dyn:boolean,
|
sm_dyn:boolean,
|
||||||
noise:number,
|
noise:number,
|
||||||
strength:number
|
strength:number,
|
||||||
|
image:string
|
||||||
}
|
}
|
||||||
export type FormatingOrderItem = 'main'|'jailbreak'|'chats'|'lorebook'|'globalNote'|'authorNote'|'lastChat'|'description'|'postEverything'|'personaPrompt'
|
export type FormatingOrderItem = 'main'|'jailbreak'|'chats'|'lorebook'|'globalNote'|'authorNote'|'lastChat'|'description'|'postEverything'|'personaPrompt'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user