-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconcierge_agent_example.py
More file actions
162 lines (135 loc) · 4.85 KB
/
Copy pathconcierge_agent_example.py
File metadata and controls
162 lines (135 loc) · 4.85 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env python3
"""
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License.
See LICENSE file in the project root for full license information.
"""
"""
Concierge Agent Example - Demonstrating the ConciergeAgent prefab
This example shows how to use the ConciergeAgent prefab for providing
virtual concierge services with information about amenities and services.
Features demonstrated:
1. Initializing a ConciergeAgent with venue information
2. Configuring amenities and services
3. Running the agent server
"""
import logging
import sys
import argparse
from pathlib import Path
# Import the ConciergeAgent prefab
from signalwire.prefabs import ConciergeAgent
# Basic logging setup
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
stream=sys.stdout,
level=logging.INFO,
)
# Create logger
logger = logging.getLogger("concierge_example")
def main():
parser = argparse.ArgumentParser(description="Run the ConciergeAgent Example")
parser.add_argument(
"--port", type=int, default=3000, help="Port to run the server on"
)
parser.add_argument(
"--host", type=str, default="0.0.0.0", help="Host to bind the server to"
)
args, _ = parser.parse_known_args()
# Find schema.json in the current directory or parent directory
current_dir = Path(__file__).resolve().parent
parent_dir = current_dir.parent
schema_locations = [
current_dir / "schema.json",
parent_dir / "schema.json",
]
schema_path = None
for loc in schema_locations:
if loc.exists():
schema_path = str(loc)
logger.info(f"Found schema.json at: {schema_path}")
break
if not schema_path:
logger.warning(f"Could not find schema.json in: {schema_locations}")
# Define a luxury resort concierge
venue_name = "Oceanview Resort"
# Define services
services = [
"room service",
"spa bookings",
"restaurant reservations",
"activity bookings",
"airport shuttle",
"valet parking",
"concierge assistance",
]
# Define amenities with details
amenities = {
"infinity pool": {
"hours": "7:00 AM - 10:00 PM",
"location": "Main Level, Ocean View",
"description": "Heated infinity pool overlooking the ocean with poolside service.",
"features": "Cabanas, hot tub, kids' splash area",
},
"spa": {
"hours": "9:00 AM - 8:00 PM",
"location": "Lower Level, East Wing",
"description": "Full-service luxury spa offering massages, facials, and body treatments.",
"reservation": "Required",
},
"fitness center": {
"hours": "24 hours",
"location": "2nd Floor, North Wing",
"description": "State-of-the-art fitness center with cardio equipment, weights, and yoga studio.",
"features": "Personal trainers available by appointment",
},
"beach access": {
"hours": "Dawn to Dusk",
"location": "Southern Pathway",
"description": "Private beach access with complimentary chairs, umbrellas, and towels.",
"services": "Beach attendants, food and beverage service",
},
}
# Define hours of operation
hours = {
"check-in": "3:00 PM",
"check-out": "11:00 AM",
"front desk": "24 hours",
"concierge": "7:00 AM - 11:00 PM",
"room service": "24 hours",
}
# Special instructions for the concierge
special_instructions = [
"Always greet guests by name when possible.",
"Offer to make reservations for guests at local attractions.",
"Provide weather updates when discussing outdoor activities.",
"Inform guests about the daily resort activities and events.",
]
# Welcome message
welcome_message = (
"Welcome to Oceanview Resort, where luxury meets comfort. "
"I'm your virtual concierge, ready to assist with any requests "
"or answer questions about our amenities and services. "
"How may I help you today?"
)
# Create the concierge agent
return ConciergeAgent(
venue_name=venue_name,
services=services,
amenities=amenities,
hours_of_operation=hours,
special_instructions=special_instructions,
welcome_message=welcome_message,
schema_path=schema_path,
host=args.host,
port=args.port,
)
if __name__ == "__main__":
agent = main()
# Print credentials
username, password, source = agent.get_basic_auth_credentials(include_source=True)
logger.info("Starting Concierge Agent for Oceanview Resort")
print("\nStarting agent server...")
print("Note: Works in any deployment mode (server/CGI/Lambda)")
agent.run()