blib/lib/SignalWire/Agents/Skills/Builtin/WebSearch.pm

filter: Statementstmt 91.8% 34 / 37 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 93.3% 14 / 15 Podpod 0.0% 0 / 4 totaltotal 86.4% 51 / 59 CC 2 SCAR 1.9
CC
2
Cov
92%
register_tools
2.2
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/SignalWire/Agents/Contexts/ContextBuilder.pm ↑ Summary blib/lib/SignalWire/Agents/Skills/Builtin/Spider.pm »
1 package SignalWire::Agents::Skills::Builtin::WebSearch;
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 ▶use JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 extends 'SignalWire::Agents::Skills::SkillBase';
7  
8 3 ▶use SignalWire::Agents::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 SignalWire::Agents::Skills::SkillRegistry->register_skill('web_search', __PACKAGE__);
10  
11 7 ▶has '+skill_name' => (default => sub { 'web_search' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 7 ▶has '+skill_description' => (default => sub { 'Search the web for information using Google Custom Search API' });
Subroutine __ANON__: called CC=1 SCAR=0.0
13 7 ▶has '+skill_version' => (default => sub { '2.0.0' });
Subroutine __ANON__: called CC=1 SCAR=0.0
14 7 ▶has '+supports_multiple_instances' => (default => sub { 1 });
Subroutine __ANON__: called CC=1 SCAR=0.0
15  
16 4 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
17  
18 3 ▶sub register_tools {
Subroutine register_tools: called CC=2 SCAR=7.9
Pod undocumented
19 3 my ($self) = @_;
20 3 ▶ my $tool_name = $self->params->{tool_name} // 'web_search';
Condition100%2/2
$self->params->{"tool_name"} // "web_search"
l!l
12
MC/DC100%1/1
$self->params->{"tool_name"} // "web_search"
$self->params->{"tool_name"}
Truth table100%2/2
A
A= $self->params->{"tool_name"}
Aresult
11
00
21  
22 $self->define_tool(
23 name => $tool_name,
24 description => 'Search the web for high-quality information, automatically filtering low-quality results',
25 parameters => {
26 type => 'object',
27 properties => {
28 query => { type => 'string', description => 'The search query' },
29 },
30 required => ['query'],
31 },
32 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 0 my ($args, $raw) = @_;
34 0 require SignalWire::Agents::SWAIG::FunctionResult;
35 0 return SignalWire::Agents::SWAIG::FunctionResult->new(
36 response => "Web search results for: $args->{query}"
37 );
38 },
39 3 );
40 }
41  
42 1 ▶sub get_global_data {
Subroutine get_global_data: called CC=1 SCAR=0.0
Pod undocumented
43 return {
44 1 web_search_enabled => JSON::true,
45 search_provider => 'Google Custom Search',
46 quality_filtering => JSON::true,
47 };
48 }
49  
50 1 ▶sub _get_prompt_sections {
Subroutine _get_prompt_sections: called CC=1 SCAR=0.0
51 return [{
52 1 title => 'Web Search Capability (Quality Enhanced)',
53 body => '',
54 bullets => [
55 'Use web_search to find current information',
56 'Results are quality-filtered automatically',
57 ],
58 }];
59 }
60  
61 1 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: called CC=1 SCAR=0.0
Pod undocumented
62 return {
63 1 %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema },
64 api_key => { type => 'string', required => 1, hidden => 1 },
65 search_engine_id => { type => 'string', required => 1, hidden => 1 },
66 num_results => { type => 'integer', default => 3, min => 1, max => 10 },
67 };
68 }
69  
70 3 1;
« blib/lib/SignalWire/Agents/Contexts/ContextBuilder.pm ↑ Summary blib/lib/SignalWire/Agents/Skills/Builtin/Spider.pm »