| #!/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.