Module: Ollama::Client::WebSearch
- Defined in:
- lib/ollama/client/web_search.rb
Overview
Ollama Cloud web search & fetch endpoints.
Both require an Ollama Cloud API key (config.api_key / OLLAMA_API_KEY) and a client configured against the cloud host, e.g.:
config.base_url = "https://ollama.com"
Instance Method Summary collapse
-
#web_fetch(url:) ⇒ Hash
Fetch and extract content from a URL via Ollama Cloud.
-
#web_search(query:, max_results: nil) ⇒ Array<Hash>
Search the web via Ollama Cloud.
Instance Method Details
#web_fetch(url:) ⇒ Hash
Fetch and extract content from a URL via Ollama Cloud.
31 32 33 34 35 36 |
# File 'lib/ollama/client/web_search.rb', line 31 def web_fetch(url:) res = execute_management_request("/api/web_fetch", body: { url: url }) JSON.parse(res.body) rescue JSON::ParserError => e raise InvalidJSONError, "Failed to parse web_fetch response: #{e.}" end |
#web_search(query:, max_results: nil) ⇒ Array<Hash>
Search the web via Ollama Cloud.
18 19 20 21 22 23 24 25 |
# File 'lib/ollama/client/web_search.rb', line 18 def web_search(query:, max_results: nil) body = { query: query } body[:max_results] = max_results if max_results res = execute_management_request("/api/web_search", body: body) JSON.parse(res.body)["results"] || [] rescue JSON::ParserError => e raise InvalidJSONError, "Failed to parse web_search response: #{e.}" end |