Overview
Empower AI with powerful document processing capabilities:
- PDF reading and extraction
- Word document parsing
- PowerPoint extraction
- Excel data extraction
- Document format conversion
Trigger scenarios
- The user sends a document and asks to "analyze" or "summarize" it
- The user asks to "extract document content"
- The user asks to "convert to PDF"
- The user asks about specific information in a document
- The user asks to "extract key points from a report/paper"
Supported formats
| Format | Read | Write | Tool |
|---|---|---|---|
| ✅ | ✅ | pdfplumber, PyPDF2 | |
| DOCX | ✅ | ✅ | python-docx |
| PPTX | ✅ | ❌ | python-pptx |
| XLSX | ✅ | ✅ | openpyxl |
| TXT | ✅ | ✅ | Built-in |
| Markdown | ✅ | ✅ | Built-in |
Tool usage
PDF processing
# 提取文本
import pdfplumber
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
print(text)
# 提取表格
with pdfplumber.open("document.pdf") as pdf:
table = pdf.pages[0].extract_tables()
Word documents
from docx import Document
doc = Document("document.docx")
for para in doc.paragraphs:
print(para.text)
# 提取表格
for table in doc.tables:
for row in table.rows:
print([cell.text for cell in row.cells])
PowerPoint
from pptx import Presentation
prs = Presentation("presentation.pptx")
for slide in prs.slides:
for shape in slide.shapes:
if shape.has_text_frame:
print(shape.text)
Workflow
1. 识别文档类型 → 选择正确的工具
2. 读取内容 → 提取文本、表格、图片
3. 分析信息 → 理解结构、提取要点
4. 总结呈现 → 用中文总结给用户
Advanced features
Document summarization
- Extract the main points of the document
- Generate a brief summary
- List key points
Table processing
- Identify table structure
- Extract table data
- Convert to CSV/Excel
Keyword extraction
- Find important nouns/terms
- Identify topics
- Extract key information
Output format
When presenting a document to the user:
- Document type and page count
- Main content summary
- Key points (3-5 items)
- Suggested follow-up actions
Limitations
- Scanned PDFs require OCR
- Complex formatting may be lost
- Images/charts cannot be fully understood