« blib/lib/SignalWire/Agents/Relay/Event.pm
↑ Summary
blib/lib/SignalWire/Agents/REST/SignalWireClient.pm »
| 1 | package SignalWire::Agents::Skills::Builtin::WikipediaSearch; | ||
| 2 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | extends 'SignalWire::Agents::Skills::SkillBase'; | |
| 6 | |||
| 7 | 3 | ▶ | use SignalWire::Agents::Skills::SkillRegistry; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | SignalWire::Agents::Skills::SkillRegistry->register_skill('wikipedia_search', __PACKAGE__); | |
| 9 | |||
| 10 | 6 | ▶ | has '+skill_name' => (default => sub { 'wikipedia_search' }); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 11 | 6 | ▶ | has '+skill_description' => (default => sub { 'Search Wikipedia for information about a topic and get article summaries' }); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 12 | 6 | ▶ | has '+supports_multiple_instances' => (default => sub { 0 }); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 4 | ▶ | sub setup { 1 } |
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 15 | |||
| 16 | 3 | ▶ | sub register_tools { |
|
Subroutine
register_tools: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 17 | 3 | my ($self) = @_; | |
| 18 | |||
| 19 | $self->define_tool( | ||
| 20 | name => 'search_wiki', | ||
| 21 | description => 'Search Wikipedia for information about a topic and get article summaries', | ||
| 22 | parameters => { | ||
| 23 | type => 'object', | ||
| 24 | properties => { | ||
| 25 | query => { type => 'string', description => 'The search query' }, | ||
| 26 | }, | ||
| 27 | required => ['query'], | ||
| 28 | }, | ||
| 29 | 1 | ▶ | handler => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 30 | 1 | my ($args, $raw) = @_; | |
| 31 | 1 | require SignalWire::Agents::SWAIG::FunctionResult; | |
| 32 | 1 | return SignalWire::Agents::SWAIG::FunctionResult->new( | |
| 33 | response => "Wikipedia search for: $args->{query}" | ||
| 34 | ); | ||
| 35 | }, | ||
| 36 | 3 | ); | |
| 37 | } | ||
| 38 | |||
| 39 | 1 | ▶ | sub _get_prompt_sections { |
|
Subroutine
_get_prompt_sections: called CC=1 SCAR=0.0
| |||
| 40 | return [{ | ||
| 41 | 1 | title => 'Wikipedia Search', | |
| 42 | body => 'You can search Wikipedia for factual information.', | ||
| 43 | bullets => [ | ||
| 44 | 'Use search_wiki to find information about any topic', | ||
| 45 | 'Results include article summaries from Wikipedia', | ||
| 46 | ], | ||
| 47 | }]; | ||
| 48 | } | ||
| 49 | |||
| 50 | 1 | ▶ | sub get_parameter_schema { |
|
Subroutine
get_parameter_schema: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 51 | return { | ||
| 52 | 1 | %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, | |
| 53 | num_results => { type => 'integer', default => 1, min => 1, max => 5 }, | ||
| 54 | no_results_message => { type => 'string' }, | ||
| 55 | }; | ||
| 56 | } | ||
| 57 | |||
| 58 | 3 | 1; | |