Skip to content

Repository files navigation

# Financial Document Classification A workflow-based system for classifying financial documents (PDFs) using LlamaCloud services. ## Overview This project uses LlamaCloud's classification service to automatically categorize financial documents into: - Cash Flow Statement - Income Statement - Balance Sheet ## Installation 1. Install dependencies: ```bash uv sync ``` 2. Set up environment variables: ```bash cp .env.example .env ``` Edit `.env` and add your LlamaCloud API key: ``` LLAMA_CLOUD_API_KEY=llx-your-api-key-here ``` ## Local Development Run the workflow server locally: ```bash llamactl serve ``` The API will be available at `http://localhost:4501/deployments/financial-classifier/` Test the workflow: ```bash curl -X POST http://localhost:4501/deployments/financial-classifier/workflows/classify/run \ -H "Content-Type: application/json" \ -d '{"start_event": {"file_paths": ["balance_sheet.pdf", "cash_flow_statement.pdf"]}}' ``` ## Cloud Deployment ### Prerequisites 1. Install `llamactl`: ```bash uv tool install llamactl ``` 2. Authenticate with LlamaCloud: ```bash llamactl auth login ``` 3. Push your code to a Git repository: ```bash git init git add . git commit -m "Initial commit" git remote add origin https://github.com/your-org/your-repo git push -u origin main ``` ### Deploy Create a deployment on LlamaCloud: ```bash llamactl deployments create ``` This will open an interactive Terminal UI where you can: - Set the deployment name (defaults to `financial-classifier`) - Specify the Git repository URL - Select the branch to deploy - Configure secrets (LLAMA_CLOUD_API_KEY will be auto-detected from `.env`) ### Update Deployment To deploy new changes: ```bash git add . git commit -m "Your changes" git push llamactl deployments update ``` ### Monitor Deployment View deployment status and logs: ```bash llamactl deployments get ``` ## Project Structure ``` src/financial_document_classification/ � __init__.py # Package exports � models.py # Pydantic models � events.py # Workflow events � workflow.py # Main workflow logic ``` ## Configuration The deployment is configured in `pyproject.toml`: ```toml [tool.llamadeploy] name = "financial-classifier" llama_cloud = true env_files = [".env"] [tool.llamadeploy.workflows] classify = "financial_document_classification.workflow:workflow" ``` ## Usage ### Python ```python from financial_document_classification import workflow result = await workflow.run(file_paths=["document.pdf"]) for classification in result: print(f"File: {classification.file_path}") print(f"Type: {classification.document_type}") print(f"Confidence: {classification.confidence}") print(f"Reasoning: {classification.reasoning}") ``` ### API After deployment, call the workflow via API: ```bash curl -X POST https://api.cloud.llamaindex.ai/deployments/financial-classifier/workflows/classify/run \ -H "Authorization: Bearer llx-your-api-key" \ -H "Content-Type: application/json" \ -d '{"start_event": {"file_paths": ["document.pdf"]}}' ```

About

Financial document classification LlamaAgent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages