File Coverage

blib/lib/SignalWire/Agents/Skills/Builtin/NativeVectorSearch.pm
Criterion Covered Total %
statement 25 28 89.2
branch n/a
condition 5 6 83.3
subroutine 9 10 90.0
pod 0 4 0.0
total 39 48 81.2


line stmt bran cond sub pod time code
1             package SignalWire::Agents::Skills::Builtin::NativeVectorSearch;
2 3     3   42 use strict;
  3         10  
  3         147  
3 3     3   20 use warnings;
  3         7  
  3         171  
4 3     3   34 use Moo;
  3         61  
  3         25  
5             extends 'SignalWire::Agents::Skills::SkillBase';
6              
7 3     3   1492 use SignalWire::Agents::Skills::SkillRegistry;
  3         9  
  3         1878  
8             SignalWire::Agents::Skills::SkillRegistry->register_skill('native_vector_search', __PACKAGE__);
9              
10             has '+skill_name' => (default => sub { 'native_vector_search' });
11             has '+skill_description' => (default => sub { 'Search document indexes using vector similarity and keyword search (local or remote)' });
12             has '+supports_multiple_instances' => (default => sub { 1 });
13              
14 4     4 0 2340 sub setup { 1 }
15              
16             sub register_tools {
17 3     3 0 537 my ($self) = @_;
18 3   100     64 my $tool_name = $self->params->{tool_name} // 'search_knowledge';
19 3   100     21 my $description = $self->params->{description} // 'Search the local knowledge base for information';
20              
21             $self->define_tool(
22             name => $tool_name,
23             description => $description,
24             parameters => {
25             type => 'object',
26             properties => {
27             query => { type => 'string', description => 'The search query' },
28             count => { type => 'integer', description => 'Number of results', default => 3 },
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 => "Vector search for: $args->{query}"
37             );
38             },
39 3         82 );
40             }
41              
42             sub get_hints {
43 1     1 0 9 my ($self) = @_;
44 1         5 my @base = ('search', 'find', 'look up', 'documentation', 'knowledge base');
45 1   50     3 push @base, @{ $self->params->{hints} // [] };
  1         80  
46 1         7 return \@base;
47             }
48              
49             sub _get_prompt_sections {
50             return [{
51 1     1   9 title => 'Knowledge Search',
52             body => 'You have access to a document search capability.',
53             bullets => ['Use the search tool to find relevant information'],
54             }];
55             }
56              
57             sub get_parameter_schema {
58             return {
59 1     1 0 6635 %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema },
  1         7  
60             remote_url => { type => 'string' },
61             index_name => { type => 'string' },
62             count => { type => 'integer', default => 3 },
63             description => { type => 'string' },
64             hints => { type => 'array' },
65             };
66             }
67              
68             1;