Giter Site home page Giter Site logo

umairhaider / pdftogpt Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 19.43 MB

The Backend of PDFtoGPT Application which enables you to interact with any PDF document after uploading it or generate a PowerPoint presentation from it.

License: MIT License

Dockerfile 1.83% Python 98.17%
fastapi openai pdf powerpoint-presentations

pdftogpt's Introduction

PDF-to-GPT FastAPI App (Backend)

PDF-to-GPT is a FastAPI application that leverages OpenAI's GPT model to generate summaries and answer questions based on uploaded PDF documents. This application also generates PowerPoint Presentation for the PDF you uploaded. This is the Backend part of the application.

Build


Features

  • Upload a PDF document and get a summary generated by ChatGPT.
  • Ask questions about the uploaded PDF and get answers generated by GPT-3.
  • Get a PowerPoint Presentation for the PDF you uploaded in seconds.

Installation

  1. Clone the repository:

    git clone https://github.com/umairhaider/pdftogpt.git
    
  2. Install the dependencies

    pip install -r requirements.txt
    
    

Usage

  1. Rename .env-temp to .env and put your OpenAI API keys and other relevant environment variables. These are only used for development environment. The actual Production CI secrets and variables are stored in Github Actions.

  2. Start the FastAPI server:

    uvicorn main:app --reload
    
  3. Open your browser and navigate to http://localhost:8000/docs to access the application.

  4. Running the tests:

    pytest -m order
    

API Endpoints

  1. POST api/v1/signin/: Get JWT tokens to access the other endpoints.
  2. POST api/v1/upload_pdf/: Upload a PDF file to generate a summary.
  3. POST api/v1/ask_question/: Ask a question about the uploaded PDF and get an answer.
  4. POST api/v1/get_presentation/: Generates PowerPoint Presention for the PDF you uploaded.

Technologies Used

  1. FastAPI: A modern, fast (high-performance), web framework for building APIs with Python 3.7+.
  2. PDFPlumber: A library for extracting text from PDF files.
  3. OpenAI: GPT language model for generating text.

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.

Code Contribution rules

Git commit message should follow the following rules:

Add the following approved tags while pushing the commits:

feat – a new feature is introduced with the changes fix – a bug fix has occurred chore – changes that do not relate to a fix or feature and don't modify src or test files (for example updating dependencies) refactor – refactored code that neither fixes a bug nor adds a feature docs – updates to documentation such as a the README or other markdown files style – changes that do not affect the meaning of the code, likely related to code formatting such as white-space, missing semi-colons, and so on. test – including new or correcting previous tests perf – performance improvements ci – continuous integration related build – changes that affect the build system or external dependencies revert – reverts a previous commit example: feat: add JWT headers to login API fix: bug preventing Firefox users to login

Merge and PR: Before creating a PR squash all the commits into one.

License

This project is licensed under the MIT License.

pdftogpt's People

Contributors

umairhaider avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pdftogpt's Issues

🎨 Streamlit based User Interface

Is your feature request related to a problem? Please describe.
This is probably going to be the most important component of this application. It will add the user-interface to the FastAPI application.

Describe the solution you'd like
The user-interface component will call the FastAPI endpoints to serve as a front-end. It will contain screens for the following use-cases:

  1. User Sign In
  2. PDF Upload and interaction
  3. PDF Upload and generate PPTX

Describe alternatives you've considered
An alternative solution for the sign-in screen can be connecting it with "Sign in with Google" feature which will make it more easy to integrate with the JWT based authentication.

Additional context
Streamlit is a promising open-source Python library, which enables developers to build attractive user interfaces in no time. Streamlit is the easiest way especially for people with no front-end knowledge to put their code into a web application: No front-end (html, js, css) experience or knowledge is required.

✨Improving the Contextual Memory

Is your feature request related to a problem? Please describe.
The application is now maintaining the context/knowledge-base in a separate module inside the application which is not the standard implementation. It might cause issues.

Describe the solution you'd like
🦜Langchain framework provides ConversationBufferMemory, ConversationBufferWindowMemory, ConversationBufferTokenMemory, and ConversationSummaryBufferMemory. These all kind of memories should be tested and a well fitting memory type should be selected for persisting the memory.

Describe alternatives you've considered
An alternative approach to improve the system can be introducing multiple use-cases for each memory type to provide better user-experience.

Additional context
Documentation reference: https://python.langchain.com/en/latest/modules/memory/how_to_guides.html

🧪 Improve the test coverage more

Is your feature request related to a problem? Please describe.
The test coverage is not covering each and every line of code. An improvement should be introduced for this problem.

Describe the solution you'd like
Introducing new tests cases should resolve this issue.

✨Shifting the project to Langchain

Is your feature request related to a problem? Please describe.
This feature request is based on the investigation done in issue #10

Describe the solution you'd like
This is a new feature to integrate LangChain into the project to work with files more efficiently.

Describe alternatives you've considered
This feature request is based on the investigation done in the issue mentioned in the description.

Additional context
Langchain framework makes it easy to deal with files context in OpenAI APIs.

How can we transition from conventional OpenAI API calls to a Langchain-based approach?

Describe the issue
Most of the OpenAI API-based applications have shifted from conventional API calls to the Langchain approach. It provides a better solution for maintaining the context of the provided files in the OpenAI model and directs all queries solely to the files within the context. We are still using the conventional API calls.

What needs investigating
It needs to be investigated that whether we can shift from conventional API calls to a Langchain based solution in our API calls or not.

Additional context
LangChain is a framework designed to simplify the creation of applications using large language models. As a language model integration framework, LangChain's use-cases largely overlap with those of language models in general, including document analysis and summarization, chatbots, and code analysis.

🔧 The file and folder structure should be improved

Is your feature request related to a problem? Please describe.
The project is not following the FastAPI recommended files and folder structure.

Describe the solution you'd like
New files and folders can be introduced to to make it more standardized and to improve readability of the code.

Describe alternatives you've considered
Alternatively, another more better structure can also be used but only with a strong justification.

Additional context
FastAPI Docs: https://fastapi.tiangolo.com/tutorial/bigger-applications/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.