This repository provides a functional microservice for Abstractive Text Summarization. It is developed for consistent performance and uses a BART-Large LLM integrated with FastAPI, Docker, and Gunicorn for deployment.
The project is designed to be run using Docker-Compose.
- Docker
- Docker Compose
- Sufficient RAM (A minimum of 12 GB RAM is recommended for the Docker Engine/VM to safely load the model.)
git clone abstractive-summarizer-api
cd abstractive-summarizer-apiThe following command builds the Docker image, caches the model weights inside the image, and starts the API service.
Note: The initial build process may take some time due to the large size of the model. Grab a ☕!
make runEnsure the container is running:
make logsThe API is available on port 8000 of your local machine.
Checks if the service is alive. ✅
- Endpoint:
GET /health - Successful Response (reflects the StatusOutput schema):
{
"status": "ok",
"model_status": "Loading (Awaiting first request)"
}Checks the precise loading status of the AI model. This is the official readiness endpoint.
- Endpoint:
GET /api/v1/status - Successful Response: Returns
{"model_status": "Loaded"}once the model is in memory.
Used to summarize a long text.
- Endpoint:
POST /api/v1/summarize - Content-Type:
application/json - Request Body (Note: Pydantic enforces minimum text length):
{
"text": "The long text goes here...",
"min_length": 30,
"max_length": 150
}- Successful Response:
{
"summary": "The generated, concise, and coherent summary text."
}You can view all API schemas and the interactive testing interface in your browser: 🔎
http://localhost:8000/docs
Checks and automatically fixes code styling (using Black) and import ordering (using Isort).
make formatExecutes unit tests using pytest to verify core functionality, DI, and error handling. The AI model is mocked during these tests for speed and reliability.
make testStops and removes all containers and the network created by Docker Compose:
make clean