add an interface class to handle and parse through sd options
parent
5d7bb556d7
commit
d5b25fc365
20
sdapi.js
20
sdapi.js
|
|
@ -359,7 +359,7 @@ async function setInpaintMaskWeight(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestGetConfig() {
|
async function requestGetConfig() {
|
||||||
console.log('requestGetModels: ')
|
console.log('requestGetConfig: ')
|
||||||
let json = []
|
let json = []
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
|
@ -374,7 +374,22 @@ async function setInpaintMaskWeight(value) {
|
||||||
}
|
}
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
async function requestGetOptions() {
|
||||||
|
console.log('requestGetOptions: ')
|
||||||
|
let json = []
|
||||||
|
try{
|
||||||
|
|
||||||
|
const full_url = 'http://127.0.0.1:8000/sdapi/v1/options'
|
||||||
|
let request = await fetch(full_url)
|
||||||
|
json = await request.json()
|
||||||
|
console.log('models json:')
|
||||||
|
console.dir(json)
|
||||||
|
|
||||||
|
}catch(e){
|
||||||
|
console.warn(`issues requesting from ${full_url}`,e)
|
||||||
|
}
|
||||||
|
return json
|
||||||
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
requestTxt2Img,
|
requestTxt2Img,
|
||||||
requestImg2Img,
|
requestImg2Img,
|
||||||
|
|
@ -390,5 +405,6 @@ module.exports = {
|
||||||
savePromptShortcut,
|
savePromptShortcut,
|
||||||
loadHistory,
|
loadHistory,
|
||||||
setInpaintMaskWeight,
|
setInpaintMaskWeight,
|
||||||
requestGetConfig
|
requestGetConfig,
|
||||||
|
requestGetOptions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
const sdapi = require('../../sdapi')
|
||||||
|
|
||||||
|
class SdOptions {
|
||||||
|
constructor () {
|
||||||
|
// this.status = false // true if we have a valid copy of sd options, false otherwise
|
||||||
|
this.options //store sd options
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async getOptions () {
|
||||||
|
try {
|
||||||
|
// if (this.status) {
|
||||||
|
// return this.options
|
||||||
|
// } else {
|
||||||
|
// this.options = await sdapi.requestGetOptions()
|
||||||
|
// if (this.options) {
|
||||||
|
// this.status = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
this.options = await sdapi.requestGetOptions()
|
||||||
|
return this.options
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getCurrentModel(){
|
||||||
|
const current_model = this.options?.sd_model_checkpoint
|
||||||
|
return current_model
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// const sd_options = new SdOptions()
|
||||||
|
// sd_options.option?.sd_model_checkpoint
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
SdOptions
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue