diff --git a/src/lib/Setting/Pages/OtherBotSettings.svelte b/src/lib/Setting/Pages/OtherBotSettings.svelte
index 4690e31d..1451104c 100644
--- a/src/lib/Setting/Pages/OtherBotSettings.svelte
+++ b/src/lib/Setting/Pages/OtherBotSettings.svelte
@@ -45,6 +45,7 @@
Stable Diffusion WebUI
Novel AI
Dall-E
+ Stability API
{#if $DataBase.sdProvider === 'webui'}
@@ -205,6 +206,43 @@
{/if}
+
+ {#if $DataBase.sdProvider === 'stability'}
+ Stability API Key
+
+
+ Stability Model
+
+ SD Ultra
+ SD Core
+ SD3 Large
+ SD3 Medium
+
+
+ {#if $DataBase.stabilityModel === 'core'}
+ SD Core Style
+
+ Unspecified
+ 3D Model
+ Analog Film
+ Anime
+ Cinematic
+ Comic Book
+ Digital Art
+ Enhance
+ Fantasy Art
+ Isometric
+ Line Art
+ Low Poly
+ Modeling Compound
+ Neon Punk
+ Origami
+ Photographic
+ Pixel Art
+ Tile Texture
+
+ {/if}
+ {/if}
diff --git a/src/ts/process/stableDiff.ts b/src/ts/process/stableDiff.ts
index 17adb0ce..aadd9705 100644
--- a/src/ts/process/stableDiff.ts
+++ b/src/ts/process/stableDiff.ts
@@ -56,6 +56,7 @@ export async function stableDiff(currentChar:character,prompt:string){
export async function generateAIImage(genPrompt:string, currentChar:character, neg:string, returnSdData:string):Promise{
const db = get(DataBase)
+ console.log(db.sdProvider)
if(db.sdProvider === 'webui'){
@@ -361,6 +362,57 @@ export async function generateAIImage(genPrompt:string, currentChar:character, n
return false
}
return returnSdData
+ }
+ if(db.sdProvider === 'stability'){
+ const formData = new FormData()
+ const model = db.stabilityModel
+ formData.append('prompt', genPrompt)
+ if(model !== 'core' && model !== 'ultra'){
+ formData.append('negative_prompt', neg)
+ formData.append('model', model)
+ }
+ if(model === 'core'){
+ if(db.stabllityStyle){
+ formData.append('style_preset', db.stabllityStyle)
+ }
+ }
+ if(model === 'ultra'){
+ formData.append('negative_prompt', neg)
+ }
+
+ const uri = model === 'core' ? 'core' : model === 'ultra' ? 'ultra' : 'sd3'
+ const da = await fetch("https://api.stability.ai/v2beta/stable-image/generate/" + uri, {
+ body: formData,
+ headers:{
+ "authorization": "Bearer " + db.stabilityKey,
+ "accept": "image/*"
+ },
+ method: 'POST'
+ })
+
+ const res = await da.arrayBuffer()
+ if(!da.ok){
+ alertError(Buffer.from(res).toString())
+ return false
+ }
+
+ if((da.headers["content-type"] ?? "").startsWith('application/json')){
+ alertError(Buffer.from(res).toString())
+ return false
+ }
+
+ if(returnSdData === 'inlay'){
+ return `data:image/png;base64,${Buffer.from(res).toString('base64')}`
+ }
+
+ let charemotions = get(CharEmotion)
+ const img = `data:image/png;base64,${Buffer.from(res).toString('base64')}`
+ const emos:[string, string,number][] = [[img, img, Date.now()]]
+ charemotions[currentChar.chaId] = emos
+ CharEmotion.set(charemotions)
+ return returnSdData
+
+
}
return ''
}
\ No newline at end of file
diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts
index 198175b8..32297fb9 100644
--- a/src/ts/storage/database.ts
+++ b/src/ts/storage/database.ts
@@ -416,6 +416,8 @@ export function setDatabase(data:Database){
data.font ??= 'default'
data.customFont ??= ''
data.lineHeight ??= 1.25
+ data.stabilityModel ??= 'sd3-large'
+ data.stabllityStyle ??= ''
changeLanguage(data.language)
DataBase.set(data)
}
@@ -686,6 +688,9 @@ export interface Database{
font: string
customFont: string
lineHeight: number
+ stabilityModel: string
+ stabilityKey: string
+ stabllityStyle: string
}
export interface customscript{