Class: SignalWire::Skills::Builtin::CustomSkillsSkill
- Inherits:
-
SkillBase
- Object
- SkillBase
- SignalWire::Skills::Builtin::CustomSkillsSkill
show all
- Defined in:
- lib/signalwire/skills/builtin/custom_skills.rb
Overview
User-defined custom tools.
Instance Attribute Summary
Attributes inherited from SkillBase
#agent, #logger, #params, #swaig_fields
Instance Method Summary
collapse
Methods inherited from SkillBase
#cleanup, #get_global_data, #get_hints, #get_param, #get_prompt_sections, #initialize, #required_env_vars, #version
Instance Method Details
#description ⇒ Object
12
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 12
def description; 'Register user-defined custom tools'; end
|
#get_parameter_schema ⇒ Object
42
43
44
45
46
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 42
def get_parameter_schema
{
'tools' => { 'type' => 'array', 'required' => true }
}
end
|
#instance_key ⇒ Object
21
22
23
24
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 21
def instance_key
tool_name = get_param('tool_name', default: 'custom')
"custom_skills_#{tool_name}"
end
|
#name ⇒ Object
11
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 11
def name; 'custom_skills'; end
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 26
def register_tools
(@tools_config || []).filter_map do |tool_def|
next unless tool_def.is_a?(Hash) && tool_def['name']
{
name: tool_def['name'],
description: tool_def['description'] || "Custom tool: #{tool_def['name']}",
parameters: tool_def['parameters'] || {},
handler: lambda { |args, _raw_data|
response = tool_def['response'] || "Custom tool #{tool_def['name']} executed."
Swaig::FunctionResult.new(response)
}
}
end
end
|
#setup ⇒ Object
15
16
17
18
19
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 15
def setup
@tools_config = get_param('tools')
return false unless @tools_config.is_a?(Array)
true
end
|
#supports_multiple_instances? ⇒ Boolean
13
|
# File 'lib/signalwire/skills/builtin/custom_skills.rb', line 13
def supports_multiple_instances?; true; end
|