Skip to main content
AI agent that analyzes uploaded PDF and DOCX documents based on user prompts.

Code

Create document-analyzer.py with the code below, or save it directly from your editor.

Skill Configuration

Create skills/document-processing/skill.yaml:

How It Works

Document Processing
  • extract_text_from_pdf: Parses PDF files using pypdf library
  • extract_text_from_docx: Extracts text from DOCX files
  • Handles file bytes and base64 decoding
  • Multi-file support with combined analysis
A2A Message Handling
  • Processes Bindu A2A FilePart messages
  • Handles both text prompts and file uploads
  • Role-based message filtering (user messages only)
  • Robust error handling for malformed data
Analysis Capabilities
  • Prompt-driven document analysis
  • Research insights extraction (methodology, gaps, findings)
  • Concise summarization capabilities
  • Content-based responses only (no hallucination)
File Support
  • PDF documents via pypdf reader
  • DOCX documents via python-docx
  • MIME type detection and validation
  • Automatic text extraction and processing

Dependencies

Environment Setup

Create .env file:

Run

Examples:
  • “Analyze the uploaded contract and extract all key obligations”
  • “Review the terms and conditions document and highlight any unusual clauses”
  • “Extract key dates and deadlines from the legal agreement”

Example API Calls

Frontend Setup

Open http://localhost:5173 and try to chat with the document analyzer