-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_installation.py
More file actions
215 lines (172 loc) · 5.64 KB
/
verify_installation.py
File metadata and controls
215 lines (172 loc) · 5.64 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env python3
"""
Verification script to check ACE RAG Gemini installation.
Checks:
- All modules can be imported
- Configuration is valid
- Dependencies are installed
- Basic functionality works
"""
import sys
from pathlib import Path
def check_imports():
"""Check that all modules can be imported."""
print("Checking imports...")
try:
import ace_rag
from ace_rag import Config
from ace_rag.rag_engine import RAGEngine
from ace_rag.gemini_client import GeminiClient
from ace_rag.vector_store import VectorStore
from ace_rag.document_processor import DocumentProcessor
from ace_rag.playbook import Playbook
from ace_rag.ace_generator import ACEGenerator
from ace_rag.ace_reflector import ACEReflector
from ace_rag.ace_curator import ACECurator
print("✓ All modules imported successfully")
return True
except ImportError as e:
print(f"✗ Import error: {e}")
return False
def check_dependencies():
"""Check that required dependencies are installed."""
print("\nChecking dependencies...")
required_packages = [
"google.generativeai",
"pydantic",
"dotenv",
"faiss",
"numpy",
]
missing = []
for package in required_packages:
try:
__import__(package)
print(f" ✓ {package}")
except ImportError:
print(f" ✗ {package} (missing)")
missing.append(package)
if missing:
print(f"\n✗ Missing packages: {', '.join(missing)}")
print("Install with: pip install -r requirements.txt")
return False
print("✓ All dependencies installed")
return True
def check_configuration():
"""Check configuration setup."""
print("\nChecking configuration...")
try:
from ace_rag import Config
from ace_rag.exceptions import ConfigurationException
# Check .env file exists
env_file = Path(".env")
if not env_file.exists():
print(" ⚠ .env file not found")
print(" Copy .env.example to .env and add your API key")
return False
# Try to load config
try:
config = Config.from_env()
print(" ✓ Configuration loaded")
# Check API key is not default
if config.gemini.api_key == "your-api-key-here":
print(" ✗ API key not configured in .env")
return False
print(" ✓ API key configured")
return True
except ConfigurationException as e:
print(f" ✗ Configuration error: {e}")
return False
except Exception as e:
print(f" ✗ Unexpected error: {e}")
return False
def check_data_directories():
"""Check that data directories are created."""
print("\nChecking data directories...")
directories = ["data", "data/vector_store", "data/playbook"]
for dir_path in directories:
path = Path(dir_path)
if path.exists():
print(f" ✓ {dir_path}")
else:
print(f" ⚠ {dir_path} (will be created on first use)")
return True
def check_models():
"""Check that data models work correctly."""
print("\nChecking data models...")
try:
from ace_rag.models import (
Document,
Chunk,
QueryTrajectory,
FusionMethod,
)
# Test Document
doc = Document(
id="test",
content="Test content",
metadata={}
)
assert doc.id == "test"
print(" ✓ Document model")
# Test Chunk
chunk = Chunk(
id="chunk1",
document_id="test",
content="Chunk content",
position=0
)
assert chunk.document_id == "test"
print(" ✓ Chunk model")
# Test QueryTrajectory
trajectory = QueryTrajectory(
id="traj1",
original_query="test",
expanded_query="expanded test",
temperature=0.5,
fusion_method=FusionMethod.MEAN
)
assert trajectory.temperature == 0.5
print(" ✓ QueryTrajectory model")
print("✓ All models working correctly")
return True
except Exception as e:
print(f"✗ Model error: {e}")
return False
def run_verification():
"""Run all verification checks."""
print("=" * 60)
print("ACE RAG Gemini Installation Verification")
print("=" * 60)
checks = [
("Imports", check_imports),
("Dependencies", check_dependencies),
("Configuration", check_configuration),
("Data Directories", check_data_directories),
("Models", check_models),
]
results = {}
for name, check_func in checks:
try:
results[name] = check_func()
except Exception as e:
print(f"\n✗ {name} check failed with error: {e}")
results[name] = False
print("\n" + "=" * 60)
print("Verification Summary")
print("=" * 60)
for name, result in results.items():
status = "✓ PASS" if result else "✗ FAIL"
print(f"{status}: {name}")
all_passed = all(results.values())
if all_passed:
print("\n✓ All checks passed! Installation is ready.")
print("\nNext steps:")
print("1. Run: python examples/basic_usage.py")
print("2. Or: python examples/ace_evolution_demo.py")
return 0
else:
print("\n✗ Some checks failed. Please fix the issues above.")
return 1
if __name__ == "__main__":
sys.exit(run_verification())