Skip to content

The PDF Analyzer Application is a FastAPI-based application designed to process PDF files.

Notifications You must be signed in to change notification settings

Pavelevich/iapdfanalizer

Repository files navigation

PDF Analyzer Application

Overview

The PDF Analyzer Application is a FastAPI-based application designed to process PDF files, allowing users to upload PDFs, ask questions about their content, analyze sentiment, and generate new PDF documents based on user-defined instructions. The application utilizes the Ollama API to analyze and generate text responses, providing powerful capabilities for extracting insights from PDF documents.

Features

  • Upload PDF: Users can upload a PDF file for analysis.
  • Ask Questions: Users can ask questions related to the content of the uploaded PDF and receive answers generated by the Ollama API.
  • Generate PDF: Users can instruct the application to create a new PDF document based on the analysis of the uploaded PDF content.
  • Analyze Sentiment: Users can analyze the sentiment of the text extracted from the uploaded PDF, providing insights into the emotional tone of the content.
  • Detect Fraud: Users can detect fraudulent activities within the PDF.
  • Count Tokens: Users can count the number of tokens (words) in the text extracted from the PDF.

Installation

  1. Clone the repository:

    git clone 
    cd 
  2. Install the dependencies:

    pip install -r requirements.txt
  3. Run the application:

    uvicorn pdf_analyzer_app.api:app --reload

API Endpoints

Upload PDF

  • URL: /upload_pdf/
  • Method: POST
  • Description: Upload a PDF file for analysis.
  • Parameters:
    • file: PDF file to upload.
  • Response:
    {
      "summary": "Summary of the PDF"
    }

Ask Questions

  • URL: /ask_question/
  • Method: POST
  • Description: Ask a question about the content of an uploaded PDF.
  • Parameters:
    • question: Question to ask.
    • file: PDF file to upload.
  • Response:
    {
      "answer": "Answer to the question"
    }

Generate PDF

  • URL: /generate_pdf/
  • Method: POST
  • Description: Generate a new PDF document based on user-defined instructions.
  • Parameters:
    • instruction: Instruction for generating the content.
    • file: PDF file to upload.
  • Response:
    {
      "message": "PDF generated successfully",
      "filename": "generated_output.pdf"
    }

Analyze Sentiment

  • URL: /analyze_sentiment/
  • Method: POST
  • Description: Analyze the sentiment of the text extracted from an uploaded PDF.
  • Parameters:
    • file: PDF file to upload.
  • Response:
    {
      "sentiment": "Result of sentiment analysis"
    }

Detect Fraud

  • URL: /detect_fraud/
  • Method: POST
  • Description: Detect fraud in a PDF.
  • Parameters:
    • file: PDF file to upload.
  • Response:
    {
      "is_fraudulent": true | false
    }

Ask Questions with Different Parameter (/ask_question_2/)

  • URL: /ask_question_2/
  • Method: POST
  • Description: Another method to ask questions about the content of a PDF.
  • Parameters:
    • question: Question to ask.
    • file: PDF file to upload.
  • Response:
    {
      "answer": "Answer to the question",
      "page_references": [1, 2, ...]
    }

Count Tokens

  • URL: /count_tokens/
  • Method: POST
  • Description: Count tokens in the text extracted from the PDF.
  • Parameters:
    • file: PDF file to upload.
  • Response:
    {
      "tokens_per_page": [number of tokens per page],
      "total_tokens": total number of tokens
    }

Ask Questions with Parallel Processing

  • URL: /ask_question_par/
  • Method: POST
  • Description: Ask questions about the content of a PDF using parallel processing.
  • Parameters:
    • question: Question to ask.
    • file: PDF file to upload.
  • Response:
    {
      "status": "Processing complete",
      "satisfaction_results": [{ "pages": [page], "result": percentage }],
      "general_result": general percentage
    }

About

The PDF Analyzer Application is a FastAPI-based application designed to process PDF files.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages