PDF Summarization API
Create a REST API that allows users to upload a 1-page PDF file and get a summary of its content. The API is containerized using Docker.
- Docker installed on your machine.
- Python 3.10 or higher
- An OpenAI API key.
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Create a
.envfile:touch .env
Add your OpenAI API key to the
.envfile:OPENAI_API_KEY=your_openai_api_key
-
Build Docker Image and run the Docker Container:
docker-compose up --build
- Description: Accepts a PDF file upload and returns a summary of its content.
- Request:
curl -X POST http://localhost:8000/summarize -F 'file=@path_to_your_pdf_file' - Response:
{ "summary": "This is the summarized content of the PDF." }
FastAPI provides a built-in interactive API documentation using Swagger UI. To access it:
-
Run the Application: Make sure your Docker container is running:
docker-compose up
-
Open Swagger UI: Open your web browser and go to
http://localhost:8080/docs. -
Interact with the API: You can test the
POST /summarizeendpoint directly from the Swagger UI by uploading a PDF file and receiving the summary in response.
The API will be accessible at http://localhost:8080.