Module: OllamaChat::WebSearching
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/web_searching.rb
Instance Method Summary collapse
-
#search_web(query, n = nil) ⇒ Array<String>?
The search_web method performs a web search using the configured search engine.
Instance Method Details
#search_web(query, n = nil) ⇒ Array<String>?
The search_web method performs a web search using the configured search engine. It appends location information to the query if available and limits the number of results. The method delegates to engine-specific search methods based on the configured search engine.
nil if the search engine is not implemented
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ollama_chat/web_searching.rb', line 14 def search_web(query, n = nil) l = .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 |