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.
- 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.
-
Clone the repository:
git clone cd
-
Install the dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn pdf_analyzer_app.api:app --reload
- URL:
/upload_pdf/
- Method:
POST
- Description: Upload a PDF file for analysis.
- Parameters:
file
: PDF file to upload.
- Response:
{ "summary": "Summary of the PDF" }
- 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" }
- 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" }
- 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" }
- URL:
/detect_fraud/
- Method:
POST
- Description: Detect fraud in a PDF.
- Parameters:
file
: PDF file to upload.
- Response:
{ "is_fraudulent": true | false }
- 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, ...] }
- 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 }
- 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 }