-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_system.py
More file actions
142 lines (110 loc) · 4.01 KB
/
test_system.py
File metadata and controls
142 lines (110 loc) · 4.01 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
"""
Test script for the project
"""
import sys
import os
def test_llm_backend():
"""Test LLM Backend connection"""
print("Testing LLM Backend Connection...")
try:
from core.llm import LLMBackend
llm = LLMBackend('deepseek-r1:1.5b')
# Test connection
if hasattr(llm, 'test_connection'):
connected = llm.test_connection()
print(f"Connection Test: {'PASS' if connected else 'FAIL'}")
# Test generation
result = llm.generate('What is 2+2?', temperature = 0.1)
print("Generation test pass!")
print(f"Sample Response: {result['text'][:100]}...")
return True
except Exception as e:
print(f"LLM Backend connection failed: {e}")
return False
def test_memory_system():
"""Test Memory System"""
print("Testing Memory System...")
try:
from core.memory import ExperimentMemory
memory = ExperimentMemory("test_experiments")
# Test experiment lifecycle
exp_id = memory.start_experiment("Test problem")
print(f"Experiment started: {exp_id}")
memory.log_iteration({
'hypothesis': {'text': 'test_hypothesis'},
'planner': {'text': 'test_plan'},
'excutor': {'text': 'test_execution'},
'analyzer': {'text': 'test_analyzer'},
'critic': {'continue': True},
})
print('Iteration logged')
memory.end_experiment("Completed")
print("Experiment ended")
# Test Retrieval
experiment = memory.get_experiment(exp_id)
print(f"Experiment Retrieved: {experiment is not None}")
return True
except Exception as e:
print(f"Memory Test System failed: {e}")
return False
def test_tools():
"""Test tool systems"""
print("Testing Tools...")
try:
from tools.symbolic_math import execute_symbolic_math
from tools.physics_simulator import execute_physics_simulations
# Test symbolic math
result = execute_symoblic_math('simplify', expression = 'x**2 + 2*x + 1')
print(f"Symbolic Math result: {'PASS' if result['success'] else 'FAIL'}")
# Test physics simulator
result = execute_physics_simulations('free_fall', initial_height = 10)
print(f"Physics Simulation result: {'PASS' if result['success'] else 'FAIL'}")
return True
except Exception as e:
print(f'Testing tool systems failed: {e}')
return False
def test_agents():
"""Test agent initialization"""
print('Testing agents...')
try:
from core.llm import LLMBackend
from core.agenst import hypothesis, planner, analyzer, critic, executor
llm = LLMBackend('deepseek-r1:1.5b')
# Test agent creation
agents = {
'hypothesis': hypothesis.HypothesisAgent("H", "llm"),
'planner': planner.PlannerAgent('P', 'llm'),
'executor': executor.ExecutorAgent('E', 'llm'),
'analyzer': analyzer.AnalyzerAgent('A', 'llm'),
'critic': critic.CriticAgent('C', 'llm')
}
print("All agents created successfully!")
# Test hypothesis agent with simple input
result = agents['hypothesis'].run({'problem': 'Test problem'})
print(f"Hypothesis Agent Test: {'PASS' if 'hypothesis' in result else 'FAIL'}")
return True
except Exception as e:
print("Agent test failed: {e}")
return False
def main():
"""Run all tests"""
print("AgenticLab Test Suite")
tests = [
test_llm_backend,
test_memory_system,
test_tools,
test_agents
]
results = []
for test in tests:
results.append(test())
print("\n" + "=" * 50)
print(f"Test Results: {sum(results)}/{len(results)} passed")
if all(results):
print("All tests passed! System is ready.")
return 0
else:
print("Some tests failed. Check the errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())