Class: SignalWire::Skills::Builtin::NativeVectorSearchSkill

Inherits:
SkillBase
  • Object
show all
Defined in:
lib/signalwire/skills/builtin/native_vector_search.rb

Overview

Network/remote mode only (as per porting manifest).

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_param, #get_prompt_sections, #initialize, #required_env_vars, #version

Constructor Details

This class inherits a constructor from SignalWire::Skills::SkillBase

Instance Method Details

#descriptionObject



16
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 16

def description; 'Search document indexes using vector similarity and keyword search (local or remote)'; end

#get_hintsObject



49
50
51
52
53
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 49

def get_hints
  base = %w[search find look\ up documentation knowledge\ base]
  base.concat(@custom_hints) if @custom_hints.is_a?(Array)
  base
end

#get_parameter_schemaObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 55

def get_parameter_schema
  {
    'remote_url'           => { 'type' => 'string', 'required' => true },
    'index_name'           => { 'type' => 'string' },
    'count'                => { 'type' => 'integer', 'default' => 3 },
    'similarity_threshold' => { 'type' => 'number', 'default' => 0.5 },
    'description'          => { 'type' => 'string' },
    'hints'                => { 'type' => 'array' }
  }
end

#instance_keyObject



33
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 33

def instance_key; "native_vector_search_#{@tool_name}"; end

#nameObject



15
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 15

def name;        'native_vector_search'; end

#register_toolsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 35

def register_tools
  [
    {
      name: @tool_name,
      description: @tool_desc,
      parameters: {
        'query' => { 'type' => 'string', 'description' => 'Search query' },
        'count' => { 'type' => 'integer', 'description' => 'Number of results to return' }
      },
      handler: method(:handle_search)
    }
  ]
end

#setupObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 19

def setup
  @remote_url  = get_param('remote_url')
  @index_name  = get_param('index_name')
  @tool_name   = get_param('tool_name', default: 'search_knowledge')
  @tool_desc   = get_param('description', default: 'Search the local knowledge base for information')
  @count       = (get_param('count', default: 3)).to_i
  @threshold   = (get_param('similarity_threshold', default: 0.5)).to_f
  @custom_hints = get_param('hints') || []

  # Network mode requires remote_url
  return false unless @remote_url && !@remote_url.empty?
  true
end

#supports_multiple_instances?Boolean

Returns:

  • (Boolean)


17
# File 'lib/signalwire/skills/builtin/native_vector_search.rb', line 17

def supports_multiple_instances?; true; end