mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-15 07:20:31 +08:00
Merge pull request #4358 from bamarillo/master
[API][Feature] Add Skip endpoint
This commit is contained in:
commit
84a6f211d4
@ -72,6 +72,7 @@ class Api:
|
|||||||
self.app.add_api_route("/sdapi/v1/progress", self.progressapi, methods=["GET"], response_model=ProgressResponse)
|
self.app.add_api_route("/sdapi/v1/progress", self.progressapi, methods=["GET"], response_model=ProgressResponse)
|
||||||
self.app.add_api_route("/sdapi/v1/interrogate", self.interrogateapi, methods=["POST"])
|
self.app.add_api_route("/sdapi/v1/interrogate", self.interrogateapi, methods=["POST"])
|
||||||
self.app.add_api_route("/sdapi/v1/interrupt", self.interruptapi, methods=["POST"])
|
self.app.add_api_route("/sdapi/v1/interrupt", self.interruptapi, methods=["POST"])
|
||||||
|
self.app.add_api_route("/sdapi/v1/skip", self.skip, methods=["POST"])
|
||||||
self.app.add_api_route("/sdapi/v1/options", self.get_config, methods=["GET"], response_model=OptionsModel)
|
self.app.add_api_route("/sdapi/v1/options", self.get_config, methods=["GET"], response_model=OptionsModel)
|
||||||
self.app.add_api_route("/sdapi/v1/options", self.set_config, methods=["POST"])
|
self.app.add_api_route("/sdapi/v1/options", self.set_config, methods=["POST"])
|
||||||
self.app.add_api_route("/sdapi/v1/cmd-flags", self.get_cmd_flags, methods=["GET"], response_model=FlagsModel)
|
self.app.add_api_route("/sdapi/v1/cmd-flags", self.get_cmd_flags, methods=["GET"], response_model=FlagsModel)
|
||||||
@ -237,6 +238,9 @@ class Api:
|
|||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def skip(self):
|
||||||
|
shared.state.skip()
|
||||||
|
|
||||||
def get_config(self):
|
def get_config(self):
|
||||||
options = {}
|
options = {}
|
||||||
for key in shared.opts.data.keys():
|
for key in shared.opts.data.keys():
|
||||||
@ -248,14 +252,10 @@ class Api:
|
|||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
def set_config(self, req: OptionsModel):
|
def set_config(self, req: Dict[str, Any]):
|
||||||
# currently req has all options fields even if you send a dict like { "send_seed": false }, which means it will
|
|
||||||
# overwrite all options with default values.
|
for o in req:
|
||||||
raise RuntimeError('Setting options via API is not supported')
|
setattr(shared.opts, o, req[o])
|
||||||
|
|
||||||
reqDict = vars(req)
|
|
||||||
for o in reqDict:
|
|
||||||
setattr(shared.opts, o, reqDict[o])
|
|
||||||
|
|
||||||
shared.opts.save(shared.config_filename)
|
shared.opts.save(shared.config_filename)
|
||||||
return
|
return
|
||||||
|
@ -176,9 +176,9 @@ class InterrogateResponse(BaseModel):
|
|||||||
caption: str = Field(default=None, title="Caption", description="The generated caption for the image.")
|
caption: str = Field(default=None, title="Caption", description="The generated caption for the image.")
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
for key, value in opts.data.items():
|
for key, metadata in opts.data_labels.items():
|
||||||
metadata = opts.data_labels.get(key)
|
value = opts.data.get(key)
|
||||||
optType = opts.typemap.get(type(value), type(value))
|
optType = opts.typemap.get(type(metadata.default), type(value))
|
||||||
|
|
||||||
if (metadata is not None):
|
if (metadata is not None):
|
||||||
fields.update({key: (Optional[optType], Field(
|
fields.update({key: (Optional[optType], Field(
|
||||||
|
Loading…
Reference in New Issue
Block a user