forked from strands-agents/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpersonal_assistant.py
More file actions
84 lines (73 loc) · 3.43 KB
/
personal_assistant.py
File metadata and controls
84 lines (73 loc) · 3.43 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
import os
from strands import Agent
from strands.models import BedrockModel
from code_assistant import code_assistant
from calendar_assistant import calendar_assistant
from search_assistant import search_assistant
from constants import SESSION_ID
# Show rich UI for tools in CLI
os.environ["STRANDS_TOOL_CONSOLE_MODE"] = "enabled"
model = BedrockModel(
model_id="us.anthropic.claude-sonnet-4-20250514-v1:0",
)
personal_assistant_agent = Agent(
model=model,
system_prompt="You are a personal assistant. Use the agents and tools at your disposal to assist the user.",
tools=[code_assistant, calendar_assistant, search_assistant],
trace_attributes={"session.id": SESSION_ID},
)
if __name__ == "__main__":
print("=============================================================================")
print("🤖 WELCOME TO YOUR PERSONAL ASSISTANT 🤖")
print("=============================================================================")
print("✨ I'm your intelligent coordinator with access to:")
print(" 📅 Calendar Assistant - Schedule and manage appointments")
print(" 💻 Coding Assistant - Write, debug, and manage code")
print(" 🔍 Search Assistant - Research and find information")
print()
print("🎯 I can handle complex requests across multiple domains:")
print(" • 'Schedule a meeting and research the attendees'")
print(" • 'Code a script and schedule time to work on it'")
print(" • 'What's my agenda and help me prepare presentations'")
print()
print("💡 Just tell me what you need - I'll coordinate everything!")
print("🚪 Type 'exit' to quit anytime")
print("=============================================================================")
print()
# Initialize the personal assistant
try:
print("🔄 Initializing Personal Assistant...")
print("✅ Personal Assistant ready!")
print("🤖 All specialized agents are available!")
print()
except Exception as e:
print(f"❌ Error initializing Personal Assistant: {str(e)}")
# Run the agent in a loop for interactive conversation
while True:
try:
user_input = input("👤 You: ").strip()
if not user_input:
print("💭 Please tell me how I can help you, or type 'exit' to quit")
continue
if user_input.lower() in ["exit", "quit", "bye", "goodbye"]:
print()
print("=========================================================")
print("👋 Thank you for using Personal Assistant!")
print("🎉 Have a productive day ahead!")
print("🤖 Come back anytime you need help!")
print("=========================================================")
break
print("🤖 PersonalBot: ", end="")
response = personal_assistant_agent(user_input)
print("\n")
except KeyboardInterrupt:
print("\n")
print("=========================================================")
print("👋 Personal Assistant interrupted!")
print("🤖 See you next time!")
print("=========================================================")
break
except Exception as e:
print(f"❌ An error occurred: {str(e)}")
print("🔧 Please try again or type 'exit' to quit")
print()