Merge pull request #17 from DiligentCatCat/main
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
|
||||
# The stable diffusion webui api's address.
|
||||
# e.g. http://192.168.3.254:1997/sdapi/v1
|
||||
# NOTE 1: REMOVE the final slash '/', or sd-webui will not recognize the request
|
||||
# NOTE 2: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
||||
# e.g. http://192.168.3.254:1997
|
||||
# NOTE: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
||||
# since we don't use host network in docker.
|
||||
DEMO_STABLE_DIFFUSION_ADDRESS=
|
||||
### The following 6 variables are optional. You can leave them empty if you want.
|
||||
|
||||
@@ -61,9 +61,8 @@ To enable Jarvis with drawing capabilities, you will need to set up an Stable Di
|
||||
cd docker
|
||||
|
||||
# Edit '.env' and configure DEMO_STABLE_DIFFUSION_ADDRESS
|
||||
# e.g. http://192.168.3.254:1997/sdapi/v1
|
||||
# NOTE 1: REMOVE the final slash '/', or sd-webui will not recognize the request
|
||||
# NOTE 2: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
||||
# e.g. http://192.168.3.254:1997
|
||||
# NOTE: Do *** NOT **** use 'localhost' or '127.0.0.1' or other loopback address,
|
||||
# since we don't use host network in docker.
|
||||
vim jarvis/.env
|
||||
|
||||
|
||||
@@ -24,6 +24,20 @@ def reg_or_not():
|
||||
logger.warn("'STABLE_DIFFUSION_URL' is not provided, stable_diffusion function will not available")
|
||||
return
|
||||
|
||||
# TODO: Remove support for 'http://xxxx/sdapi/v1'
|
||||
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_trigger_word = os.getenv('DEMO_STABLE_DIFFUSION_MY_LORA_TRIGGER_WORD')
|
||||
stable_diffusion_my_name = os.getenv('DEMO_STABLE_DIFFUSION_MY_NAME')
|
||||
@@ -208,14 +222,13 @@ NOTE: Just reply using these information, don't ask me anything.
|
||||
return resp
|
||||
|
||||
async def call_sd(params: dict):
|
||||
url = stable_diffusion_address + "/txt2img"
|
||||
headers = {
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
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()
|
||||
try:
|
||||
return resp_obj["images"][0]
|
||||
|
||||
Reference in New Issue
Block a user