File Coverage

blib/lib/SignalWire/Agents/Skills/Builtin/Datasphere.pm
Criterion Covered Total %
statement 24 28 85.7
branch n/a
condition 3 4 75.0
subroutine 10 12 83.3
pod 0 5 0.0
total 37 49 75.5


line stmt bran cond sub pod time code
1             package SignalWire::Agents::Skills::Builtin::Datasphere;
2 3     3   33 use strict;
  3         4  
  3         106  
3 3     3   13 use warnings;
  3         5  
  3         129  
4 3     3   13 use Moo;
  3         4  
  3         17  
5 3     3   961 use JSON ();
  3         6  
  3         148  
6             extends 'SignalWire::Agents::Skills::SkillBase';
7              
8 3     3   23 use SignalWire::Agents::Skills::SkillRegistry;
  3         6  
  3         1401  
9             SignalWire::Agents::Skills::SkillRegistry->register_skill('datasphere', __PACKAGE__);
10              
11             has '+skill_name' => (default => sub { 'datasphere' });
12             has '+skill_description' => (default => sub { 'Search knowledge using SignalWire DataSphere RAG stack' });
13             has '+supports_multiple_instances' => (default => sub { 1 });
14              
15 4     4 0 2290 sub setup { 1 }
16              
17             sub register_tools {
18 3     3 0 597 my ($self) = @_;
19 3   100     23 my $tool_name = $self->params->{tool_name} // 'search_knowledge';
20              
21             $self->define_tool(
22             name => $tool_name,
23             description => 'Search the knowledge base for information on any topic and return relevant results',
24             parameters => {
25             type => 'object',
26             properties => {
27             query => { type => 'string', description => 'The search query' },
28             },
29             required => ['query'],
30             },
31             handler => sub {
32 0     0   0 my ($args, $raw) = @_;
33 0         0 require SignalWire::Agents::SWAIG::FunctionResult;
34 0         0 return SignalWire::Agents::SWAIG::FunctionResult->new(
35             response => "DataSphere search for: $args->{query}"
36             );
37             },
38 3         61 );
39             }
40              
41 0     0 0 0 sub get_hints { return [] }
42              
43             sub get_global_data {
44 2     2 0 16 my ($self) = @_;
45             return {
46             datasphere_enabled => JSON::true,
47 2   50     14 document_id => $self->params->{document_id} // '',
48             knowledge_provider => 'SignalWire DataSphere',
49             };
50             }
51              
52             sub _get_prompt_sections {
53             return [{
54 1     1   7 title => 'Knowledge Search Capability',
55             body => 'You have access to a knowledge base that you can search for information.',
56             bullets => [
57             'Use the search tool to find relevant information',
58             'Provide accurate answers based on search results',
59             ],
60             }];
61             }
62              
63             sub get_parameter_schema {
64             return {
65 1     1 0 2593 %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema },
  1         5  
66             space_name => { type => 'string', required => 1 },
67             project_id => { type => 'string', required => 1 },
68             token => { type => 'string', required => 1 },
69             document_id => { type => 'string', required => 1 },
70             count => { type => 'integer', default => 1, min => 1, max => 10 },
71             distance => { type => 'number', default => 3.0 },
72             };
73             }
74              
75             1;