-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathall_config_parameters.py
More file actions
103 lines (77 loc) · 4.35 KB
/
all_config_parameters.py
File metadata and controls
103 lines (77 loc) · 4.35 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
"""
Minimal example showing all configuration parameters
"""
import time
from proactiveagent import ProactiveAgent, OpenAIProvider
def on_ai_response(response: str):
"""Callback triggered when the AI generates a response."""
print(f"🤖 AI: {response}")
def on_sleep_time_calculated(sleep_time: int, reasoning: str):
"""Callback triggered when the agent calculates how long to sleep."""
print(f"⏰ Sleep: {sleep_time}s - {reasoning}")
def on_decision_made(should_respond: bool, reasoning: str):
"""Callback triggered when the agent makes a decision about whether to respond."""
decision = "✅ RESPOND" if should_respond else "❌ WAIT"
print(f"🧠 {decision}: {reasoning}")
def main():
# Initialize the AI provider - this determines which AI model to use
provider = OpenAIProvider(
model="gpt-5-nano", # The AI model to use for generating responses
)
# Create ProactiveAgent with all available configuration parameters
agent = ProactiveAgent(
# Core configuration
provider=provider, # The AI provider instance (required)
system_prompt="You are a helpful AI assistant.", # Instructions for the AI's behavior
# Decision configuration - controls when and how the agent decides to respond
decision_config={
# === RESPONSE TIMING PARAMETERS ===
# These control the minimum and maximum time between responses
'min_response_interval': 30, # Minimum seconds between responses (prevents spam)
'max_response_interval': 600, # Maximum seconds between responses (prevents abandonment)
# === ENGAGEMENT THRESHOLD PARAMETERS ===
# These control the final decision threshold and engagement level calculation
'engagement_threshold': 0.5, # Final decision threshold (0.0-1.0) - combined score must exceed this to respond
'engagement_high_threshold': 10, # User messages ≥10 in last hour = "high" engagement level
'engagement_medium_threshold': 3, # User messages ≥3 in last hour = "medium" engagement level
# === DECISION WEIGHT PARAMETERS ===
# These weights combine three factors into a final decision score (must sum to 1.0)
'context_relevance_weight': 0.4, # Weight for context factors (questions, urgency, follow-up needs)
'time_weight': 0.3, # Weight for time-based factor (how long since last user message)
'probability_weight': 0.3, # Weight for AI's own decision
# === SLEEP CALCULATION PARAMETERS ===
# These control how the agent determines when to "sleep" (pause activity)
'wake_up_pattern': "Check every 2-3 minutes when active", # Human-readable sleep pattern description
'min_sleep_time': 30, # Minimum seconds to sleep (prevents excessive checking)
'max_sleep_time': 600, # Maximum seconds to sleep (prevents long inactivity)
},
# Logging configuration
log_level="INFO" # Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL
)
# === CALLBACK REGISTRATION ===
# Register different types of callbacks to monitor agent behavior
# Response callback - triggered when AI generates a response
agent.add_callback(on_ai_response)
# Sleep time callback - triggered when agent calculates sleep duration
agent.add_sleep_time_callback(on_sleep_time_calculated)
# Decision callback - triggered when agent decides whether to respond
agent.add_decision_callback(on_decision_made)
# Start the agent - begins the proactive monitoring and decision-making process
agent.start()
print("=== All Configuration Parameters Demo ===")
print("This example demonstrates every available configuration option.")
print("Watch the callbacks to see how each parameter affects behavior.")
print("Type 'quit' to exit.\n")
# Main interaction loop
while True:
message = input("You: ").strip()
if message.lower() == 'quit':
break
# Send message to agent - triggers decision-making process
agent.send_message(message)
# Brief pause to prevent overwhelming the system
time.sleep(1)
# Always stop the agent to clean up resources
agent.stop()
if __name__ == "__main__":
main()