-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_code.py
More file actions
171 lines (136 loc) · 5.14 KB
/
Copy pathverify_code.py
File metadata and controls
171 lines (136 loc) · 5.14 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
"""
Code Verification Script
Verifies that all modules can be imported normally and basic functionality works.
"""
import sys
import os
# Add project root directory to path
# Note: Update this path to match your installation directory
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_imports():
"""Test if all modules can be imported normally"""
print("="*60)
print("Testing Module Imports")
print("="*60)
try:
print("\n[1/6] Importing config...")
from config import OPENAI_API_KEY, DEFAULT_LLM_MODEL
print("✓ Config module imported successfully")
print(f" - Default model: {DEFAULT_LLM_MODEL}")
print("\n[2/6] Importing utils...")
from utils import get_completion_from_messages, generate_names
print("✓ Utils module imported successfully")
print("\n[3/6] Importing prompts...")
from prompts import opening_prompt, loss_prompt_template
print("✓ Prompts module imported successfully")
print("\n[4/6] Importing agents...")
from agents import Generator, DebateDetector
print("✓ Agents module imported successfully")
print("\n[5/6] Importing optimization...")
from optimization import SymbolicOptimizer
print("✓ Optimization module imported successfully")
print("\n[6/6] Importing main...")
import main
print("✓ Main module imported successfully")
print("\n" + "="*60)
print("All modules imported successfully! ✓")
print("="*60)
return True
except Exception as e:
print(f"\n✗ Import failed: {str(e)}")
import traceback
traceback.print_exc()
return False
def test_basic_functionality():
"""Test basic functionality"""
print("\n\n" + "="*60)
print("Testing Basic Functionality")
print("="*60)
try:
from utils import generate_names
from agents import Generator
from config import DEFAULT_LLM_MODEL
print("\n[1/2] Testing name generation...")
names = generate_names(6)
print(f"✓ Generated {len(names)} names: {names[:3]}...")
print("\n[2/2] Testing Generator initialization...")
generator = Generator(llm_model_name=DEFAULT_LLM_MODEL)
print(f"✓ Generator initialized with prompt: {generator.get_prompt()[:50]}...")
print("\n" + "="*60)
print("Basic functionality tests passed! ✓")
print("="*60)
return True
except Exception as e:
print(f"\n✗ Functionality test failed: {str(e)}")
import traceback
traceback.print_exc()
return False
def check_file_structure():
"""Check file structure"""
print("\n\n" + "="*60)
print("Checking File Structure")
print("="*60)
base_dir = os.path.dirname(os.path.abspath(__file__))
required_files = [
'config/__init__.py',
'config/settings.py',
'utils/__init__.py',
'utils/llm_client.py',
'prompts/__init__.py',
'prompts/debate_prompts.py',
'prompts/optimization_prompts.py',
'agents/__init__.py',
'agents/generator.py',
'agents/detector.py',
'optimization/__init__.py',
'optimization/symbolic_optimizer.py',
'main.py',
'requirements.txt',
'README.md'
]
all_exist = True
for file_path in required_files:
full_path = os.path.join(base_dir, file_path)
if os.path.exists(full_path):
print(f"✓ {file_path}")
else:
print(f"✗ {file_path} - MISSING")
all_exist = False
print("\n" + "="*60)
if all_exist:
print("All required files exist! ✓")
else:
print("Some files are missing! ✗")
print("="*60)
return all_exist
def main():
"""Run all verification tests"""
print("\n\n")
print("#"*60)
print("SALF Code Verification")
print("#"*60)
# Check file structure
structure_ok = check_file_structure()
# Test imports
imports_ok = test_imports()
# Test basic functionality
functionality_ok = test_basic_functionality()
# Summary
print("\n\n" + "#"*60)
print("Verification Summary")
print("#"*60)
print(f"File Structure: {'✓ PASS' if structure_ok else '✗ FAIL'}")
print(f"Module Imports: {'✓ PASS' if imports_ok else '✗ FAIL'}")
print(f"Basic Functionality: {'✓ PASS' if functionality_ok else '✗ FAIL'}")
if structure_ok and imports_ok and functionality_ok:
print("\n🎉 All verification tests passed!")
print("\nNext steps:")
print("1. Configure API keys in config/settings.py or environment variables")
print("2. Run a test with sample data:")
print(" python main.py --input_file data/sample.json --output_file results/test_output.json --max_iterations 1 --max_samples 1")
return 0
else:
print("\n⚠️ Some verification tests failed. Please check the errors above.")
return 1
if __name__ == "__main__":
exit(main())