Class: Leash::Integration::BraveSearchClient

Inherits:
Object
  • Object
show all
Defined in:
lib/leash/integration/brave-search.rb

Instance Method Summary collapse

Constructor Details

#initialize(leash) ⇒ BraveSearchClient

Create a new Brave Search integration client.

Parameters:

  • leash (Leash::Client)

    the Leash SDK client



11
12
13
# File 'lib/leash/integration/brave-search.rb', line 11

def initialize(leash)
  @leash = leash
end

Instance Method Details

#brave_local_search(query, count: nil) ⇒ Object

Searches for local businesses and places using Brave’s Local Search API. Best for queries related to physical locations, businesses, restaurants, services, etc. Returns detailed information includi…

Parameters:

  • query (String)

    Local search query (e.g. ‘pizza near Central Park’)

  • count (Float, nil) (defaults to: nil)

    Number of results (1-20, default 5)

Returns:

  • (Object)


35
36
37
38
39
40
41
# File 'lib/leash/integration/brave-search.rb', line 35

def brave_local_search(query, count: nil)
  params = {
    'query' => query,
    'count' => count
  }.compact
  @leash.call('brave-search', 'brave_local_search', params)
end

#brave_web_search(query, count: nil, offset: nil) ⇒ Object

Performs a web search using the Brave Search API, ideal for general queries, news, articles, and online content. Use this for broad information gathering, recent events, or when you need diverse we…

Parameters:

  • query (String)

    Search query (max 400 chars, 50 words)

  • count (Float, nil) (defaults to: nil)

    Number of results (1-20, default 10)

  • offset (Float, nil) (defaults to: nil)

    Pagination offset (max 9, default 0)

Returns:

  • (Object)


21
22
23
24
25
26
27
28
# File 'lib/leash/integration/brave-search.rb', line 21

def brave_web_search(query, count: nil, offset: nil)
  params = {
    'query' => query,
    'count' => count,
    'offset' => offset
  }.compact
  @leash.call('brave-search', 'brave_web_search', params)
end