Skip to content

cyclotron-azure/doc-parser

Repository files navigation

Operations Intake & Triage Agent

Multimodal AI system for classifying operational documents (PDF, image, text) and routing them to the right next action. Built with Microsoft Agent Framework and Azure OpenAI.

Summary

What it does:

  • Ingests documents and extracts content (text and/or images).
  • Classifies into CategoryA, CategoryB, or Unknown.
  • Assigns severity, department, next action, and confidence.
  • (Optional) Adds RAG context from a vector store (Qdrant/FAISS).
  • (Optional) Publishes results to downstream systems via webhooks.

Classification types:

  • CategoryA: actionable issues (failures, damage, safety concerns)
  • CategoryB: informational updates
  • Unknown: requires manual review

Quick Start

1) Install dependencies (recommended: uv)

uv sync

2) Configure environment

cp .env.example .env

Required variables:

AZURE_PROJECT_ENDPOINT=https://your-project.westus.ai.azure.com
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_MODEL=gpt-4o

3) Run the basic example

uv run python examples/01_basic_triage.py

API (FastAPI)

Start the server:

uv run uvicorn src.api:app --reload

Health check:

curl http://127.0.0.1:8000/health

Upload file for triage:

curl -F "file=@sample_docs/maintenance_report.txt" \
  http://127.0.0.1:8000/api/v1/triage/file

Supported formats:

  • .pdf (text-based or image-based)
  • .txt
  • .md

Response fields (abridged):

  • document_id
  • classification_type
  • severity
  • summary
  • suggested_department
  • next_action
  • confidence
  • processing_time_ms
  • citations (if RAG enabled)

Status codes:

  • 200 Success
  • 400 Empty file upload
  • 413 File exceeds size limit
  • 415 Unsupported format
  • 422 No extractable content
  • 500 Server error
  • 503 Service not ready

API config (optional):

MAX_DOCUMENT_SIZE_MB=50
AGENT_MODEL=gpt-4o
AGENT_TEMPERATURE=0.3
LOG_LEVEL=INFO

Usage Examples

Run any of the included workflows:

uv run python examples/01_basic_triage.py
uv run python examples/02_document_indexing.py
uv run python examples/03_rag_workflow.py
uv run python examples/04_webhook_integration.py
uv run python examples/05_batch_processing.py

Configuration (Common Options)

USE_FAISS=false
QDRANT_HOST=localhost
QDRANT_PORT=6333

AGENT_MODEL=gpt-4o
AGENT_TEMPERATURE=0.3
AGENT_MAX_TOKENS=2048

WEBHOOK_ENDPOINT=https://api.example.com/webhooks/triage
WEBHOOK_API_KEY=your-webhook-key

LOG_LEVEL=INFO

Project Structure (Brief)

config/   Configuration (env + settings)
src/      Core agent, vector store, document processing, webhooks
examples/ Runnable examples
tests/    Unit tests

Testing

uv run pytest tests/ -v

Notes for Integration

  • Prefer a singleton TriageAgent per process.
  • Add retry/backoff for 429s.
  • Log model diagnostics for slow or failed requests.

Troubleshooting (API)

  • 503: service still initializing; retry after a few seconds.
  • 422: no text or images extracted; verify the PDF or file content.
  • 429: reduce batch size or add delays between requests.

License

MIT License - see LICENSE file

About

Cyclotron Hands-on Interview: Agentic AI Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published