| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Prefabs::Concierge; |
|
2
|
|
|
|
|
|
|
# Copyright (c) 2025 SignalWire |
|
3
|
|
|
|
|
|
|
# Licensed under the MIT License. |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
295738
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
122
|
|
|
6
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
141
|
|
|
7
|
2
|
|
|
2
|
|
655
|
use Moo; |
|
|
2
|
|
|
|
|
10769
|
|
|
|
2
|
|
|
|
|
13
|
|
|
8
|
2
|
|
|
2
|
|
2572
|
use JSON qw(encode_json); |
|
|
2
|
|
|
|
|
27
|
|
|
|
2
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Agent::AgentBase'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has venue_name => (is => 'ro', required => 1); |
|
12
|
|
|
|
|
|
|
has services => (is => 'ro', default => sub { [] }); |
|
13
|
|
|
|
|
|
|
has amenities => (is => 'ro', default => sub { {} }); |
|
14
|
|
|
|
|
|
|
has hours_of_operation => (is => 'ro', default => sub { {} }); |
|
15
|
|
|
|
|
|
|
has special_instructions => (is => 'ro', default => sub { [] }); |
|
16
|
|
|
|
|
|
|
has welcome_message => (is => 'ro', default => sub { undef }); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub BUILD { |
|
19
|
11
|
|
|
11
|
0
|
144
|
my ($self, $args) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
11
|
50
|
|
|
|
62
|
$self->name('concierge') if $self->name eq 'agent'; |
|
22
|
11
|
50
|
|
|
|
45
|
$self->route('/concierge') if $self->route eq '/'; |
|
23
|
11
|
|
|
|
|
31
|
$self->use_pom(1); |
|
24
|
|
|
|
|
|
|
|
|
25
|
11
|
|
66
|
|
|
39
|
my $welcome = $self->welcome_message |
|
26
|
10
|
|
|
|
|
43
|
// "Welcome to ${\$self->venue_name}. How can I assist you today?"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
97
|
$self->set_global_data({ |
|
29
|
|
|
|
|
|
|
venue_name => $self->venue_name, |
|
30
|
|
|
|
|
|
|
services => $self->services, |
|
31
|
|
|
|
|
|
|
amenities => $self->amenities, |
|
32
|
|
|
|
|
|
|
}); |
|
33
|
|
|
|
|
|
|
|
|
34
|
11
|
|
|
|
|
18
|
$self->prompt_add_section( |
|
35
|
|
|
|
|
|
|
'Concierge Role', |
|
36
|
11
|
|
|
|
|
68
|
"You are the virtual concierge for ${\$self->venue_name}. $welcome", |
|
37
|
|
|
|
|
|
|
bullets => [ |
|
38
|
|
|
|
|
|
|
'Welcome users and explain available services', |
|
39
|
|
|
|
|
|
|
'Answer questions about amenities, hours, and directions', |
|
40
|
|
|
|
|
|
|
'Help with bookings and reservations', |
|
41
|
|
|
|
|
|
|
'Provide personalized recommendations', |
|
42
|
|
|
|
|
|
|
], |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Services |
|
46
|
11
|
100
|
|
|
|
17
|
if (@{ $self->services }) { |
|
|
11
|
|
|
|
|
41
|
|
|
47
|
10
|
|
|
|
|
27
|
$self->prompt_add_section( |
|
48
|
|
|
|
|
|
|
'Available Services', |
|
49
|
|
|
|
|
|
|
'', |
|
50
|
|
|
|
|
|
|
bullets => $self->services, |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Amenities |
|
55
|
11
|
100
|
|
|
|
18
|
if (%{ $self->amenities }) { |
|
|
11
|
|
|
|
|
34
|
|
|
56
|
9
|
|
|
|
|
13
|
my @amenity_bullets; |
|
57
|
9
|
|
|
|
|
17
|
for my $name (sort keys %{ $self->amenities }) { |
|
|
9
|
|
|
|
|
36
|
|
|
58
|
10
|
|
|
|
|
39
|
my $info = $self->amenities->{$name}; |
|
59
|
10
|
|
|
|
|
24
|
my $desc = "$name"; |
|
60
|
10
|
100
|
|
|
|
29
|
$desc .= " - Hours: $info->{hours}" if $info->{hours}; |
|
61
|
10
|
100
|
|
|
|
36
|
$desc .= " - Location: $info->{location}" if $info->{location}; |
|
62
|
10
|
|
|
|
|
26
|
push @amenity_bullets, $desc; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
$self->prompt_add_section( |
|
65
|
9
|
|
|
|
|
25
|
'Amenities', |
|
66
|
|
|
|
|
|
|
'', |
|
67
|
|
|
|
|
|
|
bullets => \@amenity_bullets, |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Hours |
|
72
|
11
|
100
|
|
|
|
15
|
if (%{ $self->hours_of_operation }) { |
|
|
11
|
|
|
|
|
31
|
|
|
73
|
2
|
|
|
|
|
3
|
my @hour_bullets; |
|
74
|
2
|
|
|
|
|
4
|
for my $day (sort keys %{ $self->hours_of_operation }) { |
|
|
2
|
|
|
|
|
9
|
|
|
75
|
3
|
|
|
|
|
14
|
push @hour_bullets, "$day: $self->{hours_of_operation}{$day}"; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
$self->prompt_add_section( |
|
78
|
2
|
|
|
|
|
7
|
'Hours of Operation', |
|
79
|
|
|
|
|
|
|
'', |
|
80
|
|
|
|
|
|
|
bullets => \@hour_bullets, |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Special instructions |
|
85
|
11
|
100
|
|
|
|
19
|
if (@{ $self->special_instructions }) { |
|
|
11
|
|
|
|
|
34
|
|
|
86
|
2
|
|
|
|
|
10
|
$self->prompt_add_section( |
|
87
|
|
|
|
|
|
|
'Special Instructions', |
|
88
|
|
|
|
|
|
|
'', |
|
89
|
|
|
|
|
|
|
bullets => $self->special_instructions, |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Register check availability tool |
|
94
|
|
|
|
|
|
|
$self->define_tool( |
|
95
|
|
|
|
|
|
|
name => 'check_availability', |
|
96
|
|
|
|
|
|
|
description => 'Check availability for a service or amenity', |
|
97
|
|
|
|
|
|
|
parameters => { |
|
98
|
|
|
|
|
|
|
type => 'object', |
|
99
|
|
|
|
|
|
|
properties => { |
|
100
|
|
|
|
|
|
|
service => { type => 'string', description => 'Service or amenity to check' }, |
|
101
|
|
|
|
|
|
|
date => { type => 'string', description => 'Date to check (optional)' }, |
|
102
|
|
|
|
|
|
|
}, |
|
103
|
|
|
|
|
|
|
required => ['service'], |
|
104
|
|
|
|
|
|
|
}, |
|
105
|
|
|
|
|
|
|
handler => sub { |
|
106
|
1
|
|
|
1
|
|
2
|
my ($a, $raw) = @_; |
|
107
|
1
|
|
|
|
|
504
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
108
|
1
|
|
|
|
|
3
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
109
|
1
|
|
|
|
|
9
|
response => "Checking availability for $a->{service} at ${\$self->venue_name}", |
|
110
|
|
|
|
|
|
|
); |
|
111
|
|
|
|
|
|
|
}, |
|
112
|
11
|
|
|
|
|
131
|
); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |