tahamajs's picture
download
raw
5.49 kB
#!/usr/bin/env python3
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
def test_core_components():
print("๐Ÿงช Testing Core Chain of Thought Components...")
try:
print("๐Ÿ“ฆ Testing core structures...")
from src.core.reasoning_structures import ReasoningStep, ReasoningChain
step = ReasoningStep(
step_id="test_step_1",
content="This is a test reasoning step",
step_type="analysis",
confidence=0.8,
dependencies=[],
)
print(f"โœ… ReasoningStep created: {step}")
chain = ReasoningChain(
problem="Test problem: What is 2 + 2?",
steps=[step],
solution="The answer is 4",
total_confidence=0.8,
)
print(f"โœ… ReasoningChain created with {len(chain.steps)} steps")
print("๐Ÿค– Testing basic reasoner...")
from src.core.basic_cot import BasicCoTReasoner
reasoner = BasicCoTReasoner()
test_chain = reasoner.solve_with_cot("What is 5 + 3?")
print(f"โœ… Basic CoT test successful: {len(test_chain.steps)} steps")
print("๐Ÿงฎ Testing mathematical reasoner...")
from src.core.basic_cot import MathematicalCoTReasoner
math_reasoner = MathematicalCoTReasoner()
math_chain = math_reasoner.solve_with_cot("What is 10 * 5?")
print(f"โœ… Mathematical CoT test successful: {len(math_chain.steps)} steps")
print("๐Ÿฅ Testing medical reasoner...")
from src.core.basic_cot import MedicalDiagnosisCoTReasoner
medical_reasoner = MedicalDiagnosisCoTReasoner()
medical_chain = medical_reasoner.solve_with_cot("Patient has fever and cough")
print(f"โœ… Medical CoT test successful: {len(medical_chain.steps)} steps")
print("๐Ÿ’ผ Testing business reasoner...")
from src.core.basic_cot import BusinessStrategyCoTReasoner
business_reasoner = BusinessStrategyCoTReasoner()
business_chain = business_reasoner.solve_with_cot(
"Should we expand our business?"
)
print(f"โœ… Business CoT test successful: {len(business_chain.steps)} steps")
print("\n๐ŸŽ‰ All core components tested successfully!")
return True
except Exception as e:
print(f"โŒ Error testing core components: {e}")
import traceback
traceback.print_exc()
return False
def test_advanced_components():
print("\n๐ŸŒณ Testing Advanced Components...")
try:
print("๐ŸŒฒ Testing Tree of Thought...")
from src.advanced.tree_of_thought import TreeOfThoughtReasoner
tot_reasoner = TreeOfThoughtReasoner(max_depth=3, branching_factor=2)
tot_result = tot_reasoner.solve_with_tot("How can we solve climate change?")
print(
f"โœ… Tree of Thought test successful: {tot_result['total_nodes_explored']} nodes explored"
)
print("๐Ÿ•ธ๏ธ Testing Graph CoT...")
from src.advanced.graph_cot import GraphCoTReasoner
graph_reasoner = GraphCoTReasoner(max_reflections=1)
graph_result = graph_reasoner.solve_with_reflection(
"Should we invest in renewable energy?"
)
print(
f"โœ… Graph CoT test successful: {graph_result['total_nodes']} nodes created"
)
print("\n๐ŸŽ‰ All advanced components tested successfully!")
return True
except Exception as e:
print(f"โŒ Error testing advanced components: {e}")
import traceback
traceback.print_exc()
return False
def test_evaluation():
print("\n๐Ÿ“Š Testing Evaluation Framework...")
try:
from src.evaluation.evaluator import CoTEvaluator
from src.core.basic_cot import BasicCoTReasoner
evaluator = CoTEvaluator()
reasoner = BasicCoTReasoner()
test_problems = ["What is 2 + 2?", "What is 5 * 3?"]
evaluation = evaluator.evaluate_approach(
"Test Reasoner", reasoner, test_problems
)
print(
f"โœ… Evaluation test successful: {evaluation['success_rate']:.2%} success rate"
)
print(f" Accuracy: {evaluation['accuracy']:.3f}")
print(f" Efficiency: {evaluation['efficiency']:.3f}")
print("\n๐ŸŽ‰ Evaluation framework tested successfully!")
return True
except Exception as e:
print(f"โŒ Error testing evaluation framework: {e}")
import traceback
traceback.print_exc()
return False
def main():
print("๐Ÿง  Chain of Thought System - Component Testing")
print("=" * 50)
core_success = test_core_components()
advanced_success = test_advanced_components()
evaluation_success = test_evaluation()
print("\n" + "=" * 50)
print("๐Ÿ“‹ Test Summary:")
print(f"Core Components: {'โœ… PASS' if core_success else 'โŒ FAIL'}")
print(f"Advanced Components: {'โœ… PASS' if advanced_success else 'โŒ FAIL'}")
print(f"Evaluation Framework: {'โœ… PASS' if evaluation_success else 'โŒ FAIL'}")
if all([core_success, advanced_success, evaluation_success]):
print("\n๐ŸŽ‰ All tests passed! System is ready for full execution.")
return True
else:
print("\nโš ๏ธ Some tests failed. Check the errors above.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)

Xet Storage Details

Size:
5.49 kB
ยท
Xet hash:
400252b060c8946a5dd2add921611f006745fdf41d68c93edadba5e4350a03a9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.