memra 0.2.6__tar.gz → 0.2.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memra-0.2.6 → memra-0.2.9}/MANIFEST.in +10 -0
- {memra-0.2.6 → memra-0.2.9}/PKG-INFO +1 -1
- memra-0.2.9/demos/etl_invoice_processing/data/.DS_Store +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/README.md +112 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/.DS_Store +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352259401.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352259823.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352260169.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352260417.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352260599.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352260912.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352261134.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352261563.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352261647.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352261720.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352261811.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352262025.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352262454.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352262702.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352262884.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352263346.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/10352263429.PDF +0 -0
- memra-0.2.9/demos/etl_invoice_processing/data/invoices/invoice_005.pdf +0 -0
- memra-0.2.9/demos/etl_invoice_processing/database_monitor_agent.py +89 -0
- memra-0.2.9/demos/etl_invoice_processing/etl_invoice_demo.py +1078 -0
- memra-0.2.9/demos/etl_invoice_processing/setup_demo_data.py +154 -0
- memra-0.2.9/demos/etl_invoice_processing/simple_pdf_processor.py +181 -0
- {memra-0.2.6 → memra-0.2.9}/memra/__init__.py +1 -1
- {memra-0.2.6 → memra-0.2.9}/memra/cli.py +88 -10
- {memra-0.2.6 → memra-0.2.9}/memra.egg-info/SOURCES.txt +25 -0
- {memra-0.2.6 → memra-0.2.9}/pyproject.toml +1 -1
- {memra-0.2.6 → memra-0.2.9}/setup.py +1 -1
- {memra-0.2.6 → memra-0.2.9}/CHANGELOG.md +0 -0
- {memra-0.2.6 → memra-0.2.9}/LICENSE +0 -0
- {memra-0.2.6 → memra-0.2.9}/README.md +0 -0
- {memra-0.2.6 → memra-0.2.9}/mcp_bridge_server.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/discovery.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/discovery_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/execution.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/models.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/tool_registry.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra/tool_registry_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/app.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/config/config.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/config.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/logic/__init__.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/logic/file_tools.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/logic/invoice_tools.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/logic/invoice_tools_fix.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/mcp_bridge_server.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/check_database.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/clear_database.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/monitor_database.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/release.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/reset_database.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/start_memra.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/scripts/stop_memra.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/server_tool_registry.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_llm_text_to_sql.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_llm_vs_pattern.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_mcp_schema_aware.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_schema_aware_sql.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_schema_aware_sql_simple.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tests/test_text_to_sql_demo.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-ops/tools/mcp_bridge_server.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/accounts_payable.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/accounts_payable_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/accounts_payable_mcp.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/ask_questions.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/invoice_processing.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/propane_delivery.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/examples/simple_text_to_sql.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/__init__.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/discovery.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/discovery_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/execution.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/models.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/tool_registry.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/memra/tool_registry_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/scripts/release.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-sdk/setup.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/accounts_payable/accounts_payable.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/accounts_payable/accounts_payable_client.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/accounts_payable/accounts_payable_mcp.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/accounts_payable/accounts_payable_smart.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/invoice_processing/invoice_processing.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/invoice_processing/smart_invoice_processor.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/logic/__init__.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/logic/file_tools.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/logic/invoice_tools.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/logic/propane_agents.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/mcp_bridge_server.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/propane_delivery/propane_delivery.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/text_to_sql/complete_invoice_workflow_with_queries.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/text_to_sql/complete_text_to_sql_system.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/memra-workflows/text_to_sql/file_discovery_demo.py +0 -0
- {memra-0.2.6 → memra-0.2.9}/requirements.txt +0 -0
- {memra-0.2.6 → memra-0.2.9}/setup.cfg +0 -0
@@ -9,6 +9,13 @@ include docs/*.sql
|
|
9
9
|
include mcp_bridge_server.py
|
10
10
|
recursive-include memra *.py
|
11
11
|
|
12
|
+
# Include ETL demo files
|
13
|
+
include demos/etl_invoice_processing/etl_invoice_demo.py
|
14
|
+
include demos/etl_invoice_processing/database_monitor_agent.py
|
15
|
+
include demos/etl_invoice_processing/simple_pdf_processor.py
|
16
|
+
include demos/etl_invoice_processing/setup_demo_data.py
|
17
|
+
recursive-include demos/etl_invoice_processing/data *
|
18
|
+
|
12
19
|
# Explicitly exclude server-only files and directories
|
13
20
|
exclude app.py
|
14
21
|
exclude server_tool_registry.py
|
@@ -17,6 +24,9 @@ exclude fly.toml
|
|
17
24
|
exclude Dockerfile
|
18
25
|
exclude Procfile
|
19
26
|
exclude docker-compose.yml
|
27
|
+
exclude memra-ops/docker-compose.yml
|
28
|
+
exclude memra-ops/docker-compose.mcp.yml
|
29
|
+
exclude memra-ops/docker/docker-compose.yml
|
20
30
|
recursive-exclude logic *
|
21
31
|
recursive-exclude scripts *
|
22
32
|
recursive-exclude docs *
|
Binary file
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# Demo Data Files
|
2
|
+
|
3
|
+
This directory contains sample data files for the ETL Invoice Processing demo.
|
4
|
+
|
5
|
+
## 📁 Directory Structure
|
6
|
+
|
7
|
+
```
|
8
|
+
data/
|
9
|
+
├── invoices/ # PDF invoice files for processing
|
10
|
+
│ ├── invoice_001.pdf
|
11
|
+
│ ├── invoice_002.pdf
|
12
|
+
│ └── ...
|
13
|
+
└── README.md # This file
|
14
|
+
```
|
15
|
+
|
16
|
+
## 📄 Invoice Files
|
17
|
+
|
18
|
+
The `invoices/` directory contains sample PDF invoice files that demonstrate:
|
19
|
+
|
20
|
+
- **Various invoice formats** from different vendors
|
21
|
+
- **Different data structures** (line items, totals, tax calculations)
|
22
|
+
- **Real-world scenarios** (missing data, edge cases)
|
23
|
+
- **Multiple currencies** and payment terms
|
24
|
+
|
25
|
+
## 🚀 Using the Demo Data
|
26
|
+
|
27
|
+
### Option 1: Auto-Discovery (Recommended)
|
28
|
+
The demo will automatically scan the `invoices/` directory:
|
29
|
+
|
30
|
+
```python
|
31
|
+
# The demo will find and process all PDF files
|
32
|
+
python etl_invoice_demo.py
|
33
|
+
```
|
34
|
+
|
35
|
+
### Option 2: Specific File Processing
|
36
|
+
Process a specific invoice file:
|
37
|
+
|
38
|
+
```python
|
39
|
+
# Update the demo to process a specific file
|
40
|
+
input_data = {
|
41
|
+
"invoice_file": "data/invoices/invoice_001.pdf",
|
42
|
+
"connection": "postgresql://memra:memra123@localhost:5432/memra_invoice_db"
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
### Option 3: External File Processing
|
47
|
+
Copy files from external locations:
|
48
|
+
|
49
|
+
```python
|
50
|
+
# The demo can copy files from Downloads or other locations
|
51
|
+
input_data = {
|
52
|
+
"source_path": "~/Downloads/new_invoice.pdf",
|
53
|
+
"connection": "postgresql://memra:memra123@localhost:5432/memra_invoice_db"
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
## 📊 Expected Data Structure
|
58
|
+
|
59
|
+
Each invoice file should contain:
|
60
|
+
|
61
|
+
- **Vendor Information**: Company name, address, contact details
|
62
|
+
- **Invoice Details**: Invoice number, date, due date
|
63
|
+
- **Line Items**: Description, quantity, unit price, total
|
64
|
+
- **Totals**: Subtotal, tax, shipping, grand total
|
65
|
+
- **Payment Terms**: Due date, payment methods
|
66
|
+
|
67
|
+
## 🔧 Customizing the Data
|
68
|
+
|
69
|
+
### Adding New Invoice Files
|
70
|
+
1. Place new PDF files in the `invoices/` directory
|
71
|
+
2. Ensure they follow the expected invoice format
|
72
|
+
3. Test with the demo to verify processing
|
73
|
+
|
74
|
+
### Modifying Existing Files
|
75
|
+
- Files are processed using AI vision models
|
76
|
+
- No specific format requirements
|
77
|
+
- The system adapts to different invoice layouts
|
78
|
+
|
79
|
+
## 📈 Demo Scenarios
|
80
|
+
|
81
|
+
The included files demonstrate:
|
82
|
+
|
83
|
+
| Scenario | Description |
|
84
|
+
|----------|-------------|
|
85
|
+
| **Standard Invoice** | Typical business invoice with line items |
|
86
|
+
| **Complex Invoice** | Multiple pages, detailed line items |
|
87
|
+
| **Simple Invoice** | Basic invoice with minimal details |
|
88
|
+
| **International** | Different currencies and formats |
|
89
|
+
| **Edge Cases** | Missing data, unusual formats |
|
90
|
+
|
91
|
+
## 🚨 Important Notes
|
92
|
+
|
93
|
+
- **File Size**: Each file is approximately 1MB
|
94
|
+
- **Total Size**: ~20MB for all demo files
|
95
|
+
- **Git LFS**: Not required for these file sizes
|
96
|
+
- **Version Control**: Files are tracked in Git for demo consistency
|
97
|
+
|
98
|
+
## 🔄 Updating Demo Data
|
99
|
+
|
100
|
+
When adding new invoice files:
|
101
|
+
|
102
|
+
1. **Test locally** first
|
103
|
+
2. **Verify processing** with the demo
|
104
|
+
3. **Update this README** if adding new scenarios
|
105
|
+
4. **Commit changes** with descriptive messages
|
106
|
+
|
107
|
+
## 📚 Related Documentation
|
108
|
+
|
109
|
+
- [ETL Demo Guide](../README.md)
|
110
|
+
- [Database Schema](../../../docs/database_schema.sql)
|
111
|
+
- [Sample Data](../../../docs/sample_data.sql)
|
112
|
+
- [Quick Start Guide](../../../QUICK_START.md)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"""
|
2
|
+
Database Monitor Agent
|
3
|
+
Monitors database state before and after ETL processes
|
4
|
+
"""
|
5
|
+
|
6
|
+
from memra import Agent, LLM
|
7
|
+
|
8
|
+
def create_database_monitor_agent():
|
9
|
+
"""Create a database monitoring agent"""
|
10
|
+
|
11
|
+
monitor_llm = LLM(
|
12
|
+
model="llama-3.2-11b-vision-preview",
|
13
|
+
temperature=0.1,
|
14
|
+
max_tokens=1000
|
15
|
+
)
|
16
|
+
|
17
|
+
monitor_agent = Agent(
|
18
|
+
role="Database Monitor",
|
19
|
+
job="Monitor database state and validate data integrity",
|
20
|
+
llm=monitor_llm,
|
21
|
+
sops=[
|
22
|
+
"Connect to database using provided credentials",
|
23
|
+
"Execute monitoring queries to count rows and validate data",
|
24
|
+
"Generate comprehensive monitoring report with statistics",
|
25
|
+
"Flag any data integrity issues or anomalies",
|
26
|
+
"Return structured monitoring results"
|
27
|
+
],
|
28
|
+
systems=["Database"],
|
29
|
+
tools=[
|
30
|
+
{"name": "SQLExecutor", "hosted_by": "mcp"}
|
31
|
+
],
|
32
|
+
input_keys=["table_name", "connection", "monitoring_phase"],
|
33
|
+
output_key="monitoring_report"
|
34
|
+
)
|
35
|
+
|
36
|
+
return monitor_agent
|
37
|
+
|
38
|
+
def get_monitoring_queries(table_name: str, phase: str):
|
39
|
+
"""Get appropriate SQL queries for monitoring phase"""
|
40
|
+
|
41
|
+
queries = {
|
42
|
+
"before": [
|
43
|
+
f"SELECT COUNT(*) as row_count FROM {table_name}",
|
44
|
+
f"SELECT COUNT(*) as null_vendor_count FROM {table_name} WHERE vendor_name IS NULL",
|
45
|
+
f"SELECT COUNT(*) as null_invoice_count FROM {table_name} WHERE invoice_number IS NULL",
|
46
|
+
f"SELECT COUNT(*) as null_amount_count FROM {table_name} WHERE total_amount IS NULL"
|
47
|
+
],
|
48
|
+
"after": [
|
49
|
+
f"SELECT COUNT(*) as row_count FROM {table_name}",
|
50
|
+
f"SELECT COUNT(*) as null_vendor_count FROM {table_name} WHERE vendor_name IS NULL",
|
51
|
+
f"SELECT COUNT(*) as null_invoice_count FROM {table_name} WHERE invoice_number IS NULL",
|
52
|
+
f"SELECT COUNT(*) as null_amount_count FROM {table_name} WHERE total_amount IS NULL",
|
53
|
+
f"SELECT COUNT(*) as duplicate_invoices FROM (SELECT invoice_number, COUNT(*) as cnt FROM {table_name} GROUP BY invoice_number HAVING COUNT(*) > 1) as dups",
|
54
|
+
f"SELECT MIN(total_amount) as min_amount, MAX(total_amount) as max_amount, AVG(total_amount) as avg_amount FROM {table_name}",
|
55
|
+
f"SELECT COUNT(*) as recent_records FROM {table_name} WHERE created_at >= NOW() - INTERVAL '1 hour'"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
|
59
|
+
return queries.get(phase, queries["after"])
|
60
|
+
|
61
|
+
def create_simple_monitor_agent():
|
62
|
+
"""Create a simple database monitoring agent that works with the framework"""
|
63
|
+
|
64
|
+
monitor_llm = LLM(
|
65
|
+
model="llama-3.2-11b-vision-preview",
|
66
|
+
temperature=0.1,
|
67
|
+
max_tokens=1500
|
68
|
+
)
|
69
|
+
|
70
|
+
monitor_agent = Agent(
|
71
|
+
role="Database Monitor",
|
72
|
+
job="Monitor database state and validate data integrity",
|
73
|
+
llm=monitor_llm,
|
74
|
+
sops=[
|
75
|
+
"Connect to database using provided credentials",
|
76
|
+
"Execute monitoring query using sql_query input",
|
77
|
+
"Generate monitoring report with current statistics",
|
78
|
+
"Flag any data integrity issues",
|
79
|
+
"Return structured monitoring results"
|
80
|
+
],
|
81
|
+
systems=["Database"],
|
82
|
+
tools=[
|
83
|
+
{"name": "SQLExecutor", "hosted_by": "mcp", "input_keys": ["sql_query"]}
|
84
|
+
],
|
85
|
+
input_keys=["table_name", "connection", "monitoring_phase", "sql_query"],
|
86
|
+
output_key="monitoring_report"
|
87
|
+
)
|
88
|
+
|
89
|
+
return monitor_agent
|