A production-ready FastAPI microservice for processing civic complaints.
- Transcription: Uses
faster-whisperfor local audio-to-text conversion. - Classification: Uses Groq LLM to classify complaints into dynamic labels.
- Extraction: Uses Groq LLM to extract structured data (category, urgency, location, etc.).
-
Clone and Navigate:
cd brain-service -
Environment: Create a
.envfile from.env.example:copy .env.example .env
Add your
GROQ_API_KEY. -
Install Dependencies:
python -m venv .venv .venv\Scripts\activate pip install -r requirements.txt
Note: Ensure
ffmpegis installed on your system. -
Run Server:
uvicorn app.main:app --reload
Accepts audio_url (JSON) or multipart file upload.
# File upload
curl -X POST -F "file=@complaint.mp3" http://localhost:8000/transcribe
# URL upload
curl -X POST -H "Content-Type: application/json" -d "{\"audio_url\": \"https://example.com/audio.mp3\"}" http://localhost:8000/transcribecurl -X POST -H "Content-Type: application/json" -d '{
"text": "There is a massive pothole on the corner of 5th and Main.",
"labels": ["roadwork", "sanitation", "lighting"],
"multi_label": false
}' http://localhost:8000/classifycurl -X POST -H "Content-Type: application/json" -d '{
"text": "Water leaking from a broken pipe since morning at Central Park.",
"labels": ["water", "infrastructure"]
}' http://localhost:8000/extract- Listener Agent: Handles the "hearing" part of the service. It transcribes audio files into text using a local Whisper model.
- Brain Agent: Handles the "reasoning" part. Specially prompted to act as a classifier and data extractor, ensuring predictable JSON outputs for downstream services.