BuddyImagine is a Telegram bot that leverages the power of FAL AI for high-quality image generation and Cloudflare R2 for efficient storage.
- 🤖 AI-Powered Generation: Uses an intelligent agent to understand your prompts.
- 🎨 Multiple Models: Supports various state-of-the-art models like Flux, SDXL, Recraft, and more.
- ☁️ Cloud Storage: Automatically saves all generated images to Cloudflare R2.
- 🔍 Model Discovery: Built-in fuzzy search to find the perfect model for your needs.
/start- Initialize the bot and see the welcome message./generate <prompt>- Generate an image. You can specify the model naturally in the prompt (e.g., "Generate a cyberpunk city using Flux")./models [query]- List available models or search for specific ones (e.g.,/models flux)./help- Show the help message.
-
Clone the repository:
git clone <repository_url> cd BuddyImagine
-
Install dependencies: This project uses
uvfor dependency management.uv sync
-
Configure Environment Variables: Create a
.envfile in the root directory with the following variables:BOT_TOKEN=your_telegram_bot_token OPENAI_API_KEY=your_openai_api_key # For the agent logic FAL_KEY=your_fal_ai_key # For image generation # Cloudflare R2 Configuration R2_ACCESS_KEY_ID=your_r2_access_key R2_SECRET_ACCESS_KEY=your_r2_secret_key R2_BUCKET_NAME=your_bucket_name R2_ENDPOINT_URL=your_r2_endpoint_url
-
Run the Bot:
uv run main.py
- Run Tests:
uv run pytest
- Type Check:
uv run mypy .
-
main.py: Entry point, sets up the bot and polling. -
handlers.py: Telegram message handlers (commands). -
agent.py: logic usingpydantic-aito process prompts and select tools. -
services/:fal.py: Service for interacting with FAL AI API.r2.py: Service for uploading/downloading files to Cloudflare R2.
docker-compose down && docker-compose build --no-cache && docker-compose up -d