fix: the former STABLE_DIFFUSION_URL variable is not intuitive
This commit is contained in:
@@ -38,9 +38,8 @@ JARVIS_CHAT_HISTORY_DIR=./chathistory
|
|||||||
|
|
||||||
# =========== Stable diffusion
|
# =========== Stable diffusion
|
||||||
# The stable diffusion webui api's address.
|
# The stable diffusion webui api's address.
|
||||||
# e.g. http://192.168.3.254:1997/sdapi/v1
|
# e.g. http://192.168.3.254:1997
|
||||||
# NOTE 1: REMOVE the final slash '/', or sd-webui will not recognize the request
|
# NOTE: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
||||||
# NOTE 2: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
|
||||||
# since we don't use host network in docker.
|
# since we don't use host network in docker.
|
||||||
DEMO_STABLE_DIFFUSION_ADDRESS=
|
DEMO_STABLE_DIFFUSION_ADDRESS=
|
||||||
### The following 6 variables are optional. You can leave them empty if you want.
|
### The following 6 variables are optional. You can leave them empty if you want.
|
||||||
|
|||||||
@@ -24,6 +24,19 @@ def reg_or_not():
|
|||||||
logger.warn("'STABLE_DIFFUSION_URL' is not provided, stable_diffusion function will not available")
|
logger.warn("'STABLE_DIFFUSION_URL' is not provided, stable_diffusion function will not available")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if stable_diffusion_address.endswith('/sdapi/v1') or stable_diffusion_address.endswith('/sdapi/v1/'):
|
||||||
|
logger.warn("'STABLE_DIFFUSION_URL' is expected to be something like: http://host[:port], "
|
||||||
|
"the form 'http://host[:port]/sdapi/v1' will be deprecated in the future.")
|
||||||
|
if stable_diffusion_address('/sdapi/v1'):
|
||||||
|
stable_diffusion_address += '/txt2img'
|
||||||
|
else:
|
||||||
|
stable_diffusion_address += 'txt2img'
|
||||||
|
else:
|
||||||
|
if stable_diffusion_address.endswith('/'):
|
||||||
|
stable_diffusion_address += 'sdapi/v1/txt2img'
|
||||||
|
else:
|
||||||
|
stable_diffusion_address += '/sdapi/v1/txt2img'
|
||||||
|
|
||||||
stable_diffusion_my_lora = os.getenv('DEMO_STABLE_DIFFUSION_MY_LORA')
|
stable_diffusion_my_lora = os.getenv('DEMO_STABLE_DIFFUSION_MY_LORA')
|
||||||
stable_diffusion_my_lora_trigger_word = os.getenv('DEMO_STABLE_DIFFUSION_MY_LORA_TRIGGER_WORD')
|
stable_diffusion_my_lora_trigger_word = os.getenv('DEMO_STABLE_DIFFUSION_MY_LORA_TRIGGER_WORD')
|
||||||
stable_diffusion_my_name = os.getenv('DEMO_STABLE_DIFFUSION_MY_NAME')
|
stable_diffusion_my_name = os.getenv('DEMO_STABLE_DIFFUSION_MY_NAME')
|
||||||
@@ -208,14 +221,13 @@ NOTE: Just reply using these information, don't ask me anything.
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
async def call_sd(params: dict):
|
async def call_sd(params: dict):
|
||||||
url = stable_diffusion_address + "/txt2img"
|
|
||||||
headers = {
|
headers = {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.post(url, headers=headers, data=json.dumps(params)) as response:
|
async with session.post(stable_diffusion_address, headers=headers, data=json.dumps(params)) as response:
|
||||||
resp_obj = await response.json()
|
resp_obj = await response.json()
|
||||||
try:
|
try:
|
||||||
return resp_obj["images"][0]
|
return resp_obj["images"][0]
|
||||||
|
|||||||
Reference in New Issue
Block a user