A sophisticated AI-powered bot for the Bluesky social network that uses Google's Gemini, Imagen, and Veo models to provide intelligent responses, image generation, and video creation.
- Real-time Processing: Monitors Bluesky posts via Jetstream WebSocket API
- AI-Powered Responses: Uses Google Gemini for intelligent conversation
- Media Generation: Creates images with Imagen 3 and videos with Veo 2
- Smart Thread Management: Prevents spam and manages conversation depth
- Memory Safety: Implements memory monitoring and cleanup
- Rate Limiting: Built-in API rate limiting for reliability
- Thread Safety: Concurrent processing with proper locking
- Google Search Integration: Grounded responses with search capabilities
- 8000 Python 3.8 or higher
- A Bluesky account with an app password
- Google Gemini API access
- Basic knowledge of environment variables
-
Clone the repository:
git clone <your-repo-url> cd gemini-botsky
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
cp .env.example .env
Edit
.env
and fill in your credentials:BLUESKY_HANDLE=your-handle.bsky.social BLUESKY_PASSWORD=your-app-password GEMINI_API_KEY=your-gemini-api-key
-
Run the bot:
python bot.py
The bot uses BLOCK_NONE
safety settings by default. You can adjust these in the code if needed.
- Gemini API: Minimum 1 second between calls
- Bluesky API: Minimum 0.5 seconds between calls
- Automatic memory monitoring during media processing
- Cleanup of downloaded media after processing
- Cache size limits to prevent memory leaks
All configuration is done via environment variables. See .env.example
for all available options.
Variable | Default | Description |
---|---|---|
MAX_CONVERSATION_THREAD_DEPTH |
50 | Max posts before bot stops replying |
MAX_REPLY_THREAD_DEPTH |
10 | Max posts bot will create in one thread |
MENTION_CHECK_INTERVAL_SECONDS |
15 | How often to check for new mentions |
MAX_THREAD_DEPTH_FOR_CONTEXT |
25 | How much thread history to include |
The bot is designed to work well on various cloud platforms:
- Heroku: Add environment variables in dashboard
- Railway: Connect GitHub repo and set environment variables
- DigitalOcean App Platform: Use the included requirements.txt
- AWS/GCP/Azure: Deploy as container or serverless function
- Set
LOG_LEVEL=WARNING
to reduce log verbosity - Consider using external services for persistence
- Monitor memory usage and adjust limits as needed
The bot automatically sends direct messages to @symm.social for:
- Critical Errors: Startup failures, API initialization problems
- Connection Issues: Persistent Jetstream connection problems
- Startup Notifications: Successful bot initialization with status
Messages are sent via DM when possible, with fallback to public mentions if DMs fail.
The bot provides comprehensive logging:
INFO
: General operation and successful actionsWARNING
: Non-critical issues and fallbacksERROR
: Failed operations and exceptionsDEBUG
: Detailed execution information
Built-in memory monitoring tracks usage during media processing and automatically cleans up resources.
Edit the BOT_SYSTEM_INSTRUCTION
in bot.py
to customize the bot's personality and behavior.
- Images: Triggered by "IMAGE_PROMPT:" in responses
- Videos: Triggered by "VIDEO_PROMPT:" in responses
- Automatic alt-text generation for accessibility
The bot automatically:
- Prevents duplicate replies
- Manages conversation depth
- Handles user-to-user vs bot conversations appropriately
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This bot uses AI models that may generate unexpected content. Always monitor its behavior and adjust safety settings as needed for your use case. The bot is provided as-is without warranties.
For issues, questions, or feature requests:
- Check the existing GitHub issues
- Create a new issue with detailed information
- Include relevant log outputs and configuration (without credentials)
Built with ❤️ by symmetricalboy (@symm.social)