Class: SignalWire::Skills::Builtin::WebSearchSkill
- Inherits:
-
SkillBase
- Object
- SkillBase
- SignalWire::Skills::Builtin::WebSearchSkill
show all
- Defined in:
- lib/signalwire/skills/builtin/web_search.rb
Instance Attribute Summary
Attributes inherited from SkillBase
#agent, #logger, #params, #swaig_fields
Instance Method Summary
collapse
Methods inherited from SkillBase
#cleanup, #get_hints, #get_param, #initialize, #required_env_vars
Instance Method Details
#description ⇒ Object
15
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 15
def description; 'Search the web for information using Google Custom Search API'; end
|
#get_global_data ⇒ Object
54
55
56
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 54
def get_global_data
{ 'web_search_enabled' => true, 'search_provider' => 'Google Custom Search', 'quality_filtering' => true }
end
|
#get_parameter_schema ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 73
def get_parameter_schema
{
'api_key' => { 'type' => 'string', 'required' => true, 'hidden' => true, 'env_var' => 'GOOGLE_SEARCH_API_KEY' },
'search_engine_id' => { 'type' => 'string', 'required' => true, 'hidden' => true, 'env_var' => 'GOOGLE_SEARCH_ENGINE_ID' },
'num_results' => { 'type' => 'integer', 'default' => 3, 'min' => 1, 'max' => 10 },
'no_results_message' => { 'type' => 'string' },
'response_prefix' => { 'type' => 'string', 'default' => '' },
'response_postfix' => { 'type' => 'string', 'default' => '' }
}
end
|
#get_prompt_sections ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 58
def get_prompt_sections
[
{
'title' => 'Web Search Capability (Quality Enhanced)',
'body' => "You can search the internet for high-quality information using the #{@tool_name} tool.",
'bullets' => [
"Use the #{@tool_name} tool when users ask for information you need to look up",
'The search automatically filters out low-quality results like empty pages',
'Results are ranked by content quality, relevance, and domain reputation',
'Summarize the high-quality results in a clear, helpful way'
]
}
]
end
|
#instance_key ⇒ Object
39
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 39
def instance_key; "web_search_#{@tool_name}"; end
|
#name ⇒ Object
14
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 14
def name; 'web_search'; end
|
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 41
def register_tools
[
{
name: @tool_name,
description: 'Search the web for high-quality information, automatically filtering low-quality results',
parameters: {
'query' => { 'type' => 'string', 'description' => 'The search query - what you want to find information about' }
},
handler: method(:handle_search)
}
]
end
|
#setup ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 19
def setup
@api_key = get_param('api_key', env_var: 'GOOGLE_SEARCH_API_KEY')
@search_engine_id = get_param('search_engine_id', env_var: 'GOOGLE_SEARCH_ENGINE_ID')
@num_results = (get_param('num_results', default: 3)).to_i
@tool_name = get_param('tool_name', default: 'web_search')
@no_results_msg = get_param('no_results_message',
default: "I couldn't find quality results for that query. Try rephrasing your search.")
@response_prefix = get_param('response_prefix', default: '')
@response_postfix = get_param('response_postfix', default: '')
return false unless @api_key && !@api_key.empty?
return false unless @search_engine_id && !@search_engine_id.empty?
true
end
|
#supports_multiple_instances? ⇒ Boolean
17
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 17
def supports_multiple_instances?; true; end
|
#version ⇒ Object
16
|
# File 'lib/signalwire/skills/builtin/web_search.rb', line 16
def version; '2.0.0'; end
|