add nai diffusion and logging
This commit is contained in:
@@ -31,6 +31,9 @@ async function fetchProxy(request) {
|
|||||||
const header = JSON.parse(decodeURIComponent(request.headers.get('risu-header') ?? 'null')) ?? request.headers
|
const header = JSON.parse(decodeURIComponent(request.headers.get('risu-header') ?? 'null')) ?? request.headers
|
||||||
let requestHeaders = new Headers(header);
|
let requestHeaders = new Headers(header);
|
||||||
|
|
||||||
|
console.log(urlParam)
|
||||||
|
console.log(requestHeaders)
|
||||||
|
console.log(request.body)
|
||||||
let originalResponse = await fetch(urlParam, {
|
let originalResponse = await fetch(urlParam, {
|
||||||
method: method,
|
method: method,
|
||||||
headers: requestHeaders,
|
headers: requestHeaders,
|
||||||
|
|||||||
5846
package-lock.json
generated
Normal file
5846
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@
|
|||||||
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
|
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
|
||||||
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 CheckInput from "src/lib/UI/GUI/CheckInput.svelte";
|
||||||
|
|
||||||
</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>
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
<SelectInput className="mt-2 mb-4" bind:value={$DataBase.sdProvider}>
|
<SelectInput className="mt-2 mb-4" bind:value={$DataBase.sdProvider}>
|
||||||
<OptionInput value="" >None</OptionInput>
|
<OptionInput value="" >None</OptionInput>
|
||||||
<OptionInput value="webui" >Stable Diffusion WebUI</OptionInput>
|
<OptionInput value="webui" >Stable Diffusion WebUI</OptionInput>
|
||||||
|
<OptionInput value="novelai" >Novel AI</OptionInput>
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
<!-- <OptionInput value="runpod" >Runpod Serverless</OptionInput> -->
|
<!-- <OptionInput value="runpod" >Runpod Serverless</OptionInput> -->
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
@@ -56,6 +58,30 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if $DataBase.sdProvider === 'novelai'}
|
||||||
|
<span class="text-textcolor mt-2">Novel AI {language.providerURL}</span>
|
||||||
|
<TextInput size="sm" marginBottom placeholder="https://api.novelai.net" bind:value={$DataBase.NAIImgUrl}/>
|
||||||
|
<span class="text-textcolor">API Key</span>
|
||||||
|
<TextInput size="sm" marginBottom placeholder="pst-..." bind:value={$DataBase.NAIApiKey}/>
|
||||||
|
|
||||||
|
<span class="text-textcolor">Model</span>
|
||||||
|
<TextInput size="sm" marginBottom placeholder="nai-diffusion-3" bind:value={$DataBase.NAIImgModel}/>
|
||||||
|
|
||||||
|
<span class="text-textcolor">Width</span>
|
||||||
|
<NumberInput size="sm" marginBottom min={0} max={2048} bind:value={$DataBase.NAIImgConfig.width}/>
|
||||||
|
<span class="text-textcolor">Height</span>
|
||||||
|
<NumberInput size="sm" marginBottom min={0} max={2048} bind:value={$DataBase.NAIImgConfig.height}/>
|
||||||
|
<span class="text-textcolor">Sampler</span>
|
||||||
|
<TextInput size="sm" marginBottom bind:value={$DataBase.NAIImgConfig.sampler}/>
|
||||||
|
<span class="text-textcolor">steps</span>
|
||||||
|
<NumberInput size="sm" marginBottom min={0} max={2048} bind:value={$DataBase.NAIImgConfig.steps}/>
|
||||||
|
<span class="text-textcolor">CFG scale</span>
|
||||||
|
<NumberInput size="sm" marginBottom min={0} max={2048} bind:value={$DataBase.NAIImgConfig.scale}/>
|
||||||
|
<span class="text-textcolor">Use SMEA</span>
|
||||||
|
<Check bind:check={$DataBase.NAIImgConfig.sm}/>
|
||||||
|
<span class="text-textcolor">Use DYN</span>
|
||||||
|
<Check bind:check={$DataBase.NAIImgConfig.sm_dyn}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<span class="text-textcolor mt-4 text-lg font-bold">TTS</span>
|
<span class="text-textcolor mt-4 text-lg font-bold">TTS</span>
|
||||||
<span class="text-textcolor mt-2">ElevenLabs API key</span>
|
<span class="text-textcolor mt-2">ElevenLabs API key</span>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
"cfg_scale": db.sdCFG,
|
"cfg_scale": db.sdCFG,
|
||||||
"prompt": prompts.join(','),
|
"prompt": prompts.join(','),
|
||||||
"negative_prompt": neg,
|
"negative_prompt": neg,
|
||||||
'sampler_name': db.sdConfig.sampler_name,
|
"sampler_name": db.sdConfig.sampler_name,
|
||||||
"enable_hr": db.sdConfig.enable_hr,
|
"enable_hr": db.sdConfig.enable_hr,
|
||||||
"denoising_strength": db.sdConfig.denoising_strength,
|
"denoising_strength": db.sdConfig.denoising_strength,
|
||||||
"hr_scale": db.sdConfig.hr_scale,
|
"hr_scale": db.sdConfig.hr_scale,
|
||||||
@@ -161,6 +161,69 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(db.sdProvider === 'novelai'){
|
||||||
|
|
||||||
|
let prompts:string[] = []
|
||||||
|
let neg = ''
|
||||||
|
for(let i=0;i<currentSd.length;i++){
|
||||||
|
if(currentSd[i][0] !== 'negative'){
|
||||||
|
prompts.push(currentSd[i][1])
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
neg = currentSd[i][1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const uri = new URL(db.NAIImgUrl)
|
||||||
|
uri.pathname = '/ai/generate-image'
|
||||||
|
const reqlist = {
|
||||||
|
body: {
|
||||||
|
"input": prompts.join(','),
|
||||||
|
"model": db.NAIImgModel,
|
||||||
|
"parameters": {
|
||||||
|
"width": db.NAIImgConfig.width,
|
||||||
|
"height": db.NAIImgConfig.height,
|
||||||
|
"sampler": db.NAIImgConfig.sampler,
|
||||||
|
"steps": db.NAIImgConfig.steps,
|
||||||
|
"scale": db.NAIImgConfig.scale,
|
||||||
|
"negative_prompt": neg,
|
||||||
|
"sm": db.NAIImgConfig.sm,
|
||||||
|
"sm_dyn": db.NAIImgConfig.sm_dyn
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headers:{
|
||||||
|
'Authorization:': 'Bearer ' + db.NAIApiKey,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(uri)
|
||||||
|
console.log(reqlist)
|
||||||
|
try {
|
||||||
|
const da = await globalFetch(uri.toString(), reqlist)
|
||||||
|
|
||||||
|
console.log(da)
|
||||||
|
if(da.ok){
|
||||||
|
let charemotions = get(CharEmotion)
|
||||||
|
const img = `data:image/png;base64,${da.data.images[0]}`
|
||||||
|
console.log(img)
|
||||||
|
const emos:[string, string,number][] = [[img, img, Date.now()]]
|
||||||
|
charemotions[currentChar.chaId] = emos
|
||||||
|
CharEmotion.set(charemotions)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alertError(JSON.stringify(da.data))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnSdData
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
alertError(error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@@ -174,6 +174,15 @@ export function setDatabase(data:Database){
|
|||||||
if(checkNullish(data.sdCFG)){
|
if(checkNullish(data.sdCFG)){
|
||||||
data.sdCFG = 7
|
data.sdCFG = 7
|
||||||
}
|
}
|
||||||
|
if(checkNullish(data.NAIImgUrl)){
|
||||||
|
data.NAIImgUrl = 'https://api.novelai.net'
|
||||||
|
}
|
||||||
|
if(checkNullish(data.NAIApiKey)){
|
||||||
|
data.NAIApiKey = ''
|
||||||
|
}
|
||||||
|
if(checkNullish(data.NAIImgModel)){
|
||||||
|
data.NAIImgModel = 'nai-diffusion-3'
|
||||||
|
}
|
||||||
if(checkNullish(data.textTheme)){
|
if(checkNullish(data.textTheme)){
|
||||||
data.textTheme = "standard"
|
data.textTheme = "standard"
|
||||||
}
|
}
|
||||||
@@ -231,6 +240,17 @@ export function setDatabase(data:Database){
|
|||||||
hr_upscaler:"Latent"
|
hr_upscaler:"Latent"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(checkNullish(data.NAIImgConfig)){
|
||||||
|
data.NAIImgConfig = {
|
||||||
|
width:512,
|
||||||
|
height:768,
|
||||||
|
sampler:"k_dpmpp_sde",
|
||||||
|
steps:28,
|
||||||
|
scale:5,
|
||||||
|
sm:true,
|
||||||
|
sm_dyn:true
|
||||||
|
}
|
||||||
|
}
|
||||||
if(checkNullish(data.customTextTheme)){
|
if(checkNullish(data.customTextTheme)){
|
||||||
data.customTextTheme = {
|
data.customTextTheme = {
|
||||||
FontColorStandard: "#f8f8f2",
|
FontColorStandard: "#f8f8f2",
|
||||||
@@ -394,6 +414,10 @@ export interface Database{
|
|||||||
sdSteps:number
|
sdSteps:number
|
||||||
sdCFG:number
|
sdCFG:number
|
||||||
sdConfig:sdConfig
|
sdConfig:sdConfig
|
||||||
|
NAIImgUrl:string
|
||||||
|
NAIApiKey:string
|
||||||
|
NAIImgModel:string
|
||||||
|
NAIImgConfig:NAIImgConfig
|
||||||
runpodKey:string
|
runpodKey:string
|
||||||
promptPreprocess:boolean
|
promptPreprocess:boolean
|
||||||
bias: [string, number][]
|
bias: [string, number][]
|
||||||
@@ -717,6 +741,15 @@ interface sdConfig{
|
|||||||
hr_upscaler:string
|
hr_upscaler:string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface NAIImgConfig{
|
||||||
|
width:number,
|
||||||
|
height:number,
|
||||||
|
sampler:string,
|
||||||
|
steps:number,
|
||||||
|
scale:number,
|
||||||
|
sm:boolean,
|
||||||
|
sm_dyn:boolean
|
||||||
|
}
|
||||||
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'
|
||||||
|
|
||||||
export interface Chat{
|
export interface Chat{
|
||||||
|
|||||||
Reference in New Issue
Block a user