Class: Kward::Tools::WebSearch

Inherits:
Base
  • Object
show all
Defined in:
lib/kward/tools/web_search.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#schema

Constructor Details

#initialize(web_search:) ⇒ WebSearch

Returns a new instance of WebSearch.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kward/tools/web_search.rb', line 6

def initialize(web_search:)
  @web_search = web_search
  super(
    "web_search",
    "Search the live web with bounded results.",
    properties: {
      queries: {
        type: "array",
        description: "1-4 distinct queries; avoid near-duplicates.",
        items: { type: "string" },
        minItems: 1,
        maxItems: 4
      },
      max_results: {
        type: "integer",
        description: "Results per query; default 5, max 20."
      },
      provider: {
        type: "string",
        enum: %w[auto exa perplexity gemini legacy duckduckgo],
        description: "Provider override; default auto."
      },
      recency_filter: {
        type: "string",
        enum: %w[day week month year],
        description: "Recency filter."
      },
      domain_filter: {
        type: "array",
        description: "Domains to include; prefix '-' to exclude.",
        items: { type: "string" }
      }
    },
    required: ["queries"]
  )
end

Instance Method Details

#call(args, _conversation, cancellation: nil) ⇒ Object



43
44
45
# File 'lib/kward/tools/web_search.rb', line 43

def call(args, _conversation, cancellation: nil)
  @web_search.search(args)
end