mirror of
https://github.com/open-webui/open-webui
synced 2025-03-27 07:50:37 +00:00
fix: async image gen automatic1111
This commit is contained in:
parent
553293f4d5
commit
e442b3b169
@ -15,6 +15,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from utils.utils import (
|
from utils.utils import (
|
||||||
get_verified_user,
|
get_verified_user,
|
||||||
@ -533,7 +534,9 @@ async def image_generations(
|
|||||||
if form_data.negative_prompt is not None:
|
if form_data.negative_prompt is not None:
|
||||||
data["negative_prompt"] = form_data.negative_prompt
|
data["negative_prompt"] = form_data.negative_prompt
|
||||||
|
|
||||||
r = requests.post(
|
# Use asyncio.to_thread for the requests.post call
|
||||||
|
r = await asyncio.to_thread(
|
||||||
|
requests.post,
|
||||||
url=f"{app.state.config.AUTOMATIC1111_BASE_URL}/sdapi/v1/txt2img",
|
url=f"{app.state.config.AUTOMATIC1111_BASE_URL}/sdapi/v1/txt2img",
|
||||||
json=data,
|
json=data,
|
||||||
headers={"authorization": get_automatic1111_api_auth()},
|
headers={"authorization": get_automatic1111_api_auth()},
|
||||||
@ -553,7 +556,6 @@ async def image_generations(
|
|||||||
json.dump({**data, "info": res["info"]}, f)
|
json.dump({**data, "info": res["info"]}, f)
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error = e
|
error = e
|
||||||
if r != None:
|
if r != None:
|
||||||
|
Loading…
Reference in New Issue
Block a user