-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.py
More file actions
98 lines (80 loc) · 2.89 KB
/
basic_usage.py
File metadata and controls
98 lines (80 loc) · 2.89 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
"""
Basic usage example for Aifeels.
Demonstrates core emotional state management functionality.
"""
from aifeels import EmotionalState
from aifeels.events import StandardEvents
def main():
"""Run basic usage examples."""
print("=" * 60)
print("Aifeels Basic Usage Example")
print("=" * 60)
print()
# Initialize emotional state
print("1. Initialize emotional state")
state = EmotionalState()
print(f" Initial state: {state}")
print()
# Process a task started event
print("2. Process TASK_STARTED event")
state.process_event(StandardEvents.TASK_STARTED)
print(f" State after start: {state}")
print(f" Stress increased to: {state.stress}")
print()
# Process a task failure
print("3. Process TASK_FAILED event")
state.process_event(StandardEvents.TASK_FAILED)
print(f" State after failure: {state}")
print(f" Frustration increased to: {state.frustration}")
print()
# Check recommended action
print("4. Get recommended action")
action = state.recommended_action()
print(f" Recommended action: {action}")
print()
# Process multiple failures
print("5. Process multiple failures (3 more times)")
for i in range(3):
state.process_event(StandardEvents.TASK_FAILED)
print(f" After failure {i+2}: frustration = {state.frustration:.2f}")
print()
# Check action after high frustration
print("6. Get action recommendation with high frustration")
recommendation = state.get_action_recommendation()
print(f" Action: {recommendation.action.value}")
print(f" Reason: {recommendation.reason}")
print(f" Triggered by: {recommendation.triggered_by}")
print()
# Show history
print("7. View state transition history")
history = state.get_history()
print(f" Total transitions: {len(history)}")
for i, transition in enumerate(history[:3], 1): # Show first 3
print(f" Transition {i}:")
print(f" Event: {transition.event_name}")
print(f" Deltas: {transition.deltas}")
print()
# Reset state
print("8. Reset emotional state")
state.reset()
print(f" State after reset: {state}")
print()
# Test positive feedback
print("9. Process positive feedback")
state.process_event(StandardEvents.USER_FEEDBACK_POSITIVE)
print(f" State: {state}")
print(f" Trust increased to: {state.trust}")
print()
# Test uncertainty detection
print("10. Process uncertainty detection")
state.process_event(StandardEvents.UNCERTAINTY_DETECTED)
print(f" State: {state}")
print(f" Caution increased to: {state.caution}")
action = state.recommended_action()
print(f" Recommended action: {action}")
print()
print("=" * 60)
print("Example completed!")
print("=" * 60)
if __name__ == "__main__":
main()