Admin and start handlers work. Added testing txt2img from first bot version (will be replaced soon)

This commit is contained in:
BarsTiger
2023-02-14 13:49:58 +02:00
parent 7ba5482e6a
commit dcdb4ef60d
20 changed files with 234 additions and 19 deletions

31
bot/modules/api/models.py Normal file
View File

@@ -0,0 +1,31 @@
import aiohttp
from bot.db import db, DBTables
from rich import print
async def get_models():
endpoint = 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 def set_model(model_name: str):
endpoint = 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