FastAPI service for executing prompts with various LLM providers and evaluating outputs.
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp .env.example .env # Edit .env with your API keys and configuration -
Start Redis (required for Celery):
docker-compose up -d redis # Or use local Redis installation -
Start the FastAPI server:
uvicorn main:app --reload
-
Start Celery worker (in a separate terminal):
celery -A app.celery_app worker --loglevel=info
GET /health- Health checkPOST /api/execute- Execute a prompt (queues to Celery)GET /api/task/{task_id}- Get task statusPOST /api/evaluate- Evaluate LLM output
Supported providers:
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Mistral AI
- Google Gemini
Configure API keys in .env:
OPENAI_API_KEYANTHROPIC_API_KEYMISTRAL_API_KEYGOOGLE_API_KEY
Celery is used for async task processing. Tasks are queued in Redis and processed by Celery workers.
celery -A app.celery_app worker --loglevel=infocelery -A app.celery_app flower # Web-based monitoringThe scoring engine evaluates LLM outputs using:
- Semantic similarity (sentence transformers)
- Quality metrics (length, structure, vocabulary)
- Coherence analysis
- Completeness scoring