| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::GoogleMaps; |
|
2
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
78
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
87
|
|
|
4
|
2
|
|
|
2
|
|
19
|
use Moo; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
773
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1205
|
|
|
8
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('google_maps', __PACKAGE__); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'google_maps' }); |
|
11
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Validate addresses and compute driving routes using Google Maps' }); |
|
12
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 0 }); |
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
0
|
2297
|
sub setup { 1 } |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register_tools { |
|
17
|
2
|
|
|
2
|
0
|
585
|
my ($self) = @_; |
|
18
|
2
|
|
50
|
|
|
25
|
my $lookup_name = $self->params->{lookup_tool_name} // 'lookup_address'; |
|
19
|
2
|
|
50
|
|
|
15
|
my $route_name = $self->params->{route_tool_name} // 'compute_route'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$self->define_tool( |
|
22
|
|
|
|
|
|
|
name => $lookup_name, |
|
23
|
|
|
|
|
|
|
description => 'Look up and validate an address using Google Maps Geocoding', |
|
24
|
|
|
|
|
|
|
parameters => { |
|
25
|
|
|
|
|
|
|
type => 'object', |
|
26
|
|
|
|
|
|
|
properties => { |
|
27
|
|
|
|
|
|
|
address => { type => 'string', description => 'Address to look up' }, |
|
28
|
|
|
|
|
|
|
bias_lat => { type => 'number', description => 'Latitude bias' }, |
|
29
|
|
|
|
|
|
|
bias_lng => { type => 'number', description => 'Longitude bias' }, |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
required => ['address'], |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
handler => sub { |
|
34
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
35
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
36
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
37
|
|
|
|
|
|
|
response => "Address lookup for: $args->{address}" |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
}, |
|
40
|
2
|
|
|
|
|
45
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->define_tool( |
|
43
|
|
|
|
|
|
|
name => $route_name, |
|
44
|
|
|
|
|
|
|
description => 'Compute a driving route between two points', |
|
45
|
|
|
|
|
|
|
parameters => { |
|
46
|
|
|
|
|
|
|
type => 'object', |
|
47
|
|
|
|
|
|
|
properties => { |
|
48
|
|
|
|
|
|
|
origin_lat => { type => 'number', description => 'Origin latitude' }, |
|
49
|
|
|
|
|
|
|
origin_lng => { type => 'number', description => 'Origin longitude' }, |
|
50
|
|
|
|
|
|
|
dest_lat => { type => 'number', description => 'Destination latitude' }, |
|
51
|
|
|
|
|
|
|
dest_lng => { type => 'number', description => 'Destination longitude' }, |
|
52
|
|
|
|
|
|
|
}, |
|
53
|
|
|
|
|
|
|
required => ['origin_lat', 'origin_lng', 'dest_lat', 'dest_lng'], |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
handler => sub { |
|
56
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
57
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
58
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
59
|
|
|
|
|
|
|
response => "Route computed from ($args->{origin_lat},$args->{origin_lng}) to ($args->{dest_lat},$args->{dest_lng})" |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
2
|
|
|
|
|
41
|
); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_hints { |
|
66
|
2
|
|
|
2
|
0
|
14
|
return ['address', 'location', 'route', 'directions', 'miles', 'distance']; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
70
|
|
|
|
|
|
|
return [{ |
|
71
|
1
|
|
|
1
|
|
8
|
title => 'Google Maps', |
|
72
|
|
|
|
|
|
|
body => '', |
|
73
|
|
|
|
|
|
|
bullets => [ |
|
74
|
|
|
|
|
|
|
'Use lookup_address to validate and geocode addresses', |
|
75
|
|
|
|
|
|
|
'Use compute_route to get driving directions between two points', |
|
76
|
|
|
|
|
|
|
], |
|
77
|
|
|
|
|
|
|
}]; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
81
|
|
|
|
|
|
|
return { |
|
82
|
0
|
|
|
0
|
0
|
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
api_key => { type => 'string', required => 1, hidden => 1 }, |
|
84
|
|
|
|
|
|
|
lookup_tool_name => { type => 'string', default => 'lookup_address' }, |
|
85
|
|
|
|
|
|
|
route_tool_name => { type => 'string', default => 'compute_route' }, |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |