This example demonstrates how to use AG2 (formerly AutoGen) multi-agent conversations with Unstructured for intelligent document processing and analysis.
Two AG2 agents collaborate to process and analyze documents:
- Document Agent -- Uses Unstructured to partition documents and extract structured elements (text, tables, titles, narrative)
- Analyst Agent -- Analyzes the extracted content, answers questions, and produces summaries with source references
- Python >= 3.11
- OpenAI API key
- System dependencies:
libmagic-dev,poppler-utils,tesseract-ocr(for PDF/image support)
# Install dependencies
pip install "unstructured[all-docs]" "ag2[openai]>=0.11.4,<1.0"
# Set API key
export OPENAI_API_KEY="your-api-key"
# Run the example (uses sample docs from example-docs/)
python run.py
# Or specify your own document
python run.py --file /path/to/your/document.pdf- Unstructured partitions a document into structured elements (Title, NarrativeText, Table, ListItem, etc.)
- AG2 Document Agent wraps Unstructured as a registered tool, callable by agents
- AG2 Analyst Agent receives extracted elements and produces analysis
- Agents collaborate via AG2 GroupChat with automatic tool execution
- AG2 -- Multi-agent conversation framework (500K+ monthly PyPI downloads)
- Unstructured -- Document ETL for LLMs (25+ file types)