« blib/lib/SignalWire/Agents/SWML/Document.pm
↑ Summary
blib/lib/SignalWire/Agents/REST/Namespaces/Project.pm »
| 1 | package SignalWire::Agents::Skills::Builtin::Datasphere; | ||||||||||||
| 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::Agents::Skills::SkillBase'; | |||||||||||
| 7 | |||||||||||||
| 8 | 3 | ▶ | use SignalWire::Agents::Skills::SkillRegistry; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | SignalWire::Agents::Skills::SkillRegistry->register_skill('datasphere', __PACKAGE__); | |||||||||||
| 10 | |||||||||||||
| 11 | 8 | ▶ | has '+skill_name' => (default => sub { 'datasphere' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 8 | ▶ | has '+skill_description' => (default => sub { 'Search knowledge using SignalWire DataSphere RAG stack' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 8 | ▶ | has '+supports_multiple_instances' => (default => sub { 1 }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 4 | ▶ | sub setup { 1 } | ||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 16 | |||||||||||||
| 17 | 3 | ▶ | sub register_tools { | ||||||||||
|
Subroutine
register_tools: called CC=2 SCAR=7.9
Pod
undocumented
| |||||||||||||
| 18 | 3 | my ($self) = @_; | |||||||||||
| 19 | 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"}
| |||||||||||||
| 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 | 0 | ▶ | handler => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 32 | 0 | my ($args, $raw) = @_; | |||||||||||
| 33 | 0 | require SignalWire::Agents::SWAIG::FunctionResult; | |||||||||||
| 34 | 0 | return SignalWire::Agents::SWAIG::FunctionResult->new( | |||||||||||
| 35 | response => "DataSphere search for: $args->{query}" | ||||||||||||
| 36 | ); | ||||||||||||
| 37 | }, | ||||||||||||
| 38 | 3 | ); | |||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | 0 | ▶ | sub get_hints { return [] } | ||||||||||
|
Subroutine
get_hints: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 42 | |||||||||||||
| 43 | 2 | ▶ | sub get_global_data { | ||||||||||
|
Subroutine
get_global_data: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||
| 44 | 2 | my ($self) = @_; | |||||||||||
| 45 | return { | ||||||||||||
| 46 | datasphere_enabled => JSON::true, | ||||||||||||
| 47 | 2 | ▶ | document_id => $self->params->{document_id} // '', | ||||||||||
|
Condition50%1/2
$self->params->{"document_id"} // ""
MC/DC0%0/1
$self->params->{"document_id"} // ""
$self->params->{"document_id"}
Truth table50%1/2
A
A= $self->params->{"document_id"}
| |||||||||||||
| 48 | knowledge_provider => 'SignalWire DataSphere', | ||||||||||||
| 49 | }; | ||||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | 1 | ▶ | sub _get_prompt_sections { | ||||||||||
|
Subroutine
_get_prompt_sections: called CC=1 SCAR=0.0
| |||||||||||||
| 53 | return [{ | ||||||||||||
| 54 | 1 | 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 | 1 | ▶ | sub get_parameter_schema { | ||||||||||
|
Subroutine
get_parameter_schema: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 64 | return { | ||||||||||||
| 65 | 1 | %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, | |||||||||||
| 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 | 3 | 1; | |||||||||||