Setting generation properties

This commit is contained in:
BarsTiger
2023-02-26 22:16:05 +02:00
parent 8f0cd0ac05
commit 3c3d644137
10 changed files with 286 additions and 56 deletions

View File

@@ -1,31 +1,22 @@
import aiohttp
from bot.db import db, DBTables, decrypt
from rich import print
async def get_models():
endpoint = decrypt(db[DBTables.config].get('endpoint'))
try:
async with aiohttp.ClientSession() as session:
r = await session.get(endpoint + "/sdapi/v1/sd-models")
if r.status != 200:
return None
return [x["title"] for x in await r.json()]
except Exception as e:
print(e)
return None
async with aiohttp.ClientSession() as session:
r = await session.get(endpoint + "/sdapi/v1/sd-models")
if r.status != 200:
return None
return [x["title"] for x in await r.json()]
async def set_model(model_name: str):
endpoint = decrypt(db[DBTables.config].get('endpoint'))
try:
async with aiohttp.ClientSession() as session:
r = await session.post(endpoint + "/sdapi/v1/options", json={
"sd_model_checkpoint": model_name
})
if r.status != 200:
return False
return True
except Exception as e:
print(e)
return False
async with aiohttp.ClientSession() as session:
r = await session.post(endpoint + "/sdapi/v1/options", json={
"sd_model_checkpoint": model_name
})
if r.status != 200:
return False
return True