Module: OllamaChat::WebSearching

Included in:
Chat
Defined in:
lib/ollama_chat/web_searching.rb

Instance Method Summary collapse

Instance Method Details

#search_web(query, n = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/ollama_chat/web_searching.rb', line 2

def search_web(query, n = nil)
  l     = @messages.at_location.full? and query += " #{l}"
  n     = n.to_i.clamp(1..)
  query = URI.encode_uri_component(query)
  search_command = :"search_web_with_#{search_engine}"
  if respond_to?(search_command, true)
    send(search_command, query, n)
  else
    STDOUT.puts "Search engine #{bold{search_engine}} not implemented!"
    nil
  end
end