This is the repository of the capstone project "Intuitive response on ChatGPT"
The web application, built with FastAPI and HTML, offers a dynamic user experience with chat or messaging capabilities. The application combines a robust backend with an interactive front end.
- FastAPI Framework: Enables efficient and easy handling of HTTP requests.
- Chat Functionalities: Includes endpoints for starting a new chat and sending messages.
- PDF Handling: Integration with fitz library suggests functionality related to PDFs.
- User Input Forms: Facilitates user interaction through forms, buttons, and text areas.
- Responsive Layout: Structured with headers, paragraphs, and divisions for a clean layout.
- Dynamic Content: Utilizes JavaScript for enhanced user experience.
- Clone the repository to your local machine.
- Navigate to the project directory.
- Install the required dependencies:
pip install -r requirements.txt
- Download the data.zip and unzip it into the
webApp2/data/result
folder. - To run the program, change directory to the webApp2, and run
python main.py
and then visit 0.0.0.0:8000
or localhost:8000
- If you encountered problem installing fitz, you can try to install the c++ build tool first. https://visualstudio.microsoft.com/visual-cpp-build-tools/
- If something like
module frontend not found
, try to installPyMuPDF
again. - If something like
connection error: [SSL: CERTIFICATE_VERIFY_FAILED]
pop up, try the following command
pip config set global.trusted-host \
"pypi.org files.pythonhosted.org pypi.python.org" \
--trusted-host=pypi.python.org \
--trusted-host=pypi.org \
--trusted-host=files.pythonhosted.org
pip install certifi
The application relies on various Python libraries including FastAPI, Pydantic, Jinja2, sentence_transformers, and fitz. A complete list can be found in the requirements.txt file.
When integrating new PDFs into our system, it's important to ensure they are processed correctly to maintain the efficiency and accuracy of our application. Here are the steps to follow:
- Creating Company-Year Directories: For each company's annual report, create a new directory within the webApp2/data/result directory directory. The naming convention for these directories should be Company_Year. For example, a directory for Unilever Company's 2023 report would be named Unilever_2023.
- Uploading Annual Reports:
- Single Report per Year: It's important to upload only the final annual report for each year into the respective directory.
- Quarterly Report Handling: Although each quarter might generate a report, only the final annual report should be stored in these directories.
- File Format: Ensure that the reports are in PDF format before uploading.
- Algorithm Compatibility:
- Unique PDF Requirement: Our backend algorithm is designed to process all PDF files within a given directory. Therefore, having more than one PDF file in a directory can disrupt the algorithm's functionality.
- Maintaining Algorithm Integrity: To ensure the algorithm operates correctly, it is essential to have only one PDF file (the final annual report) in each Company_Year directory.
-
The current code version consider context as all the text on the same page with the images/tables. We do provide a way to match context with images/tables, and put them into the caption.json. However, the accuracy can be very low using these captions.
-
To change the match logic, take a look at
match_page
method in main.py, which takescompany_year
and users' query as input and returns the response tables/images