Skip to content

Commit

Permalink
Discord bot: make model entry optional for text2image
Browse files Browse the repository at this point in the history
  • Loading branch information
Stax124 committed Jun 19, 2024
1 parent 4f444c5 commit 726ab2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

async def find_closest_model(model: str):
"""Find the closest model to the one provided"""

models, _ = await shared_bot.models.cached_loaded_models()

if model == "":
return models[0]
res = difflib.get_close_matches(model, models, n=1, cutoff=0.1)

if not res:
Expand Down
4 changes: 2 additions & 2 deletions bot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ async def load_model(self, ctx: Context, model: str) -> None:
response = await response.json()

if status == 200:
await message.edit(content=f"{response['message']}: {model}")
await shared_bot.models.refresh_loaded_models()
await message.edit(content=f"{response['message']}: {model}")
else:
await message.edit(content=f"Error: **{response.get('detail')}**")

Expand All @@ -121,8 +121,8 @@ async def unload_model(self, ctx: Context, model: str) -> None:
response = await response.json()

if status == 200:
await message.edit(content=f"{response['message']}: {model}")
await shared_bot.models.refresh_loaded_models()
await message.edit(content=f"{response['message']}: {model}")
else:
await message.edit(content=f"Error: {status}")

Expand Down
2 changes: 1 addition & 1 deletion bot/txt2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def dream_unsupported(
self,
ctx: Context,
prompt: str,
model: str,
model: str = "",
negative_prompt: str = "",
guidance_scale: float = config.default_cfg,
steps: int = config.default_steps,
Expand Down

0 comments on commit 726ab2d

Please sign in to comment.