rajmethun0's picture
Update README.md
745273a verified
---
license: mit
title: Data Extractor Using Gemini
sdk: docker
emoji: πŸƒ
colorFrom: yellow
colorTo: blue
---
# πŸ“Š Financial Data Extractor Using Gemini
A powerful AI-driven financial document analysis system that automatically extracts, organizes, and generates professional Excel reports from financial documents using Google's Gemini AI models.
## πŸš€ Features
### Core Functionality
- **πŸ“„ Multi-format Document Support**: PDF, DOCX, TXT, and image files
- **πŸ” Intelligent Data Extraction**: AI-powered extraction of financial data points
- **πŸ“Š Smart Data Organization**: Automatic categorization into 12+ financial categories
- **πŸ’» Excel Report Generation**: Professional multi-worksheet Excel reports with charts
- **🎯 Real-time Processing**: Live streaming interface with progress tracking
### Advanced Capabilities
- **πŸ€– Multi-Agent Workflow**: Specialized AI agents for extraction, arrangement, and code generation
- **πŸ’Ύ Session Management**: Persistent storage with SQLite caching
- **πŸ”„ Auto-shutdown**: Intelligent resource management for cloud deployments
- **πŸ“± Modern UI**: Beautiful Gradio-based web interface
- **🌐 Cross-platform**: Works on Windows, Mac, and Linux
- **🐳 Docker Support**: Containerized deployment ready
## πŸ—οΈ Architecture
The system uses a sophisticated multi-agent workflow powered by the Agno framework:
```
πŸ“„ Document Upload
↓
πŸ” Data Extractor Agent
↓ (Structured Financial Data)
πŸ“Š Data Arranger Agent
↓ (Organized Categories)
πŸ’» Code Generator Agent
↓ (Python Excel Code)
πŸ“Š Excel Report Output
```
### Agent Specialization
- **Data Extractor**: Extracts financial data points with confidence scoring
- **Data Arranger**: Organizes data into 12+ professional categories
- **Code Generator**: Creates Python code for Excel report generation
## πŸ“‹ Requirements
### System Requirements
- Python 3.8+
- Google API Key (for Gemini models)
- 2GB+ RAM recommended
- Cross-platform compatible
### Dependencies
```
agno>=1.7.4
gradio
google-generativeai
PyPDF2
Pillow
python-dotenv
pandas
matplotlib
openpyxl
python-docx
lxml
markdown
requests
seaborn
sqlalchemy
websockets
```
## πŸš€ Quick Start
### 1. Clone the Repository
```bash
git clone <repository-url>
cd Data_Extractor_Using_Gemini
```
### 2. Install Dependencies
```bash
pip install -r requirements.txt
```
### 3. Configure Environment
Create a `.env` file:
```env
GOOGLE_API_KEY=your_gemini_api_key_here
```
### 4. Run the Application
```bash
python app.py
```
The application will be available at `http://localhost:7860`
## 🐳 Docker Deployment
### Build and Run
```bash
docker build -t financial-extractor .
docker run -p 7860:7860 --env-file .env financial-extractor
```
### Environment Variables
- `GOOGLE_API_KEY`: Your Google Gemini API key
- `INACTIVITY_TIMEOUT_MINUTES`: Auto-shutdown timeout (default: 30)
## πŸ“– Usage Guide
### 1. Upload Document
- Drag and drop or select your financial document
- Supported formats: PDF, DOCX, TXT, PNG, JPG, JPEG
### 2. Select Processing Mode
- **Quick Analysis**: Standard extraction and organization
- **Custom Prompts**: Use predefined prompt templates for specific document types
### 3. Monitor Progress
- Real-time streaming interface shows each processing step
- Progress indicators for all workflow stages
- Live terminal output for code execution
### 4. Download Results
- Professional Excel report with multiple worksheets
- Organized data categories with charts and formatting
- All intermediate files available for download
## πŸ“Š Output Structure
The generated Excel reports include:
### Worksheets
- **Summary**: Executive overview with key metrics
- **Revenue**: Income and revenue streams
- **Expenses**: Operating and non-operating expenses
- **Assets**: Current and non-current assets
- **Liabilities**: Short-term and long-term liabilities
- **Equity**: Shareholder equity components
- **Cash Flow**: Cash flow statements
- **Ratios**: Financial ratio analysis
- **Charts**: Visual representations of key data
- **Raw Data**: Original extracted data points
### Features
- Professional formatting with consistent styling
- Interactive charts and visualizations
- Dynamic period handling (auto-detects years/quarters)
- Cross-referenced data validation
- Print-ready layouts
## πŸ”§ Configuration
### Model Settings
Configure AI models in `config/settings.py`:
- Data Extractor Model
- Data Arranger Model
- Code Generator Model
- Thinking budgets and retry settings
### Prompt Customization
Customize agent instructions in `instructions/agents/`:
- `data_extractor.md`: Data extraction prompts
- `data_arranger.md`: Data organization prompts
- `code_generator.md`: Excel generation prompts
### Workflow Configuration
Modify workflow behavior in `workflow/financial_workflow.py`:
- Agent configurations
- Tool assignments
- Output formats
## πŸ› οΈ Development
### Project Structure
```
β”œβ”€β”€ app.py # Main Gradio application
β”œβ”€β”€ workflow/ # Core workflow implementation
β”œβ”€β”€ instructions/ # Agent instruction templates
β”œβ”€β”€ prompts/ # Prompt gallery configurations
β”œβ”€β”€ config/ # Application settings
β”œβ”€β”€ utils/ # Utility functions
β”œβ”€β”€ static/ # Static assets
β”œβ”€β”€ models/ # Data models
└── terminal_stream.py # Real-time terminal streaming
```
### Key Components
- **WorkflowUI**: Main interface controller
- **FinancialDocumentWorkflow**: Core processing pipeline
- **AutoShutdownManager**: Resource management
- **TerminalLogHandler**: Real-time logging
- **PromptGallery**: Template management
## πŸ”’ Security & Privacy
- **Local Processing**: All document processing happens locally
- **No Data Storage**: Documents are processed and cleaned up automatically
- **API Key Security**: Environment-based configuration
- **Session Isolation**: Each session has isolated temporary directories
## 🌐 Deployment Options
### Local Development
```bash
python app.py
```
### Production (Gunicorn)
```bash
gunicorn -w 4 -b 0.0.0.0:7860 app:app
```
### Cloud Platforms
- **Hugging Face Spaces**: Ready for deployment
- **Google Cloud Run**: Containerized deployment
- **AWS/Azure**: Standard container deployment
## 🀝 Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## πŸ“ License
This project is licensed under the MIT License - see the LICENSE file for details.
## πŸ†˜ Support
### Common Issues
- **API Key Errors**: Ensure your Google API key is valid and has Gemini access
- **Memory Issues**: Increase system RAM or reduce document size
- **Processing Timeouts**: Check network connectivity and API quotas