Skip to content

anuza08/planetAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌌 Q&A Planet

Screenshot 2024-10-27 212211 Screenshot 2024-10-27 212211 Screenshot 2024-10-27 212211 Screenshot 2024-10-27 212211

Added loader for enhancing user experience

Screenshot 2024-10-27 212211

Q&A Planet is a AI platform where you can upload any document and ask question related to it

πŸ›  Technologies used

Frontend Framework

  • ReactJs: For building the user interface.
  • VueJs: For additional components and interactivity.

Backend Framework

  • FastAPI: For building the API efficiently.
  • Python: The programming language used for the backend.

Data Validation and Parsing

  • Pydantic: For validating request and response data.

CORS Handling

  • CORS Middleware from FastAPI: To enable cross-origin resource sharing.

File Handling

  • PyMuPDF: For processing PDF files.

Text Processing

  • LangChain: For text splitting and handling large documents.
  • Hugging Face Transformers: For natural language processing tasks.
  • Sentence Transformers: For embedding sentences and retrieving contextual information.

Database Management

  • SQLAlchemy ORM: For database interactions and object-relational mapping.

πŸ“₯ Installation

Use the package manager pip to install foobar. Copy the proejct url

Frontend

cd ./frontend
npm install

and the frontend server will start

Backend Server

cd ./backend

To install all the dependencies

pip install fastapi uvicorn sqlalchemy pymupdf langchain transformers sentence-transformers fastapi[all]

To run the backend server

uvicorn main:app --reload

the server will run at port

http://127.0.0.1:8000/docs#/

πŸ“‘ API Documentation

BASE URL

http://localhost:8000

πŸš€ Endpoints

1. Upload PDF Document

  • Endpoint: /upload_pdf
  • Method: POST
  • Description: Upload a PDF file to the server for processing.

Request

  • Headers:

    • Content-Type: multipart/form-data
  • Body:

    • file: The PDF file to be uploaded (required).

Response

  • Status Code: 200 OK
  • Response Body:
    {
      "document_id": "string" // The ID of the uploaded document.
    }
    
    

2. Ask a Question

  • Endpoint: /ask_question
  • Method: POST
  • Description: Submit a question related to the uploaded document and receive an answer.

Request

  • Headers:

    • Content-Type: application/json
  • Body:

    • document_id: The ID of the document to ask questions about.
    • question: The question to be asked.

    Response

  • Status Code: 200 OK

  • Response Body:

    {
      "answer": "string" // The answer to the asked question.
    }
    

3. Get Document Questions

  • Endpoint: /document/{document_id}/questions
  • Method: GET
  • Description: Retrieve a list of questions and answers associated with a specific document.

Request

  • Path Parameters:

    • document_id: The ID of the document for which questions are retrieved (required).

    Response

  • Status Code: 200 OK

  • Response Body:

    [
      {
        "question": "string", // The question asked.
         "answer": "string"     // The answer provided.
       }
    ]