« blib/lib/SignalWire/Agents/Skills/SkillBase.pm
↑ Summary
blib/lib/SignalWire/Agents/Skills/Builtin/Joke.pm »
| 1 | package SignalWire::Agents::Skills::Builtin::NativeVectorSearch; | ||||||||||||
| 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('native_vector_search', __PACKAGE__); | |||||||||||
| 9 | |||||||||||||
| 10 | 7 | ▶ | has '+skill_name' => (default => sub { 'native_vector_search' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 7 | ▶ | has '+skill_description' => (default => sub { 'Search document indexes using vector similarity and keyword search (local or remote)' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 7 | ▶ | has '+supports_multiple_instances' => (default => sub { 1 }); | ||||||||||
|
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=3 SCAR=11.6
Pod
undocumented
| |||||||||||||
| 17 | 3 | my ($self) = @_; | |||||||||||
| 18 | 3 | ▶ | my $tool_name = $self->params->{tool_name} // 'search_knowledge'; | ||||||||||
|
Condition100%2/2
$self->params->{"tool_name"} // "search_knowledge"
MC/DC100%1/1
$self->params->{"tool_name"} // "search_knowledge"
$self->params->{"tool_name"}
Truth table100%2/2
A
A= $self->params->{"tool_name"}
| |||||||||||||
| 19 | 3 | ▶ | my $description = $self->params->{description} // 'Search the local knowledge base for information'; | ||||||||||
|
Condition100%2/2
$self->params->{"description"} // "Search the local knowledge base for information"
MC/DC100%1/1
$self->params->{"description"} // "Search the local knowledge base for information"
$self->params->{"description"}
Truth table100%2/2
A
A= $self->params->{"description"}
| |||||||||||||
| 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 | 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 => "Vector search for: $args->{query}" | ||||||||||||
| 37 | ); | ||||||||||||
| 38 | }, | ||||||||||||
| 39 | 3 | ); | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 1 | ▶ | sub get_hints { | ||||||||||
|
Subroutine
get_hints: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 43 | 1 | my ($self) = @_; | |||||||||||
| 44 | 1 | my @base = ('search', 'find', 'look up', 'documentation', 'knowledge base'); | |||||||||||
| 45 | 1 | ▶ | push @base, @{ $self->params->{hints} // [] }; | ||||||||||
|
Condition50%1/2
$self->params->{"hints"} // []
MC/DC0%0/1
$self->params->{"hints"} // []
$self->params->{"hints"}
Truth table50%1/2
A
A= $self->params->{"hints"}
| |||||||||||||
| 46 | 1 | return \@base; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 1 | ▶ | sub _get_prompt_sections { | ||||||||||
|
Subroutine
_get_prompt_sections: called CC=1 SCAR=0.0
| |||||||||||||
| 50 | return [{ | ||||||||||||
| 51 | 1 | 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 | 1 | ▶ | sub get_parameter_schema { | ||||||||||
|
Subroutine
get_parameter_schema: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 58 | return { | ||||||||||||
| 59 | 1 | %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, | |||||||||||
| 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 | 3 | 1; | |||||||||||