exaonruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +614 -0
- data/exaonruby.gemspec +37 -0
- data/exe/exa +7 -0
- data/lib/exa/cli.rb +458 -0
- data/lib/exa/client.rb +210 -0
- data/lib/exa/configuration.rb +81 -0
- data/lib/exa/endpoints/answer.rb +109 -0
- data/lib/exa/endpoints/contents.rb +141 -0
- data/lib/exa/endpoints/events.rb +71 -0
- data/lib/exa/endpoints/find_similar.rb +154 -0
- data/lib/exa/endpoints/imports.rb +145 -0
- data/lib/exa/endpoints/monitors.rb +193 -0
- data/lib/exa/endpoints/research.rb +158 -0
- data/lib/exa/endpoints/search.rb +195 -0
- data/lib/exa/endpoints/webhooks.rb +161 -0
- data/lib/exa/endpoints/webset_enrichments.rb +162 -0
- data/lib/exa/endpoints/webset_items.rb +90 -0
- data/lib/exa/endpoints/webset_searches.rb +137 -0
- data/lib/exa/endpoints/websets.rb +214 -0
- data/lib/exa/errors.rb +180 -0
- data/lib/exa/resources/answer_response.rb +101 -0
- data/lib/exa/resources/base.rb +56 -0
- data/lib/exa/resources/contents_response.rb +123 -0
- data/lib/exa/resources/event.rb +84 -0
- data/lib/exa/resources/import.rb +137 -0
- data/lib/exa/resources/monitor.rb +205 -0
- data/lib/exa/resources/paginated_response.rb +87 -0
- data/lib/exa/resources/research_task.rb +165 -0
- data/lib/exa/resources/search_response.rb +111 -0
- data/lib/exa/resources/search_result.rb +95 -0
- data/lib/exa/resources/webhook.rb +152 -0
- data/lib/exa/resources/webset.rb +491 -0
- data/lib/exa/resources/webset_item.rb +256 -0
- data/lib/exa/utils/parameter_converter.rb +159 -0
- data/lib/exa/utils/webhook_handler.rb +239 -0
- data/lib/exa/version.rb +7 -0
- data/lib/exa.rb +130 -0
- metadata +146 -0
data/lib/exa.rb
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# typed: strict
|
|
4
|
+
|
|
5
|
+
require_relative "exa/version"
|
|
6
|
+
require_relative "exa/errors"
|
|
7
|
+
require_relative "exa/configuration"
|
|
8
|
+
|
|
9
|
+
require_relative "exa/utils/parameter_converter"
|
|
10
|
+
require_relative "exa/utils/webhook_handler"
|
|
11
|
+
|
|
12
|
+
require_relative "exa/resources/base"
|
|
13
|
+
require_relative "exa/resources/search_result"
|
|
14
|
+
require_relative "exa/resources/search_response"
|
|
15
|
+
require_relative "exa/resources/contents_response"
|
|
16
|
+
require_relative "exa/resources/answer_response"
|
|
17
|
+
require_relative "exa/resources/research_task"
|
|
18
|
+
require_relative "exa/resources/webset"
|
|
19
|
+
require_relative "exa/resources/webset_item"
|
|
20
|
+
require_relative "exa/resources/paginated_response"
|
|
21
|
+
require_relative "exa/resources/monitor"
|
|
22
|
+
require_relative "exa/resources/import"
|
|
23
|
+
require_relative "exa/resources/webhook"
|
|
24
|
+
require_relative "exa/resources/event"
|
|
25
|
+
|
|
26
|
+
require_relative "exa/endpoints/search"
|
|
27
|
+
require_relative "exa/endpoints/contents"
|
|
28
|
+
require_relative "exa/endpoints/find_similar"
|
|
29
|
+
require_relative "exa/endpoints/answer"
|
|
30
|
+
require_relative "exa/endpoints/research"
|
|
31
|
+
require_relative "exa/endpoints/websets"
|
|
32
|
+
require_relative "exa/endpoints/webset_items"
|
|
33
|
+
require_relative "exa/endpoints/webset_searches"
|
|
34
|
+
require_relative "exa/endpoints/webset_enrichments"
|
|
35
|
+
require_relative "exa/endpoints/monitors"
|
|
36
|
+
require_relative "exa/endpoints/imports"
|
|
37
|
+
require_relative "exa/endpoints/webhooks"
|
|
38
|
+
require_relative "exa/endpoints/events"
|
|
39
|
+
|
|
40
|
+
require_relative "exa/client"
|
|
41
|
+
|
|
42
|
+
module Exa
|
|
43
|
+
class << self
|
|
44
|
+
# @return [Configuration] Global configuration
|
|
45
|
+
attr_accessor :configuration
|
|
46
|
+
|
|
47
|
+
# @return [Logger, nil] Optional logger for debug output
|
|
48
|
+
attr_accessor :logger
|
|
49
|
+
|
|
50
|
+
# Configures the Exa gem globally
|
|
51
|
+
#
|
|
52
|
+
# @yield [Configuration] Configuration instance
|
|
53
|
+
#
|
|
54
|
+
# @example Configure globally
|
|
55
|
+
# Exa.configure do |config|
|
|
56
|
+
# config.api_key = "your-api-key"
|
|
57
|
+
# config.timeout = 120
|
|
58
|
+
# end
|
|
59
|
+
def configure
|
|
60
|
+
self.configuration ||= Configuration.new
|
|
61
|
+
yield(configuration)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Returns a default client using global configuration
|
|
65
|
+
#
|
|
66
|
+
# @return [Client] Default client instance
|
|
67
|
+
#
|
|
68
|
+
# @example Using default client
|
|
69
|
+
# Exa.configure { |c| c.api_key = ENV["EXA_API_KEY"] }
|
|
70
|
+
# results = Exa.client.search("AI research")
|
|
71
|
+
def client
|
|
72
|
+
@client ||= Client.new do |config|
|
|
73
|
+
if configuration
|
|
74
|
+
config.api_key = configuration.api_key
|
|
75
|
+
config.base_url = configuration.base_url
|
|
76
|
+
config.websets_base_url = configuration.websets_base_url
|
|
77
|
+
config.timeout = configuration.timeout
|
|
78
|
+
config.max_retries = configuration.max_retries
|
|
79
|
+
config.retry_delay = configuration.retry_delay
|
|
80
|
+
config.max_retry_delay = configuration.max_retry_delay
|
|
81
|
+
config.retry_statuses = configuration.retry_statuses.dup
|
|
82
|
+
config.retry_exceptions = configuration.retry_exceptions.dup
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Resets the default client (useful for testing)
|
|
88
|
+
#
|
|
89
|
+
# @return [void]
|
|
90
|
+
def reset_client!
|
|
91
|
+
@client = nil
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Convenience method to perform a search using the default client
|
|
95
|
+
#
|
|
96
|
+
# @param query [String] Search query
|
|
97
|
+
# @param options [Hash] Search options
|
|
98
|
+
# @return [Resources::SearchResponse] Search results
|
|
99
|
+
#
|
|
100
|
+
# @example Quick search
|
|
101
|
+
# Exa.search("Latest AI research", text: true)
|
|
102
|
+
def search(query, **options)
|
|
103
|
+
client.search(query, **options)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Convenience method to get contents using the default client
|
|
107
|
+
#
|
|
108
|
+
# @param urls [Array<String>] URLs to fetch
|
|
109
|
+
# @param options [Hash] Content options
|
|
110
|
+
# @return [Resources::ContentsResponse] Contents results
|
|
111
|
+
#
|
|
112
|
+
# @example Quick contents
|
|
113
|
+
# Exa.get_contents(["https://example.com"])
|
|
114
|
+
def get_contents(urls, **options)
|
|
115
|
+
client.get_contents(urls, **options)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Convenience method to find similar links using the default client
|
|
119
|
+
#
|
|
120
|
+
# @param url [String] Source URL
|
|
121
|
+
# @param options [Hash] Search options
|
|
122
|
+
# @return [Resources::SearchResponse] Similar links
|
|
123
|
+
#
|
|
124
|
+
# @example Quick find similar
|
|
125
|
+
# Exa.find_similar("https://example.com/article")
|
|
126
|
+
def find_similar(url, **options)
|
|
127
|
+
client.find_similar(url, **options)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: exaonruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- tigel-agm
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '3.0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '2.0'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '3.0'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: faraday-retry
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '2.0'
|
|
39
|
+
- - "<"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3.0'
|
|
42
|
+
type: :runtime
|
|
43
|
+
prerelease: false
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '2.0'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '3.0'
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: thor
|
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '1.0'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.0'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '3.0'
|
|
72
|
+
description: A production-ready Ruby gem wrapper for the Exa.ai Search and Websets
|
|
73
|
+
APIs. Features neural search, LLM-powered answers, async research tasks, Websets
|
|
74
|
+
management (monitors, imports, webhooks), and a beautiful CLI. Includes n8n/Zapier
|
|
75
|
+
webhook signature verification utilities.
|
|
76
|
+
email: []
|
|
77
|
+
executables:
|
|
78
|
+
- exa
|
|
79
|
+
extensions: []
|
|
80
|
+
extra_rdoc_files: []
|
|
81
|
+
files:
|
|
82
|
+
- LICENSE.txt
|
|
83
|
+
- README.md
|
|
84
|
+
- exaonruby.gemspec
|
|
85
|
+
- exe/exa
|
|
86
|
+
- lib/exa.rb
|
|
87
|
+
- lib/exa/cli.rb
|
|
88
|
+
- lib/exa/client.rb
|
|
89
|
+
- lib/exa/configuration.rb
|
|
90
|
+
- lib/exa/endpoints/answer.rb
|
|
91
|
+
- lib/exa/endpoints/contents.rb
|
|
92
|
+
- lib/exa/endpoints/events.rb
|
|
93
|
+
- lib/exa/endpoints/find_similar.rb
|
|
94
|
+
- lib/exa/endpoints/imports.rb
|
|
95
|
+
- lib/exa/endpoints/monitors.rb
|
|
96
|
+
- lib/exa/endpoints/research.rb
|
|
97
|
+
- lib/exa/endpoints/search.rb
|
|
98
|
+
- lib/exa/endpoints/webhooks.rb
|
|
99
|
+
- lib/exa/endpoints/webset_enrichments.rb
|
|
100
|
+
- lib/exa/endpoints/webset_items.rb
|
|
101
|
+
- lib/exa/endpoints/webset_searches.rb
|
|
102
|
+
- lib/exa/endpoints/websets.rb
|
|
103
|
+
- lib/exa/errors.rb
|
|
104
|
+
- lib/exa/resources/answer_response.rb
|
|
105
|
+
- lib/exa/resources/base.rb
|
|
106
|
+
- lib/exa/resources/contents_response.rb
|
|
107
|
+
- lib/exa/resources/event.rb
|
|
108
|
+
- lib/exa/resources/import.rb
|
|
109
|
+
- lib/exa/resources/monitor.rb
|
|
110
|
+
- lib/exa/resources/paginated_response.rb
|
|
111
|
+
- lib/exa/resources/research_task.rb
|
|
112
|
+
- lib/exa/resources/search_response.rb
|
|
113
|
+
- lib/exa/resources/search_result.rb
|
|
114
|
+
- lib/exa/resources/webhook.rb
|
|
115
|
+
- lib/exa/resources/webset.rb
|
|
116
|
+
- lib/exa/resources/webset_item.rb
|
|
117
|
+
- lib/exa/utils/parameter_converter.rb
|
|
118
|
+
- lib/exa/utils/webhook_handler.rb
|
|
119
|
+
- lib/exa/version.rb
|
|
120
|
+
homepage: https://github.com/tigel-agm/exaonruby
|
|
121
|
+
licenses:
|
|
122
|
+
- MIT
|
|
123
|
+
metadata:
|
|
124
|
+
homepage_uri: https://github.com/tigel-agm/exaonruby
|
|
125
|
+
source_code_uri: https://github.com/tigel-agm/exaonruby
|
|
126
|
+
changelog_uri: https://github.com/tigel-agm/exaonruby/blob/main/CHANGELOG.md
|
|
127
|
+
documentation_uri: https://github.com/tigel-agm/exaonruby#readme
|
|
128
|
+
rubygems_mfa_required: 'true'
|
|
129
|
+
rdoc_options: []
|
|
130
|
+
require_paths:
|
|
131
|
+
- lib
|
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '3.1'
|
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
|
+
requirements:
|
|
139
|
+
- - ">="
|
|
140
|
+
- !ruby/object:Gem::Version
|
|
141
|
+
version: '0'
|
|
142
|
+
requirements: []
|
|
143
|
+
rubygems_version: 4.0.2
|
|
144
|
+
specification_version: 4
|
|
145
|
+
summary: Complete Ruby client for the Exa.ai API with beautiful CLI
|
|
146
|
+
test_files: []
|