This project is a web application designed to summarize key points from a CV in PDF format using the OpenAI API and present the results in an Excel file.
The project is organized as follows:
- app/
- routes.py: Contains the main routes and logic for processing PDF files, interacting with the OpenAI API, and generating the Excel file.
- static/
- index.html: HTML file providing a simple interface for uploading PDF files and obtaining generated summaries.
- main.py: The main file that configures and runs the FastAPI application.
- requirements.txt: File containing the dependencies required to run the project.
- .env: Optional file for securely storing the OpenAI API key (this file should be excluded from version control).
Before you begin, ensure you have the following prerequisites installed:
- Python 3.7 or higher
- pip (Python package installer)
- Git
First, clone this repository to your local machine:
git clone https://github.com/portfoliojuanberrios/CVsum.git
cd CVsum
It is recommended to use a virtual environment to manage the project dependencies.
python -m venv venv
venv\Scripts\activate
python3 -m venv venv
source venv/bin/activate
With the virtual environment activated, install the project dependencies using pip:
pip install -r requirements.txt
The project requires an OpenAI API key to function. You need to configure this key securely within the source code.
-
Open the
app/routes.py
file. -
Locate the line where the OpenAI client is initialized:
client = openai.Client(api_key='put open api key')
-
Replace
'put open api key'
with your actual API key. Be sure to keep this key secure and do not share it publicly.
It is recommended not to store the API key directly in the code. You can use a .env
file or configure the key as an environment variable:
-
.env File: Create a
.env
file in the root of the project with the following content:OPENAI_API_KEY=your_api_key_here
-
Modify
routes.py
to read the key from the environment variable:import os client = openai.Client(api_key=os.getenv('OPENAI_API_KEY'))
-
System Environment Variables:
- On Windows:
- Open Control Panel -> System and Security -> System.
- Click on "Advanced system settings" and then "Environment Variables."
- Create a new environment variable named
OPENAI_API_KEY
with your API key as the value.
- On Linux:
export OPENAI_API_KEY=your_api_key_here
- On Windows:
With everything configured, you can run the project using:
uvicorn main:app --reload
This command will start the FastAPI application, and it will be served at http://127.0.0.1:8000
.
To access the web interface:
- Open a web browser and go to
http://127.0.0.1:8000/static/index.html
. - Upload a PDF file and click "Summarize CV" to generate a summary.
- Once the summary is generated, you can download an Excel file with the results.
- Security: Ensure that your API key is not exposed in the public repository. Use a
.gitignore
file to exclude the.env
file if you choose this option. - Compatibility: The project has been tested on Windows 10 and Ubuntu 20.04. Ensure that your environment meets the minimum requirements.
If you wish to contribute to the project, please fork the repository and submit a pull request with your improvements.
This project is licensed under the MIT License. See the LICENSE
file for more details.
Juan A. Berrios Moya
AI & Software Engineer and Researcher
LinkedIn