88 getImageInfo ,
99 setOptions ,
1010 testForHistoryPlugin ,
11+ fetchHypernetworks ,
12+ fetchEmbeddings ,
13+ fetchExtraModels
1114} from "./Utilities" ;
1215
1316const manifest = {
@@ -64,6 +67,25 @@ const webuiUpscalers = [
6467 } ,
6568] ;
6669
70+ const webuiStyleTypes = [
71+ {
72+ label : "None" ,
73+ value : "none" ,
74+ } ,
75+ {
76+ label : "LoRA" ,
77+ value : "lora" ,
78+ } ,
79+ {
80+ label : "Hypernetworks" ,
81+ value : "hypernetworks" ,
82+ } ,
83+ {
84+ label : "Textual Inversions" ,
85+ value : "embeddings" ,
86+ } ,
87+ ] ;
88+
6789const getNumber = ( strValue : string | null , defaultValue : number ) => {
6890 let retValue = defaultValue ;
6991
@@ -80,6 +102,7 @@ export const createPlugin = StableStudio.createPlugin<{
80102 baseUrl : StableStudio . PluginSettingString ;
81103 upscaler : StableStudio . PluginSettingString ;
82104 historyImagesCount : StableStudio . PluginSettingNumber ;
105+ styleType : StableStudio . PluginSettingString ;
83106 } ;
84107} > ( ( { set, get } ) => {
85108 const webuiLoad = (
@@ -93,6 +116,7 @@ export const createPlugin = StableStudio.createPlugin<{
93116 | "getStableDiffusionDefaultCount"
94117 | "getStableDiffusionDefaultInput"
95118 | "getStableDiffusionExistingImages"
119+ | "getStableDiffusionStyles"
96120 > => {
97121 webuiHostUrl = webuiHostUrl ?? "http://127.0.0.1:7861" ;
98122
@@ -138,7 +162,8 @@ export const createPlugin = StableStudio.createPlugin<{
138162 const data = await constructPayload (
139163 options ,
140164 isUpscale ,
141- get ( ) . settings . upscaler . value
165+ get ( ) . settings . upscaler . value ,
166+ get ( ) . settings . styleType . value
142167 ) ;
143168
144169 // Send payload to webui
@@ -273,6 +298,45 @@ export const createPlugin = StableStudio.createPlugin<{
273298 } ) ) ;
274299 } ,
275300
301+ getStableDiffusionStyles : async ( ) => {
302+ const styleType = localStorage . getItem ( "styleType" ) ?? "None" ;
303+
304+ const styles : any = [ ] ;
305+
306+ if ( styleType === "lora" ) {
307+ const loras = await fetchExtraModels ( webuiHostUrl , "Lora" ) ;
308+
309+ loras . forEach ( ( lora : any ) => {
310+ styles . push ( {
311+ id : lora [ "name" ] ,
312+ name : lora [ "name" ] ,
313+ } ) ;
314+ } )
315+ }
316+ if ( styleType === "hypernetworks" ) {
317+ const hypernetworks = await fetchHypernetworks ( webuiHostUrl ) ;
318+
319+ hypernetworks . forEach ( ( hypernetwork : any ) => {
320+ styles . push ( {
321+ id : hypernetwork [ "name" ] ,
322+ name : hypernetwork [ "name" ] ,
323+ } ) ;
324+ } )
325+ }
326+ if ( styleType === "embeddings" ) {
327+ const embeddings = await fetchEmbeddings ( webuiHostUrl ) ;
328+
329+ for ( const key in embeddings . loaded ) {
330+ styles . push ( {
331+ id : key ,
332+ name : key ,
333+ } ) ;
334+ }
335+ }
336+
337+ return styles ;
338+ } ,
339+
276340 getStableDiffusionExistingImages : async ( ) => {
277341 const existingImagesResponse = await fetch (
278342 `${ webuiHostUrl } /StableStudio/get-generated-images` ,
@@ -379,6 +443,13 @@ export const createPlugin = StableStudio.createPlugin<{
379443 variant : "slider" ,
380444 value : getNumber ( localStorage . getItem ( "historyImagesCount" ) , 20 ) ,
381445 } ,
446+
447+ styleType : {
448+ type : "string" ,
449+ title : "Style Type" ,
450+ options : webuiStyleTypes ,
451+ value : localStorage . getItem ( "styleType" ) ?? "None"
452+ }
382453 } ,
383454
384455 setSetting : ( key , value ) => {
@@ -396,6 +467,8 @@ export const createPlugin = StableStudio.createPlugin<{
396467 localStorage . setItem ( "upscaler1" , value ) ;
397468 } else if ( key === "historyImagesCount" && typeof value === "number" ) {
398469 localStorage . setItem ( "historyImagesCount" , value . toString ( ) ) ;
470+ } else if ( key === "styleType" && typeof value === "string" ) {
471+ localStorage . setItem ( "styleType" , value ) ;
399472 }
400473 } ,
401474
0 commit comments