| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::InfoGatherer; |
|
2
|
3
|
|
|
3
|
|
19
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
107
|
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
151
|
|
|
4
|
3
|
|
|
3
|
|
13
|
use Moo; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
20
|
|
|
5
|
3
|
|
|
3
|
|
1127
|
use JSON qw(encode_json); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
487
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1830
|
|
|
9
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('info_gatherer', __PACKAGE__); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'info_gatherer' }); |
|
12
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Gather answers to a configurable list of questions' }); |
|
13
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 1 }); |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
0
|
2342
|
sub setup { 1 } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub register_tools { |
|
18
|
3
|
|
|
3
|
0
|
618
|
my ($self) = @_; |
|
19
|
3
|
|
100
|
|
|
26
|
my $prefix = $self->params->{prefix} // ''; |
|
20
|
3
|
|
100
|
|
|
16
|
my $questions = $self->params->{questions} // []; |
|
21
|
|
|
|
|
|
|
|
|
22
|
3
|
100
|
|
|
|
9
|
my $start_name = $prefix ? "${prefix}_start_questions" : 'start_questions'; |
|
23
|
3
|
100
|
|
|
|
10
|
my $submit_name = $prefix ? "${prefix}_submit_answer" : 'submit_answer'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->define_tool( |
|
26
|
|
|
|
|
|
|
name => $start_name, |
|
27
|
|
|
|
|
|
|
description => 'Start the question-gathering process and return the first question', |
|
28
|
|
|
|
|
|
|
parameters => { type => 'object', properties => {} }, |
|
29
|
|
|
|
|
|
|
handler => sub { |
|
30
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
31
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
32
|
0
|
|
0
|
|
|
0
|
my $first = $questions->[0]{question_text} // 'No questions configured'; |
|
33
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
34
|
|
|
|
|
|
|
response => $first, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
3
|
|
|
|
|
37
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->define_tool( |
|
40
|
|
|
|
|
|
|
name => $submit_name, |
|
41
|
|
|
|
|
|
|
description => 'Submit an answer to the current question', |
|
42
|
|
|
|
|
|
|
parameters => { |
|
43
|
|
|
|
|
|
|
type => 'object', |
|
44
|
|
|
|
|
|
|
properties => { |
|
45
|
|
|
|
|
|
|
answer => { type => 'string', description => 'The answer' }, |
|
46
|
|
|
|
|
|
|
confirmed_by_user => { type => 'boolean', description => 'Whether user confirmed' }, |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
required => ['answer'], |
|
49
|
|
|
|
|
|
|
}, |
|
50
|
|
|
|
|
|
|
handler => sub { |
|
51
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
52
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
53
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
54
|
|
|
|
|
|
|
response => "Answer recorded: $args->{answer}", |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
}, |
|
57
|
3
|
|
|
|
|
64
|
); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_global_data { |
|
61
|
1
|
|
|
1
|
0
|
5
|
my ($self) = @_; |
|
62
|
1
|
|
50
|
|
|
7
|
my $ns = $self->params->{prefix} // 'info_gatherer'; |
|
63
|
|
|
|
|
|
|
return { |
|
64
|
|
|
|
|
|
|
$ns => { |
|
65
|
1
|
|
50
|
|
|
7
|
questions => $self->params->{questions} // [], |
|
66
|
|
|
|
|
|
|
question_index => 0, |
|
67
|
|
|
|
|
|
|
answers => [], |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
73
|
1
|
|
|
1
|
|
4
|
my ($self) = @_; |
|
74
|
1
|
|
50
|
|
|
7
|
my $key = $self->params->{prefix} // 'info_gatherer'; |
|
75
|
|
|
|
|
|
|
return [{ |
|
76
|
1
|
|
|
|
|
8
|
title => "Info Gatherer ($key)", |
|
77
|
|
|
|
|
|
|
body => 'Ask the user a series of questions and collect their answers.', |
|
78
|
|
|
|
|
|
|
bullets => [ |
|
79
|
|
|
|
|
|
|
'Ask questions one at a time', |
|
80
|
|
|
|
|
|
|
'Wait for the user to answer before proceeding', |
|
81
|
|
|
|
|
|
|
'Confirm answers when required', |
|
82
|
|
|
|
|
|
|
], |
|
83
|
|
|
|
|
|
|
}]; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
87
|
|
|
|
|
|
|
return { |
|
88
|
1
|
|
|
1
|
0
|
3084
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
1
|
|
|
|
|
5
|
|
|
89
|
|
|
|
|
|
|
questions => { type => 'array', required => 1, description => 'List of question objects' }, |
|
90
|
|
|
|
|
|
|
prefix => { type => 'string', description => 'Prefix for tool names' }, |
|
91
|
|
|
|
|
|
|
completion_message => { type => 'string', description => 'Message after all questions answered' }, |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |