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() {
|
||||
console.log('requestGetModels: ')
|
||||
console.log('requestGetConfig: ')
|
||||
let json = []
|
||||
try{
|
||||
|
||||
|
|
@ -374,7 +374,22 @@ async function setInpaintMaskWeight(value) {
|
|||
}
|
||||
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 = {
|
||||
requestTxt2Img,
|
||||
requestImg2Img,
|
||||
|
|
@ -390,5 +405,6 @@ module.exports = {
|
|||
savePromptShortcut,
|
||||
loadHistory,
|
||||
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