This Discord bot is designed to generate images using AI-powered image generation capabilities. It leverages the AI Power Grid API to create images based on user prompts within a Discord server. The bot is built using Python and the nextcord library, offering a seamless integration with Discord's interface.
- Image Generation: Users can generate images by providing text prompts.
- Customizable Parameters: Allows modification of various image generation parameters such as dimensions, steps, CFG scale, and more.
- Interactive UI: Utilizes Discord's button and modal interfaces for a user-friendly experience.
- Queue Management: Implements a queue system to manage API requests efficiently.
- Logging: Comprehensive logging for easier debugging and monitoring.
The bot is structured into several key components:
- Main Script (
main.py
): Initializes the bot and sets up event handlers. - Image Generation Cog (
cogs/image_generation.py
): Handles image generation commands and user interactions. - Image Generation Utilities (
image_generation_utils.py
): Contains functions for API interactions. - Queue Manager (
queue_manager.py
): Manages the queue of API requests to prevent rate limiting. - Configuration (
config.py
,constants.py
): Stores bot settings and default parameters. - Logging (
utils/logger.py
): Provides logging functionality throughout the application.
- User inputs a prompt using the
!dream
command. - The bot sends an initial status message and starts the image generation process.
- It periodically checks the generation status and updates the status message.
- Once complete, it retrieves and sends the generated image.
- Users can then interact with buttons to modify parameters and regenerate images.
To handle API rate limits, the bot uses a queue system:
- Requests are added to a queue and processed at a controlled rate.
- This ensures compliance with API usage limits and prevents overloading.
The bot implements robust error handling to manage various scenarios:
- API communication errors
- Invalid user inputs
- Unexpected exceptions
Users can customize various aspects of image generation:
- Seed
- Dimensions
- Steps
- CFG Scale
- Sampler
- Model
This bot includes integration with the Flux image generation model, which connects to a local Pinokio server (https://pinokio.computer/). This feature allows for additional image generation capabilities alongside the AI Power Grid API.
Key points about the Flux integration:
- Requires a local Pinokio server running the Flux model
- Accessed through the "Flux it" button in the bot's interface
- Provides an alternative image generation option with different characteristics
To use the Flux integration:
- Ensure you have a Pinokio server set up and running locally
- The bot will automatically connect to the Pinokio server at http://127.0.0.1:7860/
- Use the "Flux it" button in the bot interface to generate images using the Flux model
Note: The Flux integration is an advanced feature and requires additional setup. Make sure your Pinokio server is properly configured before using this feature.
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables in
.env
file - Run the bot:
python main.py
- Support for multiple AI models
- Advanced prompt engineering features
- Integration with more Discord features (e.g., slash commands)
- User preference saving
Contributions to improve the bot are welcome. Please follow the standard fork-and-pull request workflow.
Per model