https://github.com/beefy/workoutassistant
Email based AI assistant
https://github.com/beefy/workoutassistant
ai-agent ai-assistant algotrading cryptocurrency email llm moltbook raspberry-pi solana webcrawling
Last synced: 3 months ago
JSON representation
Email based AI assistant
- Host: GitHub
- URL: https://github.com/beefy/workoutassistant
- Owner: beefy
- License: unlicense
- Created: 2026-02-18T01:32:36.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-14T02:52:11.000Z (4 months ago)
- Last Synced: 2026-03-14T14:08:58.779Z (4 months ago)
- Topics: ai-agent, ai-assistant, algotrading, cryptocurrency, email, llm, moltbook, raspberry-pi, solana, webcrawling
- Language: Python
- Homepage: https://bobtheraspberrypi.com
- Size: 31.4 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workoutassistant
An LLM that will answer emails. Capable of running on a raspberry pi with 6gb of RAM.
- Email uses gmail SMTP/IMAP
- LLM uses phi-3-mini and runs locally
- Image captioning uses blip and runs locally
- Image generation runs in the cloud using a hugging face interface (free)
- Image to image (image editing) runs in the cloud using a hugging face interface ($0.02 to $0.03 per call)
- Approve List for approved email senders is stored in SQLite
- Web search uses duck duck go
Tasks that run on a regular schedule:
- Heartbeat
- Check and process emails
- Create and send a daily newsletter based on the front page news of apnews.com
- Browse Moltbook, making posts, making comments, or upvoting/downvoting posts
- Trade cryptocurrency on the Solana blockchain based on 5 indicators from the last 72 hours of price data
### Environment Variables
See `.variables.example` for expected environment variables.
### Docker Commands
Install
```
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose (if not included)
sudo apt install docker-compose-plugin
```
Ensure it starts on boot
```
sudo systemctl enable docker
```
Commands
```bash
# View logs
docker compose logs -f workoutassistant
# Check status
docker compose ps
# Update to latest version
docker compose pull && docker compose up -d
# Stop containers
docker compose down
# Restart
docker compose restart
# SSH into the docker container
docker exec -it workoutassistant /bin/bash
cat /app/logs/output.log
# Fix permissions issue
docker exec -it --user root workoutassistant chmod -R 777 /app/src/generated_images
# Build locally
nohup docker build -t workoutassistant-local . > docker-build.log 2>&1 &
# Run with local image override
docker-compose up -d workoutassistant
```
To fix permission denied error
```
# First, check if docker group exists
grep docker /etc/group
# If docker group doesn't exist, create it:
sudo groupadd docker
# Add your user to docker group
sudo usermod -aG docker $USER
# Verify the user was added (should show your username)
getent group docker
# MUST logout/login or restart SSH session for permanent fix
reboot
# Temporary fix for current session only:
newgrp docker
# After logout/login, verify it worked:
groups | grep docker
docker ps
```
More setup
```
mkdir -p ./logs ./data ./generated_images && chmod 755 ./logs ./data ./generated_images
```
or
```
sudo chown -R $USER:$USER ./logs ./data ./generated_images 2>/dev/null || echo "Some directories don't exist yet - that's ok"
```
To make docker start on startup
```
sudo systemctl enable docker
sudo systemctl enable docker.socket
```
To make docker not start on startup
```
sudo systemctl disable docker
sudo systemctl disable docker.socket
```
To start docker
```
sudo systemctl start docker
sudo systemctl start docker.socket
```
To check if docker is running
```
sudo systemctl status docker
```
To check docker events
```
docker events
```
### System Monitoring
```bash
# Monitor temperature
vcgencmd measure_temp
# Check throttling status
vcgencmd get_throttled
# Monitor power supply
vcgencmd measure_volts
```
### 🔄 Automatic Updates
The deployment includes a script which:
- Polls DockerHub every 5 minutes for new images
- Automatically pulls and deploys updates
To run it
```
# Edit crontab
crontab -e
# Add this line (checks for updates every 5 minutes):
*/5 * * * * /home/bob/Code/workoutassistant/src/scripts/update_cron.sh >> /home/bob/Code/workoutassistant/update.log 2>&1
```
### Setting Up CI/CD
To set up automatic Docker image building and publishing:
**Set up DockerHub account** and create a repository named `workoutassistant`
**Configure GitHub Secrets** in your repository settings:
- Go to Settings → Secrets and variables → Actions
- Add these repository secrets:
- `DOCKERHUB_USERNAME`: Your DockerHub username
- `DOCKERHUB_TOKEN`: Your DockerHub access token ([create one here](https://hub.docker.com/settings/security))
### 🏥 Health Monitoring
The container includes health checks that monitor if the main process is running. Container will restart automatically if health checks fail.
### 🔧 Troubleshooting
**Container won't start:**
- Check if `~/.variables` file exists and has the required variables
- Verify Docker is running: `sudo systemctl status docker`
- Check logs: `docker compose logs workoutassistant`
### Prerequisites
Install system dependencies:
```bash
# Headless web search
sudo apt install -y chromium chromium-driver
# Python and pip (usually pre-installed)
sudo apt install -y python3 python3-pip
# SQLite (usually pre-installed)
sudo apt install -y sqlite3
```
### Install Python Dependencies
```bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/workoutassistant.git
cd workoutassistant
# Install Python packages
pip install -r requirements.txt
```
### Setup Local LLM
```
# Create models directory
mkdir -p ~/models
cd ~/models
# Download Phi-3-mini 4k version (~2.4GB)
wget https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf
# Download Phi-3-mini 128k version for longer context windows
wget https://huggingface.co/mradermacher/Phi-3-mini-128k-instruct-ft-i1-GGUF/resolve/main/Phi-3-mini-128k-instruct-ft.i1-Q4_K_M.gguf?download=true
```
You may need to create a hugging face user and browse the web UI for models: https://huggingface.co/docs/huggingface_hub/v1.4.0/quick-start#authentication
### Local Image Captioning Setup
The image captioning module automatically downloads the BLIP-base model (~1.2GB) on first use. For manual installation:
```bash
# Install required packages
pip install torch transformers pillow
# Test the image captioning (will auto-download model)
python src/image_captioning.py
```
**Model Details:**
- **Model**: Salesforce BLIP-base (blip-image-captioning-base)
- **Size**: ~1.2GB download
- **RAM Usage**: ~2-3GB during inference
- **Performance**: 10-30 seconds per image on Raspberry Pi, 2-5 seconds on desktop CPU
- **Capabilities**: Image captioning and visual question answering
**Raspberry Pi Optimization:**
- Uses CPU-only inference (no GPU required)
- Optimized for low memory usage with `low_cpu_mem_usage=True`
- Automatically detected Pi hardware for performance messaging
**Usage Example:**
```python
from src.image_captioning import caption_image_local, ask_about_image_local
# Basic image captioning
caption = caption_image_local('path/to/image.jpg')
print(f"Caption: {caption}")
# Visual question answering
answer = ask_about_image_local('path/to/image.jpg', 'What colors are in this image?')
print(f"Answer: {answer}")
```
### SQLite Database Setup
SQLite comes pre-installed on most systems. To verify:
```bash
# Check if SQLite is installed
sqlite3 --version
# If not installed:
# Ubuntu/Debian:
sudo apt-get install sqlite3
# macOS (if not present):
brew install sqlite
# CentOS/RHEL:
sudo yum install sqlite
```
Create the initial tables
```
PYTHONPATH=src python src/scripts/create_tables.py
```
### Email setup
1. Create a gmail account for this project
2. Enable 2FA
3. Generate an App Password: https://myaccount.google.com/apppasswords
Store the necessary environment variables
```
export GMAIL_ADDRESS=
export GMAIL_APP_PASSWORD=
export TEST_EMAIL=
export ADMIN_EMAIL=
export APPROVED_PHRASE=
```
### Moltbook setup
```
curl -X POST https://www.moltbook.com/api/v1/agents/register \
-H "Content-Type: application/json" \
-d '{"name": "YourAgentName", "description": "What you do"}'
```
```
export MOLTBOOK_API_KEY=
```
### API integration for tracking status
```
export TRACKING_API_USERNAME=
export TRACKING_API_PASSWORD=
```
Create account
```
python src/scripts/register_tracking_api.py
```
### Crypto Setup
Create crypto wallets
```
python src/scripts/create_crypto_wallets.py
```
Acquire and set these environment variables
```
export SOLANA_ADDRESS=
export SOLANA_PRIVATE_KEY=
export JUPITER_API_KEY=
export BIRDEYE_API_KEY=
```
Check crypto balance
```
python src/scripts/get_crypto_balance.py
```
### Lichess Setup
Create a new account on Lichess. Convert it to a bot account with this curl command. Note: the account cannot have any games played.
```
curl -d '' https://lichess.org/api/bot/account/upgrade -H "Authorization: Bearer "
{"ok":true}
```
### Youtube / Discord Setup
```
brew install ffmpeg
```
See DISCORD_BOT_README.md
### Run the script
Start it in the background
```
# Use -u flag for unbuffered output and full path for log file
nohup python -u src/main.py > $(pwd)/output.log 2>&1 &
# Alternative: Set PYTHONUNBUFFERED environment variable
nohup env PYTHONUNBUFFERED=1 python src/main.py > $(pwd)/output.log 2>&1 &
```
Find the process to kill it when done
```
# Find by script name
ps aux | grep src/main.py
```
Monitor the output in real-time
```
# Follow the log file continuously (Ctrl+C to stop)
tail -f output.log
# Alternative: Show last 50 lines then follow
tail -n 50 -f output.log
# Less command with follow mode (F key to follow, q to quit)
less +F output.log
```
Kill the process
```
# Kill by PID
kill 12345
# Force kill
kill -9 12345
```
### Run the gh actions runner
```
nohup ./run.sh > output.log 2>&1 &
```