| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::WebSearch; |
|
2
|
3
|
|
|
3
|
|
24
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
137
|
|
|
3
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
215
|
|
|
4
|
3
|
|
|
3
|
|
21
|
use Moo; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
22
|
|
|
5
|
3
|
|
|
3
|
|
1374
|
use JSON (); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
182
|
|
|
6
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
37
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
3
|
|
|
|
|
16
|
|
|
|
3
|
|
|
|
|
1629
|
|
|
9
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('web_search', __PACKAGE__); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'web_search' }); |
|
12
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Search the web for information using Google Custom Search API' }); |
|
13
|
|
|
|
|
|
|
has '+skill_version' => (default => sub { '2.0.0' }); |
|
14
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 1 }); |
|
15
|
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
0
|
2359
|
sub setup { 1 } |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register_tools { |
|
19
|
3
|
|
|
3
|
0
|
541
|
my ($self) = @_; |
|
20
|
3
|
|
100
|
|
|
22
|
my $tool_name = $self->params->{tool_name} // 'web_search'; |
|
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
|
|
|
|
|
|
|
handler => sub { |
|
33
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
34
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
35
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
36
|
|
|
|
|
|
|
response => "Web search results for: $args->{query}" |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
3
|
|
|
|
|
43
|
); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_global_data { |
|
43
|
|
|
|
|
|
|
return { |
|
44
|
1
|
|
|
1
|
0
|
13
|
web_search_enabled => JSON::true, |
|
45
|
|
|
|
|
|
|
search_provider => 'Google Custom Search', |
|
46
|
|
|
|
|
|
|
quality_filtering => JSON::true, |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
51
|
|
|
|
|
|
|
return [{ |
|
52
|
1
|
|
|
1
|
|
6
|
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
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
62
|
|
|
|
|
|
|
return { |
|
63
|
1
|
|
|
1
|
0
|
3129
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
1
|
|
|
|
|
5
|
|
|
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
|
|
|
|
|
|
|
1; |