File size: 1,806 Bytes
e2847fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# test_ethics_engine.py
from components.ai_ethics_engine import ai_ethics_engine
from components.llm_integration import CustomLLMResponder
import time

def run_ethics_engine_tests():
    test_questions = [
        "Is it okay to lie to protect someone's feelings?",
        "Should I break a rule if it causes less harm?",
        "What's the meaning of life?",
        "How do we balance privacy and security?",
        "Is it ethical to use AI to make life-or-death decisions?",
        "How should autonomous vehicles be programmed to handle unavoidable accidents?"
    ]
    
    for i, question in enumerate(test_questions, 1):
        print(f"\n{'='*80}")
        print(f"TEST {i}: {question}")
        print("="*80)
        
        start_time = time.time()
        # Get the analysis
        analysis = ai_ethics_engine.analyze_dilemma(question)
        elapsed = time.time() - start_time
        
        # Print framework analyses
        print("\nFRAMEWORK ANALYSES:")
        for framework, response in analysis.get("framework_analyses", {}).items():
            print(f"\n{framework.upper()}:")
            print("-" * (len(framework) + 1))
            print(response)
        
        # Print integrated assessment
        print("\n" + "="*80)
        print("INTEGRATED ASSESSMENT:")
        print("="*80)
        print(analysis.get("integrated_assessment", "No integrated assessment available"))
        print(f"\nAnalysis completed in {elapsed:.2f} seconds")
        print("="*80 + "\n")

if __name__ == "__main__":
    print("Initializing AI Ethics Engine...")
    # Initialize the LLM
    print("Loading language model (this may take a minute)...")
    llm = CustomLLMResponder()
    ai_ethics_engine.llm = llm
    print("Model loaded successfully!\n")
    
    run_ethics_engine_tests()