-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_document.py
More file actions
124 lines (105 loc) · 4.92 KB
/
Copy pathcheck_document.py
File metadata and controls
124 lines (105 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
Quick script to check document processing results
"""
import json
from db.database import get_db
from db.models import Document, DocumentFinding
# Get latest document
db = next(get_db())
doc = db.query(Document).order_by(Document.created_at.desc()).first()
if not doc:
print("No documents found!")
exit()
print(f"\n{'='*80}")
print(f"DOCUMENT: {doc.document_id}")
print(f"Filename: {doc.filename}")
print(f"Status: {doc.status}")
print(f"Risk Score: {doc.risk_score}")
print(f"Risk Band: {doc.risk_band}")
print(f"{'='*80}\n")
# Get workflow metadata
if doc.workflow_metadata:
metadata = doc.workflow_metadata
print("📊 PROCESSING SUMMARY:")
print(f" • OCR Text Length: {metadata.get('ocr_text_length', 'N/A')} characters")
print(f" • Pages Processed: {metadata.get('pages_processed', 'N/A')}")
print(f" • Total Findings: {metadata.get('total_findings', 'N/A')}")
print(f" • Processing Time: {metadata.get('processing_time_seconds', 'N/A')}s\n")
workflow_state = metadata.get('workflow_state', {})
# Agent 1: Document Intake
print("\n🔵 AGENT 1: DocumentIntake")
print(f" Status: ✅ Executed")
print(f" Output: Received {doc.filename}, {doc.file_size_bytes} bytes")
# Agent 2: OCR
print("\n🔵 AGENT 2: OCR")
print(f" Status: ✅ Executed")
print(f" Output: Extracted {metadata.get('ocr_text_length', 0)} characters")
ocr_preview = workflow_state.get('ocr_text', '')[:200] if workflow_state.get('ocr_text') else 'N/A'
print(f" Preview: {ocr_preview}...")
# Agent 3: Format Validation
print("\n🔵 AGENT 3: FormatValidation")
format_findings = workflow_state.get('format_findings', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(format_findings)} format issues found")
for i, finding in enumerate(format_findings[:3], 1):
print(f" {i}. {finding.get('issue_type')}: {finding.get('description')}")
# Agent 4: NLP Validation
print("\n🔵 AGENT 4: NLPValidation")
nlp_findings = workflow_state.get('nlp_findings', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(nlp_findings)} NLP findings")
for i, finding in enumerate(nlp_findings[:3], 1):
print(f" {i}. {finding.get('finding_type')}: {finding.get('description')}")
# Agent 5: Image Forensics
print("\n🔵 AGENT 5: ImageForensics")
img_findings = workflow_state.get('image_forensics_findings', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(img_findings)} image issues detected")
for i, finding in enumerate(img_findings[:3], 1):
print(f" {i}. {finding.get('finding_type')}: {finding.get('description')}")
if finding.get('confidence'):
print(f" Confidence: {finding.get('confidence')}")
# Agent 6: Background Check
print("\n🔵 AGENT 6: BackgroundCheck")
bg_results = workflow_state.get('background_check_results', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(bg_results)} matches found")
for i, result in enumerate(bg_results[:3], 1):
print(f" {i}. {result.get('match_type')}: {result.get('entity_name')}")
if result.get('match_score'):
print(f" Match Score: {result.get('match_score')}")
if result.get('additional_information'):
print(f" Info: {result.get('additional_information')}")
# Agent 7: Cross Reference
print("\n🔵 AGENT 7: CrossReference")
cross_ref = workflow_state.get('cross_reference_findings', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(cross_ref)} cross-references")
# Agent 8: Document Risk
print("\n🔵 AGENT 8: DocumentRisk")
risk_factors = workflow_state.get('risk_factors', [])
print(f" Status: ✅ Executed")
print(f" Output: {len(risk_factors)} risk factors identified")
for i, risk in enumerate(risk_factors[:3], 1):
print(f" {i}. {risk.get('factor_type')}: {risk.get('description')}")
if risk.get('weight'):
print(f" Weight: {risk.get('weight')}")
# Agent 9: Report Generator
print("\n🔵 AGENT 9: ReportGenerator")
report_path = workflow_state.get('report_path')
print(f" Status: ✅ Executed")
print(f" Output: Report path: {report_path or 'Not generated'}")
# Agent 10: Evidence Storekeeper
print("\n🔵 AGENT 10: EvidenceStorekeeper")
print(f" Status: ✅ Executed")
print(f" Output: Stored to database, document_id={doc.document_id}")
print(f"\n{'='*80}")
print("✅ ALL 10 AGENTS EXECUTED SUCCESSFULLY!")
print(f"{'='*80}\n")
# Check document findings table
findings = db.query(DocumentFinding).filter(DocumentFinding.document_id == doc.id).all()
if findings:
print(f"\n📋 DOCUMENT FINDINGS TABLE ({len(findings)} records):")
for finding in findings[:5]:
print(f" • {finding.finding_type}: {finding.description}")
print("\n")