Configuration¶
AIMQ can be configured through environment variables and requires proper Supabase queue setup.
Supabase Queue Setup¶
- Enable Queue Integration:
- Go to your Supabase project dashboard
- Navigate to Database → Extensions
- Enable the "pg_net" and "pg_cron" extensions if not already enabled
- Navigate to Database → Queues (Beta)
- Click "Enable Queue"
-
Make sure to enable "Expose Queues via PostgREST"
-
Create Queues:
- In the Queues interface, click "Create a new queue"
- Give your queue a name (this will be referenced in your
@worker.task
decorators) - Configure queue settings as needed
For more details, see the Supabase Queue Documentation.
Environment Variables¶
The following environment variables are supported:
# Required Supabase Configuration
SUPABASE_URL=your-project-url
SUPABASE_KEY=your-service-role-key # Must be service role key, not anon key
# Worker Configuration (Optional)
WORKER_NAME=my-worker # Default: 'peon'
WORKER_LOG_LEVEL=info # Default: 'info'
WORKER_IDLE_WAIT=10.0 # Default: 10.0 seconds
# LangChain Configuration (Optional)
LANGCHAIN_TRACING_V2=true # Enable LangChain tracing
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_API_KEY=your-langchain-api-key
LANGCHAIN_PROJECT=your-project-name
# OpenAI Configuration (If using OpenAI)
OPENAI_API_KEY=your-openai-api-key
Configuration File¶
You can create a .env
file in your project root:
Using Poetry¶
Since this project uses Poetry for dependency management, you can:
-
Install dependencies:
-
Run with environment variables:
Or use your .env
file:
Configuration in Code¶
Access configuration in your code:
from aimq.config import config
# Access configuration values
supabase_url = config.supabase_url
worker_name = config.worker_name
# Create a worker with custom configuration
from aimq import Worker
worker = Worker(
name="custom-worker",
log_level="debug",
idle_wait=5.0
)
Next Steps¶
- See the Quick Start Guide for usage examples
- Learn about Worker Configuration for advanced settings