| 1 | package SignalWire::Agents::Skills::Builtin::GoogleMaps; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | extends 'SignalWire::Agents::Skills::SkillBase'; | |||||||||||
| 6 | |||||||||||||
| 7 | 2 | ▶ | use SignalWire::Agents::Skills::SkillRegistry; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | SignalWire::Agents::Skills::SkillRegistry->register_skill('google_maps', __PACKAGE__); | |||||||||||
| 9 | |||||||||||||
| 10 | 4 | ▶ | has '+skill_name' => (default => sub { 'google_maps' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 4 | ▶ | has '+skill_description' => (default => sub { 'Validate addresses and compute driving routes using Google Maps' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 4 | ▶ | has '+supports_multiple_instances' => (default => sub { 0 }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 3 | ▶ | sub setup { 1 } | ||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 15 | |||||||||||||
| 16 | 2 | ▶ | sub register_tools { | ||||||||||
|
Subroutine
register_tools: called CC=3 SCAR=14.7
Pod
undocumented
| |||||||||||||
| 17 | 2 | my ($self) = @_; | |||||||||||
| 18 | 2 | ▶ | my $lookup_name = $self->params->{lookup_tool_name} // 'lookup_address'; | ||||||||||
|
Condition50%1/2
$self->params->{"lookup_tool_name"} // "lookup_address"
MC/DC0%0/1
$self->params->{"lookup_tool_name"} // "lookup_address"
$self->params->{"lookup_tool_name"}
Truth table50%1/2
A
A= $self->params->{"lookup_tool_name"}
| |||||||||||||
| 19 | 2 | ▶ | my $route_name = $self->params->{route_tool_name} // 'compute_route'; | ||||||||||
|
Condition50%1/2
$self->params->{"route_tool_name"} // "compute_route"
MC/DC0%0/1
$self->params->{"route_tool_name"} // "compute_route"
$self->params->{"route_tool_name"}
Truth table50%1/2
A
A= $self->params->{"route_tool_name"}
| |||||||||||||
| 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 | 0 | ▶ | handler => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | 0 | my ($args, $raw) = @_; | |||||||||||
| 35 | 0 | require SignalWire::Agents::SWAIG::FunctionResult; | |||||||||||
| 36 | 0 | return SignalWire::Agents::SWAIG::FunctionResult->new( | |||||||||||
| 37 | response => "Address lookup for: $args->{address}" | ||||||||||||
| 38 | ); | ||||||||||||
| 39 | }, | ||||||||||||
| 40 | 2 | ); | |||||||||||
| 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 | 0 | ▶ | handler => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 56 | 0 | my ($args, $raw) = @_; | |||||||||||
| 57 | 0 | require SignalWire::Agents::SWAIG::FunctionResult; | |||||||||||
| 58 | 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 | ); | |||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | 2 | ▶ | sub get_hints { | ||||||||||
|
Subroutine
get_hints: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 66 | 2 | return ['address', 'location', 'route', 'directions', 'miles', 'distance']; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 1 | ▶ | sub _get_prompt_sections { | ||||||||||
|
Subroutine
_get_prompt_sections: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | return [{ | ||||||||||||
| 71 | 1 | 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 | 0 | ▶ | sub get_parameter_schema { | ||||||||||
|
Subroutine
get_parameter_schema: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 81 | return { | ||||||||||||
| 82 | 0 | %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, | |||||||||||
| 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 | 2 | 1; | |||||||||||