-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_setup.py
More file actions
119 lines (104 loc) · 3.44 KB
/
Copy pathverify_setup.py
File metadata and controls
119 lines (104 loc) · 3.44 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
"""
Quick setup verification script.
"""
import sys
from pathlib import Path
def verify_setup():
"""Verify that all components are set up correctly."""
print("Verifying setup...")
print("-" * 60)
errors = []
# Check Python packages
print("Checking Python packages...")
try:
import pdfplumber
print(" ✓ pdfplumber")
except ImportError:
errors.append("pdfplumber not installed")
print(" ✗ pdfplumber")
try:
import openpyxl
print(" ✓ openpyxl")
except ImportError:
errors.append("openpyxl not installed")
print(" ✗ openpyxl")
try:
import ollama
print(" ✓ ollama")
except ImportError:
errors.append("ollama not installed")
print(" ✗ ollama")
try:
import pandas
print(" ✓ pandas")
except ImportError:
errors.append("pandas not installed")
print(" ✗ pandas")
# Check Ollama model
print("\nChecking Ollama model...")
try:
import ollama
models_response = ollama.list()
# Handle different response formats
if isinstance(models_response, dict) and 'models' in models_response:
model_names = [model.get('name', '') for model in models_response['models']]
elif isinstance(models_response, list):
model_names = [model.get('name', '') for model in models_response]
else:
model_names = []
if 'llama3.1:8b' in model_names:
print(" ✓ llama3.1:8b model available")
else:
# Not a critical error - user can pull it later
print(f" ⚠ llama3.1:8b not found. Run: ollama pull llama3.1:8b")
print(f" Available models: {model_names[:3]}...")
except Exception as e:
print(f" ⚠ Could not verify Ollama model: {e}")
print(" Make sure Ollama is running: ollama serve")
# Check files
print("\nChecking project files...")
required_files = [
'main.py',
'pdf_extractor.py',
'ai_parser.py',
'excel_writer.py',
'config.json',
'requirements.txt',
'template.xlsx'
]
for file in required_files:
if Path(file).exists():
print(f" ✓ {file}")
else:
errors.append(f"{file} not found")
print(f" ✗ {file}")
# Check directories
print("\nChecking directories...")
required_dirs = ['statements', 'output']
for dir_name in required_dirs:
if Path(dir_name).exists():
print(f" ✓ {dir_name}/")
else:
print(f" ✗ {dir_name}/ (will be created automatically)")
# Summary
print("\n" + "=" * 60)
if errors:
print("SETUP INCOMPLETE")
print("=" * 60)
print("Errors found:")
for error in errors:
print(f" - {error}")
print("\nPlease fix the errors above and try again.")
return False
else:
print("SETUP COMPLETE ✓")
print("=" * 60)
print("\nYou're ready to use LedgerLens!")
print("\nNext steps:")
print("1. Place your PDF statements in the 'statements/' folder")
print("2. Ensure your Excel template is at 'template.xlsx' (or update config.json)")
print("3. Run: python main.py")
return True
if __name__ == "__main__":
success = verify_setup()
sys.exit(0 if success else 1)