| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::DatasphereServerless; |
|
2
|
2
|
|
|
2
|
|
14
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
116
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
89
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use Moo; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
11
|
|
|
5
|
2
|
|
|
2
|
|
747
|
use JSON (); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
98
|
|
|
6
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
902
|
|
|
9
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('datasphere_serverless', __PACKAGE__); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'datasphere_serverless' }); |
|
12
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Search knowledge using SignalWire DataSphere with serverless DataMap execution' }); |
|
13
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 1 }); |
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
0
|
2382
|
sub setup { 1 } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub register_tools { |
|
18
|
1
|
|
|
1
|
0
|
545
|
my ($self) = @_; |
|
19
|
1
|
|
50
|
|
|
11
|
my $tool_name = $self->params->{tool_name} // 'search_knowledge'; |
|
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
|
|
50
|
|
|
37
|
url => 'https://' . ($self->params->{space_name} // '') . '/api/datasphere/documents/search', |
|
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
|
|
|
0
|
0
|
|
sub get_hints { return [] } |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_global_data { |
|
48
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
49
|
|
|
|
|
|
|
return { |
|
50
|
|
|
|
|
|
|
datasphere_serverless_enabled => JSON::true, |
|
51
|
0
|
|
0
|
|
|
|
document_id => $self->params->{document_id} // '', |
|
52
|
|
|
|
|
|
|
knowledge_provider => 'SignalWire DataSphere (Serverless)', |
|
53
|
|
|
|
|
|
|
}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
57
|
|
|
|
|
|
|
return [{ |
|
58
|
0
|
|
|
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
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
68
|
|
|
|
|
|
|
return { |
|
69
|
0
|
|
|
0
|
0
|
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
0
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
1; |