blib/lib/SignalWire/Skills/Builtin/DatasphereServerless.pm

filter: Statementstmt 82.3% 28 / 34 Branchbran n/a Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 10 / 14 Podpod 0.0% 0 / 5 totaltotal 64.5% 40 / 62 CC 4 SCAR 7.7
CC
4
Cov
75%
get_global_data
6.0
register_tools
3.2
get_hints
2.0
CRAP 2.2
« blib/lib/SignalWire/REST/Namespaces/Datasphere.pm ↑ Summary blib/lib/SignalWire/REST/Namespaces/Calling.pm »
1 package SignalWire::Skills::Builtin::DatasphereServerless;
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::Skills::SkillBase';
7  
8 3 ▶use SignalWire::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 SignalWire::Skills::SkillRegistry->register_skill('datasphere_serverless', __PACKAGE__);
10  
11 2 ▶has '+skill_name' => (default => sub { 'datasphere_serverless' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 2 ▶has '+skill_description' => (default => sub { 'Search knowledge using SignalWire DataSphere with serverless DataMap execution' });
Subroutine __ANON__: called CC=1 SCAR=0.0
13 2 ▶has '+supports_multiple_instances' => (default => sub { 1 });
Subroutine __ANON__: called CC=1 SCAR=0.0
14  
15 2 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
16  
17 1 ▶sub register_tools {
Subroutine register_tools: called CC=3 SCAR=11.7
Pod undocumented
18 1 my ($self) = @_;
19 1 ▶ my $tool_name = $self->params->{tool_name} // 'search_knowledge';
Condition50%1/2
$self->params->{"tool_name"} // "search_knowledge"
l!l
01
MC/DC0%0/1
$self->params->{"tool_name"} // "search_knowledge"
$self->params->{"tool_name"}
Truth table50%1/2
A
A= $self->params->{"tool_name"}
Aresult
11
00
20  
21 # DataMap-based tool: register as a SWAIG function definition
22 $self->agent->register_swaig_function({
23 function => $tool_name,
24 description => 'Search the knowledge base for information on any topic and return relevant results',
25 parameters => {
26 type => 'object',
27 properties => {
28 query => { type => 'string', description => 'The search query' },
29 },
30 required => ['query'],
31 },
32 data_map => {
33 webhooks => [{
34 method => 'POST',
35 1 ▶ url => 'https://' . ($self->params->{space_name} // '') . '/api/datasphere/documents/search',
Condition50%1/2
$self->params->{"space_name"} // ""
l!l
01
MC/DC0%0/1
$self->params->{"space_name"} // ""
$self->params->{"space_name"}
Truth table50%1/2
A
A= $self->params->{"space_name"}
Aresult
11
00
36 output => {
37 response => 'I found results for "${args.query}":\n\n${formatted_results}',
38 action => [{ say => 'Here are the search results.' }],
39 },
40 }],
41 },
42 });
43 }
44  
45 0 ▶sub get_hints { return [] }
Subroutine get_hints: not called CC=1 SCAR=6.9
Pod undocumented
46  
47 0 ▶sub get_global_data {
Subroutine get_global_data: not called CC=2 SCAR=17.9
Pod undocumented
48 0 my ($self) = @_;
49 return {
50 datasphere_serverless_enabled => JSON::true,
51 0 ▶ document_id => $self->params->{document_id} // '',
Condition0%0/2
$self->params->{"document_id"} // ""
l!l
00
MC/DC0%0/1
$self->params->{"document_id"} // ""
$self->params->{"document_id"}
Truth table0%0/2
A
A= $self->params->{"document_id"}
Aresult
11
00
52 knowledge_provider => 'SignalWire DataSphere (Serverless)',
53 };
54 }
55  
56 0 ▶sub _get_prompt_sections {
Subroutine _get_prompt_sections: not called CC=1 SCAR=6.9
57 return [{
58 0 title => 'Knowledge Search Capability (Serverless)',
59 body => 'You have access to a serverless knowledge base search.',
60 bullets => [
61 'Use the search tool to find relevant information',
62 'Results are processed server-side for efficiency',
63 ],
64 }];
65 }
66  
67 0 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: not called CC=1 SCAR=6.9
Pod undocumented
68 return {
69 0 %{ SignalWire::Skills::SkillBase->get_parameter_schema },
70 space_name => { type => 'string', required => 1 },
71 project_id => { type => 'string', required => 1 },
72 token => { type => 'string', required => 1 },
73 document_id => { type => 'string', required => 1 },
74 count => { type => 'integer', default => 1, min => 1, max => 10 },
75 distance => { type => 'number', default => 3.0 },
76 };
77 }
78  
79 3 1;
« blib/lib/SignalWire/REST/Namespaces/Datasphere.pm ↑ Summary blib/lib/SignalWire/REST/Namespaces/Calling.pm »