Make it an importable module
Abandon DuckDB in favor of sqlite3
This commit is contained in:
parent
3a1d1ea86a
commit
55809a9a39
56 changed files with 234 additions and 828 deletions
26
src/gptbot/commands/imagine.py
Normal file
26
src/gptbot/commands/imagine.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from nio.events.room_events import RoomMessageText
|
||||
from nio.rooms import MatrixRoom
|
||||
|
||||
|
||||
async def command_imagine(room: MatrixRoom, event: RoomMessageText, bot):
|
||||
prompt = " ".join(event.body.split()[2:])
|
||||
|
||||
if prompt:
|
||||
bot.logger.log("Generating image...")
|
||||
|
||||
try:
|
||||
images, tokens_used = await bot.image_api.generate_image(prompt, user=room.room_id)
|
||||
except Exception as e:
|
||||
bot.logger.log(f"Error generating image: {e}", "error")
|
||||
await bot.send_message(room, "Sorry, I couldn't generate an image. Please try again later.", True)
|
||||
return
|
||||
|
||||
for image in images:
|
||||
bot.logger.log(f"Sending image...")
|
||||
await bot.send_image(room, image)
|
||||
|
||||
bot.log_api_usage(event, room, f"{bot.image_api.api_code}-{bot.image_api.image_api}", tokens_used)
|
||||
|
||||
return
|
||||
|
||||
await bot.send_message(room, "You need to provide a prompt.", True)
|
Loading…
Add table
Add a link
Reference in a new issue