1
0
Files
CommentAutomation/README.md

59 lines
1.5 KiB
Markdown

# CommentAutomation
Python project initialized with uv.
## Quick start
1. Install uv.
2. Sync dependencies:
uv sync --group dev
3. Run the app:
uv run uvicorn comment_automation.main:app --app-dir src --host 0.0.0.0 --port 8000
4. Run tests:
uv run pytest
## Webhooks
Instagram comments webhook endpoint:
- POST /webhooks/instagram/comments
The route validates incoming payloads and enqueues a Celery task.
## LLM task configuration
The Celery task that handles webhook payload forwarding reads these environment variables:
- LLM_ENDPOINT_URL (required): Full HTTP(S) URL for the downstream LLM endpoint.
- LLM_ENDPOINT_API_KEY (optional): Bearer token sent as Authorization header.
- LLM_ENDPOINT_TIMEOUT_SECONDS (optional): Request timeout in seconds. Defaults to 10.
Retry behavior is built into the task:
- Retries transient failures (network/timeouts and HTTP 429/500/502/503/504).
- Exponential backoff enabled.
- Retry delay is jittered.
- Maximum retries is 7.
## Running a Celery worker
The Celery entrypoint is in src/comment_automation/celery_app.py.
It reads these environment variables:
- CELERY_BROKER_URL (optional): Message broker URL. Defaults to redis://localhost:6379/0.
- CELERY_RESULT_BACKEND (optional): Result backend URL. Defaults to redis://localhost:6379/0.
With uv:
uv run celery -A comment_automation.celery_app:celery_app worker --loglevel=info
Without uv (venv already created):
./.venv/bin/celery -A comment_automation.celery_app:celery_app worker --loglevel=info