Class: Exa::Client
- Inherits:
-
Object
- Object
- Exa::Client
- Defined in:
- lib/exa/client.rb
Overview
Main client for interacting with the Exa.ai API
Provides methods for all supported Exa.ai operations including search, content retrieval, answer generation, and async research tasks.
Instance Method Summary collapse
-
#agent_run_cancel(run_id) ⇒ Resources::AgentRun
Cancel an in-progress agent run.
-
#agent_run_create(query:, **params) ⇒ Resources::AgentRun
Create a new agent run.
-
#agent_run_delete(run_id) ⇒ Resources::AgentRun
Delete an agent run.
-
#agent_run_events(run_id, **params) ⇒ Array<Hash>
List events for an agent run.
-
#agent_run_get(run_id) ⇒ Resources::AgentRun
Get the status and results of an agent run.
-
#agent_run_list(**params) ⇒ Resources::AgentRunList
List all agent runs.
-
#agent_run_stream(query:, **params) {|chunk| ... } ⇒ void
Stream an agent run, yielding chunks as they arrive.
-
#answer(query, **options) ⇒ Resources::Answer
Get AI-generated answers to a query.
-
#answer_stream(query, **options) {|chunk| ... } ⇒ void
Stream AI-generated answers to a query.
-
#cancel_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Cancel a running enrichment.
-
#cancel_webset(id) ⇒ Resources::Webset
Cancel in-progress operations on a webset.
-
#cancel_webset_search(webset_id:, id:) ⇒ Resources::WebsetSearch
Cancel a webset search.
-
#context(query, **params) ⇒ Resources::SearchResult
Search code repositories.
-
#create_enrichment(webset_id:, **params) ⇒ Resources::WebsetEnrichment
Create a new enrichment for a webset.
-
#create_import(**params) ⇒ Resources::Import
Create a new import.
-
#create_monitor(webset_id:, cadence:, behavior:, **params) ⇒ Resources::Monitor
Create a new monitor for a webset.
-
#create_webset(**params) ⇒ Resources::Webset
Create a new webset.
-
#create_webset_search(webset_id:, **params) ⇒ Resources::WebsetSearch
Create a new search within a webset.
-
#delete_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Delete an enrichment.
-
#delete_import(id) ⇒ Resources::Import
Delete an import.
-
#delete_item(webset_id:, id:) ⇒ Boolean
Delete a webset item by ID.
-
#delete_monitor(id:) ⇒ Resources::Monitor
Delete a monitor.
-
#delete_webset(id) ⇒ Resources::Webset
Delete a webset.
-
#find_similar(url, **options) ⇒ Resources::SearchResult
Find similar content to a given URL.
-
#get_contents(urls, **options) ⇒ Resources::ContentCollection
Get full page contents for URLs.
-
#get_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Get a specific enrichment by ID.
-
#get_import(id) ⇒ Resources::Import
Get a specific import by ID.
-
#get_item(webset_id:, id:) ⇒ Hash
Get a webset item by ID.
-
#get_monitor(id:) ⇒ Resources::Monitor
Get a specific monitor by ID.
-
#get_monitor_run(monitor_id:, id:) ⇒ Resources::MonitorRun
Get a specific monitor run by ID.
-
#get_webset(id, **params) ⇒ Resources::Webset
Get a specific webset by ID.
-
#get_webset_search(webset_id:, id:) ⇒ Resources::WebsetSearch
Get a webset search by ID.
-
#initialize(api_key: nil, **options) ⇒ Client
constructor
Initialize a new Exa client.
-
#list_imports(**params) ⇒ Resources::ImportCollection
List all imports.
-
#list_items(webset_id:, **params) ⇒ Resources::WebsetItemCollection
List all items in a webset.
-
#list_monitor_runs(monitor_id:, **params) ⇒ Resources::MonitorRunCollection
List all runs for a specific monitor.
-
#list_monitors(**params) ⇒ Resources::MonitorCollection
List all monitors.
-
#list_websets(**params) ⇒ Resources::WebsetCollection
List all websets.
-
#research_get(research_id, **params) ⇒ Resources::Research
Get status and results of a research task.
-
#research_list(**params) ⇒ Resources::ResearchList
List all research tasks.
-
#research_start(**params) ⇒ Resources::Research
Start an asynchronous research task.
-
#search(query, **params) ⇒ Resources::SearchResult
Execute a search query.
-
#update_enrichment(webset_id:, id:, **params) ⇒ Resources::WebsetEnrichment
Update an enrichment.
-
#update_import(id, **params) ⇒ Resources::Import
Update an import.
-
#update_monitor(id:, **params) ⇒ Resources::Monitor
Update a monitor.
-
#update_webset(id, **params) ⇒ Resources::Webset
Update a webset's title and/or metadata.
-
#upload_import(file_path:, **params) ⇒ Resources::Import
Upload a file for import (creates import and uploads file).
Constructor Details
Instance Method Details
#agent_run_cancel(run_id) ⇒ Resources::AgentRun
Cancel an in-progress agent run
169 170 171 |
# File 'lib/exa/client.rb', line 169 def agent_run_cancel(run_id) Services::AgentRunCancel.new(connection, run_id: run_id).call end |
#agent_run_create(query:, **params) ⇒ Resources::AgentRun
Create a new agent run
126 127 128 |
# File 'lib/exa/client.rb', line 126 def agent_run_create(query:, **params) Services::AgentRunCreate.new(connection, query: query, **params).call end |
#agent_run_delete(run_id) ⇒ Resources::AgentRun
Delete an agent run
177 178 179 |
# File 'lib/exa/client.rb', line 177 def agent_run_delete(run_id) Services::AgentRunDelete.new(connection, run_id: run_id).call end |
#agent_run_events(run_id, **params) ⇒ Array<Hash>
List events for an agent run
188 189 190 |
# File 'lib/exa/client.rb', line 188 def agent_run_events(run_id, **params) Services::AgentRunEvents.new(connection, run_id: run_id, **params).call end |
#agent_run_get(run_id) ⇒ Resources::AgentRun
Get the status and results of an agent run
151 152 153 |
# File 'lib/exa/client.rb', line 151 def agent_run_get(run_id) Services::AgentRunGet.new(connection, run_id: run_id).call end |
#agent_run_list(**params) ⇒ Resources::AgentRunList
List all agent runs
161 162 163 |
# File 'lib/exa/client.rb', line 161 def agent_run_list(**params) Services::AgentRunList.new(connection, **params).call end |
#agent_run_stream(query:, **params) {|chunk| ... } ⇒ void
This method returns an undefined value.
Stream an agent run, yielding chunks as they arrive
143 144 145 |
# File 'lib/exa/client.rb', line 143 def agent_run_stream(query:, **params, &block) Services::AgentRunStream.new(connection, query: query, **params).call(&block) end |
#answer(query, **options) ⇒ Resources::Answer
Get AI-generated answers to a query
70 71 72 |
# File 'lib/exa/client.rb', line 70 def answer(query, **) Services::Answer.new(connection, query: query, **).call end |
#answer_stream(query, **options) {|chunk| ... } ⇒ void
This method returns an undefined value.
Stream AI-generated answers to a query
Returns partial answer chunks as they are generated by the API.
85 86 87 |
# File 'lib/exa/client.rb', line 85 def answer_stream(query, **, &block) Services::AnswerStream.new(connection, query: query, **).call(&block) end |
#cancel_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Cancel a running enrichment
308 309 310 |
# File 'lib/exa/client.rb', line 308 def cancel_enrichment(webset_id:, id:) Services::Websets::CancelEnrichment.new(connection, webset_id: webset_id, id: id).call end |
#cancel_webset(id) ⇒ Resources::Webset
Cancel in-progress operations on a webset
234 235 236 |
# File 'lib/exa/client.rb', line 234 def cancel_webset(id) Services::Websets::Cancel.new(connection, id: id).call end |
#cancel_webset_search(webset_id:, id:) ⇒ Resources::WebsetSearch
Cancel a webset search
344 345 346 |
# File 'lib/exa/client.rb', line 344 def cancel_webset_search(webset_id:, id:) Services::Websets::CancelSearch.new(connection, webset_id: webset_id, id: id).call end |
#context(query, **params) ⇒ Resources::SearchResult
Search code repositories
198 199 200 |
# File 'lib/exa/client.rb', line 198 def context(query, **params) Services::Context.new(connection, query: query, **params).call end |
#create_enrichment(webset_id:, **params) ⇒ Resources::WebsetEnrichment
Create a new enrichment for a webset
267 268 269 |
# File 'lib/exa/client.rb', line 267 def create_enrichment(webset_id:, **params) Services::Websets::CreateEnrichment.new(connection, webset_id: webset_id, **params).call end |
#create_import(**params) ⇒ Resources::Import
Create a new import
398 399 400 |
# File 'lib/exa/client.rb', line 398 def create_import(**params) Services::Websets::CreateImport.new(connection, **params).call end |
#create_monitor(webset_id:, cadence:, behavior:, **params) ⇒ Resources::Monitor
Create a new monitor for a webset
452 453 454 |
# File 'lib/exa/client.rb', line 452 def create_monitor(webset_id:, cadence:, behavior:, **params) Services::Websets::Monitors::Create.new(connection, webset_id: webset_id, cadence: cadence, behavior: behavior, **params).call end |
#create_webset(**params) ⇒ Resources::Webset
Create a new webset
254 255 256 |
# File 'lib/exa/client.rb', line 254 def create_webset(**params) Services::Websets::Create.new(connection, **params).call end |
#create_webset_search(webset_id:, **params) ⇒ Resources::WebsetSearch
Create a new search within a webset
326 327 328 |
# File 'lib/exa/client.rb', line 326 def create_webset_search(webset_id:, **params) Services::Websets::CreateSearch.new(connection, webset_id: webset_id, **params).call end |
#delete_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Delete an enrichment
299 300 301 |
# File 'lib/exa/client.rb', line 299 def delete_enrichment(webset_id:, id:) Services::Websets::DeleteEnrichment.new(connection, webset_id: webset_id, id: id).call end |
#delete_import(id) ⇒ Resources::Import
Delete an import
440 441 442 |
# File 'lib/exa/client.rb', line 440 def delete_import(id) Services::Websets::DeleteImport.new(connection, id: id).call end |
#delete_item(webset_id:, id:) ⇒ Boolean
Delete a webset item by ID
362 363 364 |
# File 'lib/exa/client.rb', line 362 def delete_item(webset_id:, id:) Services::Websets::DeleteItem.new(connection, webset_id: webset_id, id: id).call end |
#delete_monitor(id:) ⇒ Resources::Monitor
Delete a monitor
490 491 492 |
# File 'lib/exa/client.rb', line 490 def delete_monitor(id:) Services::Websets::Monitors::Delete.new(connection, id: id).call end |
#delete_webset(id) ⇒ Resources::Webset
Delete a webset
226 227 228 |
# File 'lib/exa/client.rb', line 226 def delete_webset(id) Services::Websets::Delete.new(connection, id: id).call end |
#find_similar(url, **options) ⇒ Resources::SearchResult
Find similar content to a given URL
51 52 53 |
# File 'lib/exa/client.rb', line 51 def find_similar(url, **) Services::FindSimilar.new(connection, url: url, **).call end |
#get_contents(urls, **options) ⇒ Resources::ContentCollection
Get full page contents for URLs
60 61 62 |
# File 'lib/exa/client.rb', line 60 def get_contents(urls, **) Services::GetContents.new(connection, urls: urls, **).call end |
#get_enrichment(webset_id:, id:) ⇒ Resources::WebsetEnrichment
Get a specific enrichment by ID
276 277 278 |
# File 'lib/exa/client.rb', line 276 def get_enrichment(webset_id:, id:) Services::Websets::RetrieveEnrichment.new(connection, webset_id: webset_id, id: id).call end |
#get_import(id) ⇒ Resources::Import
Get a specific import by ID
421 422 423 |
# File 'lib/exa/client.rb', line 421 def get_import(id) Services::Websets::GetImport.new(connection, id: id).call end |
#get_item(webset_id:, id:) ⇒ Hash
Get a webset item by ID
353 354 355 |
# File 'lib/exa/client.rb', line 353 def get_item(webset_id:, id:) Services::Websets::GetItem.new(connection, webset_id: webset_id, id: id).call end |
#get_monitor(id:) ⇒ Resources::Monitor
Get a specific monitor by ID
470 471 472 |
# File 'lib/exa/client.rb', line 470 def get_monitor(id:) Services::Websets::Monitors::Get.new(connection, id: id).call end |
#get_monitor_run(monitor_id:, id:) ⇒ Resources::MonitorRun
Get a specific monitor run by ID
510 511 512 |
# File 'lib/exa/client.rb', line 510 def get_monitor_run(monitor_id:, id:) Services::Websets::Monitors::Runs::Get.new(connection, monitor_id: monitor_id, id: id).call end |
#get_webset(id, **params) ⇒ Resources::Webset
Get a specific webset by ID
218 219 220 |
# File 'lib/exa/client.rb', line 218 def get_webset(id, **params) Services::Websets::Retrieve.new(connection, id: id, **params).call end |
#get_webset_search(webset_id:, id:) ⇒ Resources::WebsetSearch
Get a webset search by ID
335 336 337 |
# File 'lib/exa/client.rb', line 335 def get_webset_search(webset_id:, id:) Services::Websets::GetSearch.new(connection, webset_id: webset_id, id: id).call end |
#list_imports(**params) ⇒ Resources::ImportCollection
List all imports
383 384 385 |
# File 'lib/exa/client.rb', line 383 def list_imports(**params) Services::Websets::ListImports.new(connection, **params).call end |
#list_items(webset_id:, **params) ⇒ Resources::WebsetItemCollection
List all items in a webset
373 374 375 |
# File 'lib/exa/client.rb', line 373 def list_items(webset_id:, **params) Services::Websets::ListItems.new(connection, webset_id: webset_id, **params).call end |
#list_monitor_runs(monitor_id:, **params) ⇒ Resources::MonitorRunCollection
List all runs for a specific monitor
501 502 503 |
# File 'lib/exa/client.rb', line 501 def list_monitor_runs(monitor_id:, **params) Services::Websets::Monitors::Runs::List.new(connection, monitor_id: monitor_id, **params).call end |
#list_monitors(**params) ⇒ Resources::MonitorCollection
List all monitors
462 463 464 |
# File 'lib/exa/client.rb', line 462 def list_monitors(**params) Services::Websets::Monitors::List.new(connection, **params).call end |
#list_websets(**params) ⇒ Resources::WebsetCollection
List all websets
208 209 210 |
# File 'lib/exa/client.rb', line 208 def list_websets(**params) Services::Websets::List.new(connection, **params).call end |
#research_get(research_id, **params) ⇒ Resources::Research
Get status and results of a research task
111 112 113 |
# File 'lib/exa/client.rb', line 111 def research_get(research_id, **params) Services::ResearchGet.new(connection, research_id: research_id, **params).call end |
#research_list(**params) ⇒ Resources::ResearchList
List all research tasks
102 103 104 |
# File 'lib/exa/client.rb', line 102 def research_list(**params) Services::ResearchList.new(connection, **params).call end |
#research_start(**params) ⇒ Resources::Research
Start an asynchronous research task
93 94 95 |
# File 'lib/exa/client.rb', line 93 def research_start(**params) Services::ResearchStart.new(connection, **params).call end |
#search(query, **params) ⇒ Resources::SearchResult
Execute a search query
41 42 43 |
# File 'lib/exa/client.rb', line 41 def search(query, **params) Services::Search.new(connection, query: query, **params).call end |
#update_enrichment(webset_id:, id:, **params) ⇒ Resources::WebsetEnrichment
Update an enrichment
290 291 292 |
# File 'lib/exa/client.rb', line 290 def update_enrichment(webset_id:, id:, **params) Services::Websets::UpdateEnrichment.new(connection, webset_id: webset_id, id: id, **params).call end |
#update_import(id, **params) ⇒ Resources::Import
Update an import
432 433 434 |
# File 'lib/exa/client.rb', line 432 def update_import(id, **params) Services::Websets::UpdateImport.new(connection, id: id, **params).call end |
#update_monitor(id:, **params) ⇒ Resources::Monitor
Update a monitor
482 483 484 |
# File 'lib/exa/client.rb', line 482 def update_monitor(id:, **params) Services::Websets::Monitors::Update.new(connection, id: id, **params).call end |
#update_webset(id, **params) ⇒ Resources::Webset
Update a webset's title and/or metadata
245 246 247 |
# File 'lib/exa/client.rb', line 245 def update_webset(id, **params) Services::Websets::Update.new(connection, id: id, **params).call end |
#upload_import(file_path:, **params) ⇒ Resources::Import
Upload a file for import (creates import and uploads file)
413 414 415 |
# File 'lib/exa/client.rb', line 413 def upload_import(file_path:, **params) Services::Websets::UploadImport.new(connection, file_path: file_path, **params).call end |