exa-ai 0.15.0 → 0.16.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 +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +72 -1
- data/exe/exa-ai +139 -1
- data/exe/exa-ai-enrichment-cancel +108 -0
- data/exe/exa-ai-enrichment-create +188 -0
- data/exe/exa-ai-enrichment-delete +122 -0
- data/exe/exa-ai-enrichment-get +104 -0
- data/exe/exa-ai-enrichment-list +99 -0
- data/exe/exa-ai-enrichment-update +140 -0
- data/exe/exa-ai-import-create +224 -0
- data/exe/exa-ai-import-delete +92 -0
- data/exe/exa-ai-import-get +92 -0
- data/exe/exa-ai-import-list +71 -0
- data/exe/exa-ai-import-update +130 -0
- data/exe/exa-ai-monitor-create +180 -0
- data/exe/exa-ai-monitor-delete +101 -0
- data/exe/exa-ai-monitor-get +92 -0
- data/exe/exa-ai-monitor-list +89 -0
- data/exe/exa-ai-monitor-runs-get +103 -0
- data/exe/exa-ai-monitor-runs-list +110 -0
- data/exe/exa-ai-monitor-update +192 -0
- data/exe/exa-ai-search +10 -0
- data/exe/exa-ai-search-monitor-create +1 -1
- data/exe/exa-ai-search-monitor-delete +1 -1
- data/exe/exa-ai-search-monitor-get +1 -1
- data/exe/exa-ai-search-monitor-list +1 -1
- data/exe/exa-ai-search-monitor-trigger +1 -1
- data/exe/exa-ai-webset-cancel +97 -0
- data/exe/exa-ai-webset-create +220 -0
- data/exe/exa-ai-webset-delete +111 -0
- data/exe/exa-ai-webset-get +93 -0
- data/exe/exa-ai-webset-item-delete +111 -0
- data/exe/exa-ai-webset-item-get +105 -0
- data/exe/exa-ai-webset-item-list +108 -0
- data/exe/exa-ai-webset-list +96 -0
- data/exe/exa-ai-webset-search-cancel +104 -0
- data/exe/exa-ai-webset-search-create +231 -0
- data/exe/exa-ai-webset-search-get +105 -0
- data/exe/exa-ai-webset-update +116 -0
- data/lib/exa/cli/formatters/enrichment_formatter.rb +125 -0
- data/lib/exa/cli/formatters/import_formatter.rb +153 -0
- data/lib/exa/cli/formatters/monitor_formatter.rb +144 -0
- data/lib/exa/cli/formatters/monitor_run_formatter.rb +126 -0
- data/lib/exa/cli/formatters/search_formatter.rb +22 -1
- data/lib/exa/cli/formatters/search_monitor_formatter.rb +1 -1
- data/lib/exa/cli/formatters/webset_formatter.rb +134 -0
- data/lib/exa/cli/formatters/webset_item_formatter.rb +132 -0
- data/lib/exa/cli/formatters/webset_search_formatter.rb +57 -0
- data/lib/exa/cli/search_parser.rb +4 -0
- data/lib/exa/client.rb +313 -1
- data/lib/exa/constants/websets.rb +19 -0
- data/lib/exa/resources/import.rb +111 -0
- data/lib/exa/resources/import_collection.rb +33 -0
- data/lib/exa/resources/monitor.rb +72 -0
- data/lib/exa/resources/monitor_collection.rb +30 -0
- data/lib/exa/resources/monitor_run.rb +82 -0
- data/lib/exa/resources/monitor_run_collection.rb +30 -0
- data/lib/exa/resources/search_monitor.rb +1 -0
- data/lib/exa/resources/search_result.rb +5 -1
- data/lib/exa/resources/webset.rb +106 -0
- data/lib/exa/resources/webset_collection.rb +33 -0
- data/lib/exa/resources/webset_enrichment.rb +71 -0
- data/lib/exa/resources/webset_enrichment_collection.rb +28 -0
- data/lib/exa/resources/webset_item.rb +63 -0
- data/lib/exa/resources/webset_item_collection.rb +33 -0
- data/lib/exa/resources/webset_search.rb +140 -0
- data/lib/exa/services/parameter_converter.rb +3 -2
- data/lib/exa/services/search.rb +2 -1
- data/lib/exa/services/websets/cancel.rb +19 -0
- data/lib/exa/services/websets/cancel_enrichment.rb +35 -0
- data/lib/exa/services/websets/cancel_search.rb +23 -0
- data/lib/exa/services/websets/create.rb +28 -0
- data/lib/exa/services/websets/create_enrichment.rb +35 -0
- data/lib/exa/services/websets/create_search.rb +28 -0
- data/lib/exa/services/websets/create_search_validator.rb +135 -0
- data/lib/exa/services/websets/create_validator.rb +214 -0
- data/lib/exa/services/websets/delete.rb +19 -0
- data/lib/exa/services/websets/delete_enrichment.rb +35 -0
- data/lib/exa/services/websets/delete_item.rb +20 -0
- data/lib/exa/services/websets/get_item.rb +20 -0
- data/lib/exa/services/websets/get_search.rb +22 -0
- data/lib/exa/services/websets/import_create.rb +22 -0
- data/lib/exa/services/websets/import_delete.rb +19 -0
- data/lib/exa/services/websets/import_get.rb +19 -0
- data/lib/exa/services/websets/import_list.rb +25 -0
- data/lib/exa/services/websets/import_update.rb +20 -0
- data/lib/exa/services/websets/import_upload.rb +59 -0
- data/lib/exa/services/websets/list.rb +25 -0
- data/lib/exa/services/websets/list_items.rb +26 -0
- data/lib/exa/services/websets/monitors/create.rb +31 -0
- data/lib/exa/services/websets/monitors/delete.rb +21 -0
- data/lib/exa/services/websets/monitors/get.rb +22 -0
- data/lib/exa/services/websets/monitors/list.rb +27 -0
- data/lib/exa/services/websets/monitors/runs/get.rb +25 -0
- data/lib/exa/services/websets/monitors/runs/list.rb +30 -0
- data/lib/exa/services/websets/monitors/update.rb +28 -0
- data/lib/exa/services/websets/retrieve.rb +30 -0
- data/lib/exa/services/websets/retrieve_enrichment.rb +35 -0
- data/lib/exa/services/websets/update.rb +40 -0
- data/lib/exa/services/websets/update_enrichment.rb +36 -0
- data/lib/exa/services/websets_parameter_converter.rb +51 -0
- data/lib/exa/version.rb +1 -1
- data/lib/exa.rb +51 -0
- metadata +331 -227
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
webset_id = nil
|
|
8
|
+
item_id = nil
|
|
9
|
+
api_key = nil
|
|
10
|
+
output_format = "json"
|
|
11
|
+
|
|
12
|
+
args = ARGV.dup
|
|
13
|
+
while args.any?
|
|
14
|
+
arg = args.shift
|
|
15
|
+
case arg
|
|
16
|
+
when "--api-key"
|
|
17
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
18
|
+
when "--output-format"
|
|
19
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
20
|
+
when "--help", "-h"
|
|
21
|
+
puts <<~HELP
|
|
22
|
+
Usage: exa-ai webset-item-get <webset_id> <item_id> [OPTIONS]
|
|
23
|
+
|
|
24
|
+
Get details of a webset item
|
|
25
|
+
|
|
26
|
+
Arguments:
|
|
27
|
+
webset_id ID of the webset (required)
|
|
28
|
+
item_id ID of the item (required)
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
32
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
33
|
+
--help, -h Show this help message
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
exa-ai webset-item-get ws_123 item_456
|
|
37
|
+
exa-ai webset-item-get ws_123 item_456 --output-format pretty
|
|
38
|
+
exa-ai webset-item-get ws_123 item_456 --output-format text
|
|
39
|
+
HELP
|
|
40
|
+
exit 0
|
|
41
|
+
else
|
|
42
|
+
# First positional argument is webset_id, second is item_id
|
|
43
|
+
if webset_id.nil? && !arg.start_with?("-")
|
|
44
|
+
webset_id = arg
|
|
45
|
+
elsif item_id.nil? && !arg.start_with?("-")
|
|
46
|
+
item_id = arg
|
|
47
|
+
else
|
|
48
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
49
|
+
exit 1
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Validate
|
|
55
|
+
if webset_id.nil?
|
|
56
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
57
|
+
$stderr.puts "Usage: exa-ai webset-item-get <webset_id> <item_id> [OPTIONS]"
|
|
58
|
+
$stderr.puts "Try 'exa-ai webset-item-get --help' for more information"
|
|
59
|
+
exit 1
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if item_id.nil?
|
|
63
|
+
$stderr.puts "Error: item_id argument is required"
|
|
64
|
+
$stderr.puts "Usage: exa-ai webset-item-get <webset_id> <item_id> [OPTIONS]"
|
|
65
|
+
$stderr.puts "Try 'exa-ai webset-item-get --help' for more information"
|
|
66
|
+
exit 1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
begin
|
|
70
|
+
# Resolve API key and format
|
|
71
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
72
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
73
|
+
|
|
74
|
+
# Build client
|
|
75
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
76
|
+
|
|
77
|
+
# Get item
|
|
78
|
+
item = client.get_item(webset_id: webset_id, id: item_id)
|
|
79
|
+
|
|
80
|
+
# Format and output
|
|
81
|
+
output = Exa::CLI::Formatters::WebsetItemFormatter.format(item, output_format)
|
|
82
|
+
puts output
|
|
83
|
+
$stdout.flush
|
|
84
|
+
|
|
85
|
+
rescue Exa::NotFound => e
|
|
86
|
+
$stderr.puts "Item not found: #{e.message}"
|
|
87
|
+
exit 1
|
|
88
|
+
rescue Exa::Unauthorized => e
|
|
89
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
90
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
91
|
+
exit 1
|
|
92
|
+
rescue Exa::ClientError => e
|
|
93
|
+
$stderr.puts "Client error: #{e.message}"
|
|
94
|
+
exit 1
|
|
95
|
+
rescue Exa::ServerError => e
|
|
96
|
+
$stderr.puts "Server error: #{e.message}"
|
|
97
|
+
exit 1
|
|
98
|
+
rescue Exa::Error => e
|
|
99
|
+
$stderr.puts "Error: #{e.message}"
|
|
100
|
+
exit 1
|
|
101
|
+
rescue StandardError => e
|
|
102
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
103
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
104
|
+
exit 1
|
|
105
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
webset_id = nil
|
|
8
|
+
api_key = nil
|
|
9
|
+
output_format = "json"
|
|
10
|
+
limit = nil
|
|
11
|
+
cursor = nil
|
|
12
|
+
|
|
13
|
+
args = ARGV.dup
|
|
14
|
+
while args.any?
|
|
15
|
+
arg = args.shift
|
|
16
|
+
case arg
|
|
17
|
+
when "--api-key"
|
|
18
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
19
|
+
when "--output-format"
|
|
20
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
21
|
+
when "--limit"
|
|
22
|
+
limit = Exa::CLI::Base.parse_integer("--limit", args.shift)
|
|
23
|
+
when "--cursor"
|
|
24
|
+
cursor = Exa::CLI::Base.text_value("--cursor", args.shift)
|
|
25
|
+
when "--help", "-h"
|
|
26
|
+
puts <<~HELP
|
|
27
|
+
Usage: exa-ai webset-item-list <webset_id> [OPTIONS]
|
|
28
|
+
|
|
29
|
+
List all items in a webset
|
|
30
|
+
|
|
31
|
+
Arguments:
|
|
32
|
+
webset_id ID of the webset (required)
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
--limit N Maximum number of items to return (default: 20)
|
|
36
|
+
--cursor CURSOR Cursor for pagination (use next_cursor from previous response)
|
|
37
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
38
|
+
--output-format FMT Output format: json, pretty, text, or toon (default: json)
|
|
39
|
+
--help, -h Show this help message
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
exa-ai webset-item-list ws_123
|
|
43
|
+
exa-ai webset-item-list ws_123 --limit 10
|
|
44
|
+
exa-ai webset-item-list ws_123 --limit 5 --cursor "abc123"
|
|
45
|
+
exa-ai webset-item-list ws_123 --output-format pretty
|
|
46
|
+
HELP
|
|
47
|
+
exit 0
|
|
48
|
+
else
|
|
49
|
+
# First positional argument is webset_id
|
|
50
|
+
if webset_id.nil? && !arg.start_with?("-")
|
|
51
|
+
webset_id = arg
|
|
52
|
+
else
|
|
53
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
54
|
+
exit 1
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Validate
|
|
60
|
+
if webset_id.nil?
|
|
61
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
62
|
+
$stderr.puts "Usage: exa-ai webset-item-list <webset_id> [OPTIONS]"
|
|
63
|
+
$stderr.puts "Try 'exa-ai webset-item-list --help' for more information"
|
|
64
|
+
exit 1
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
begin
|
|
68
|
+
# Resolve API key and format
|
|
69
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
70
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
71
|
+
|
|
72
|
+
# Build client
|
|
73
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
74
|
+
|
|
75
|
+
# Build list params
|
|
76
|
+
list_params = {}
|
|
77
|
+
list_params[:limit] = limit if limit
|
|
78
|
+
list_params[:cursor] = cursor if cursor
|
|
79
|
+
|
|
80
|
+
# List items
|
|
81
|
+
collection = client.list_items(webset_id: webset_id, **list_params)
|
|
82
|
+
|
|
83
|
+
# Format and output
|
|
84
|
+
output = Exa::CLI::Formatters::WebsetItemFormatter.format_collection(collection, output_format)
|
|
85
|
+
puts output
|
|
86
|
+
$stdout.flush
|
|
87
|
+
|
|
88
|
+
rescue Exa::NotFound => e
|
|
89
|
+
$stderr.puts "Webset not found: #{e.message}"
|
|
90
|
+
exit 1
|
|
91
|
+
rescue Exa::Unauthorized => e
|
|
92
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
93
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
94
|
+
exit 1
|
|
95
|
+
rescue Exa::ClientError => e
|
|
96
|
+
$stderr.puts "Client error: #{e.message}"
|
|
97
|
+
exit 1
|
|
98
|
+
rescue Exa::ServerError => e
|
|
99
|
+
$stderr.puts "Server error: #{e.message}"
|
|
100
|
+
exit 1
|
|
101
|
+
rescue Exa::Error => e
|
|
102
|
+
$stderr.puts "Error: #{e.message}"
|
|
103
|
+
exit 1
|
|
104
|
+
rescue StandardError => e
|
|
105
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
106
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
107
|
+
exit 1
|
|
108
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
limit = nil
|
|
8
|
+
cursor = nil
|
|
9
|
+
search = nil
|
|
10
|
+
api_key = nil
|
|
11
|
+
output_format = "json"
|
|
12
|
+
|
|
13
|
+
args = ARGV.dup
|
|
14
|
+
while args.any?
|
|
15
|
+
arg = args.shift
|
|
16
|
+
case arg
|
|
17
|
+
when "--limit"
|
|
18
|
+
limit = Exa::CLI::Base.parse_integer("--limit", args.shift)
|
|
19
|
+
when "--cursor"
|
|
20
|
+
cursor = Exa::CLI::Base.text_value("--cursor", args.shift)
|
|
21
|
+
when "--search"
|
|
22
|
+
search = Exa::CLI::Base.text_value("--search", args.shift)
|
|
23
|
+
when "--api-key"
|
|
24
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
25
|
+
when "--output-format"
|
|
26
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
27
|
+
when "--help", "-h"
|
|
28
|
+
puts <<~HELP
|
|
29
|
+
Usage: exa-ai webset-list [OPTIONS]
|
|
30
|
+
|
|
31
|
+
List all websets with optional pagination
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--limit N Maximum number of websets to return (default: 25, max: 100)
|
|
35
|
+
--cursor CURSOR Cursor for pagination (use next_cursor from previous response)
|
|
36
|
+
--search TEXT Only websets matching this text (2-50 characters)
|
|
37
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
38
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
39
|
+
--help, -h Show this help message
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
exa-ai webset-list
|
|
43
|
+
exa-ai webset-list --limit 10
|
|
44
|
+
exa-ai webset-list --limit 5 --cursor "abc123"
|
|
45
|
+
exa-ai webset-list --search "AI infrastructure startups"
|
|
46
|
+
exa-ai webset-list --output-format pretty
|
|
47
|
+
HELP
|
|
48
|
+
exit 0
|
|
49
|
+
else
|
|
50
|
+
Exa::CLI::Base.reject_unknown_option(arg)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
begin
|
|
55
|
+
# Resolve API key and format
|
|
56
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
57
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
58
|
+
|
|
59
|
+
# Build client
|
|
60
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
61
|
+
|
|
62
|
+
# List websets with optional pagination
|
|
63
|
+
list_params = {}
|
|
64
|
+
list_params[:limit] = limit if limit
|
|
65
|
+
list_params[:cursor] = cursor if cursor
|
|
66
|
+
list_params[:search] = search if search
|
|
67
|
+
|
|
68
|
+
collection = client.list_websets(**list_params)
|
|
69
|
+
|
|
70
|
+
# Format and output
|
|
71
|
+
output = Exa::CLI::Formatters::WebsetFormatter.format_collection(collection, output_format)
|
|
72
|
+
puts output
|
|
73
|
+
$stdout.flush
|
|
74
|
+
|
|
75
|
+
rescue Exa::ConfigurationError => e
|
|
76
|
+
$stderr.puts "Configuration error: #{e.message}"
|
|
77
|
+
exit 1
|
|
78
|
+
rescue Exa::Unauthorized => e
|
|
79
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
80
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
81
|
+
exit 1
|
|
82
|
+
rescue Exa::ClientError => e
|
|
83
|
+
$stderr.puts "Client error: #{e.message}"
|
|
84
|
+
exit 1
|
|
85
|
+
rescue Exa::ServerError => e
|
|
86
|
+
$stderr.puts "Server error: #{e.message}"
|
|
87
|
+
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
88
|
+
exit 1
|
|
89
|
+
rescue Exa::Error => e
|
|
90
|
+
$stderr.puts "Error: #{e.message}"
|
|
91
|
+
exit 1
|
|
92
|
+
rescue StandardError => e
|
|
93
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
94
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
95
|
+
exit 1
|
|
96
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse arguments
|
|
7
|
+
webset_id = nil
|
|
8
|
+
search_id = nil
|
|
9
|
+
api_key = nil
|
|
10
|
+
output_format = "json"
|
|
11
|
+
|
|
12
|
+
args = ARGV.dup
|
|
13
|
+
while args.any?
|
|
14
|
+
arg = args.shift
|
|
15
|
+
case arg
|
|
16
|
+
when "--api-key"
|
|
17
|
+
api_key = Exa::CLI::Base.text_value("--api-key", args.shift)
|
|
18
|
+
when "--output-format"
|
|
19
|
+
output_format = Exa::CLI::Base.text_value("--output-format", args.shift)
|
|
20
|
+
when "--help", "-h"
|
|
21
|
+
puts <<~HELP
|
|
22
|
+
Usage: exa-ai webset-search-cancel <webset_id> <search_id> [OPTIONS]
|
|
23
|
+
|
|
24
|
+
Cancel a running webset search
|
|
25
|
+
|
|
26
|
+
Arguments:
|
|
27
|
+
webset_id ID of the webset (required)
|
|
28
|
+
search_id ID of the search (required)
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
32
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
33
|
+
--help, -h Show this help message
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
exa-ai webset-search-cancel ws_123 search_456
|
|
37
|
+
exa-ai webset-search-cancel ws_123 search_456 --output-format text
|
|
38
|
+
HELP
|
|
39
|
+
exit 0
|
|
40
|
+
else
|
|
41
|
+
# First positional argument is webset_id, second is search_id
|
|
42
|
+
if webset_id.nil? && !arg.start_with?("-")
|
|
43
|
+
webset_id = arg
|
|
44
|
+
elsif search_id.nil? && !arg.start_with?("-")
|
|
45
|
+
search_id = arg
|
|
46
|
+
else
|
|
47
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
48
|
+
exit 1
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Validate
|
|
54
|
+
if webset_id.nil?
|
|
55
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
56
|
+
$stderr.puts "Usage: exa-ai webset-search-cancel <webset_id> <search_id> [OPTIONS]"
|
|
57
|
+
$stderr.puts "Try 'exa-ai webset-search-cancel --help' for more information"
|
|
58
|
+
exit 1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if search_id.nil?
|
|
62
|
+
$stderr.puts "Error: search_id argument is required"
|
|
63
|
+
$stderr.puts "Usage: exa-ai webset-search-cancel <webset_id> <search_id> [OPTIONS]"
|
|
64
|
+
$stderr.puts "Try 'exa-ai webset-search-cancel --help' for more information"
|
|
65
|
+
exit 1
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
begin
|
|
69
|
+
# Resolve API key and format
|
|
70
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
71
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
72
|
+
|
|
73
|
+
# Build client
|
|
74
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
75
|
+
|
|
76
|
+
# Cancel search
|
|
77
|
+
search = client.cancel_webset_search(webset_id: webset_id, id: search_id)
|
|
78
|
+
|
|
79
|
+
# Format and output
|
|
80
|
+
output = Exa::CLI::Formatters::SearchFormatter.format(search, output_format)
|
|
81
|
+
puts output
|
|
82
|
+
$stdout.flush
|
|
83
|
+
|
|
84
|
+
rescue Exa::NotFound => e
|
|
85
|
+
$stderr.puts "Search not found: #{e.message}"
|
|
86
|
+
exit 1
|
|
87
|
+
rescue Exa::Unauthorized => e
|
|
88
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
89
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
90
|
+
exit 1
|
|
91
|
+
rescue Exa::ClientError => e
|
|
92
|
+
$stderr.puts "Client error: #{e.message}"
|
|
93
|
+
exit 1
|
|
94
|
+
rescue Exa::ServerError => e
|
|
95
|
+
$stderr.puts "Server error: #{e.message}"
|
|
96
|
+
exit 1
|
|
97
|
+
rescue Exa::Error => e
|
|
98
|
+
$stderr.puts "Error: #{e.message}"
|
|
99
|
+
exit 1
|
|
100
|
+
rescue StandardError => e
|
|
101
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
102
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
103
|
+
exit 1
|
|
104
|
+
end
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "exa-ai"
|
|
5
|
+
|
|
6
|
+
# Parse command-line arguments
|
|
7
|
+
def parse_args(argv)
|
|
8
|
+
args = {
|
|
9
|
+
output_format: "json",
|
|
10
|
+
api_key: nil
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# First positional argument is webset_id
|
|
14
|
+
webset_id_found = false
|
|
15
|
+
|
|
16
|
+
i = 0
|
|
17
|
+
while i < argv.length
|
|
18
|
+
arg = argv[i]
|
|
19
|
+
case arg
|
|
20
|
+
when "--query"
|
|
21
|
+
args[:query] = Exa::CLI::Base.text_value("--query", argv[i + 1])
|
|
22
|
+
i += 2
|
|
23
|
+
when "--count"
|
|
24
|
+
args[:count] = Exa::CLI::Base.parse_integer("--count", argv[i + 1])
|
|
25
|
+
i += 2
|
|
26
|
+
when "--entity"
|
|
27
|
+
args[:entity] = Exa::CLI::Base.text_value("--entity", argv[i + 1])
|
|
28
|
+
i += 2
|
|
29
|
+
when "--entity-description"
|
|
30
|
+
args[:entity_description] = Exa::CLI::Base.text_value("--entity-description", argv[i + 1])
|
|
31
|
+
i += 2
|
|
32
|
+
when "--criteria"
|
|
33
|
+
args[:criteria] = Exa::CLI::Base.parse_json_or_file("--criteria", argv[i + 1], symbolize_names: true)
|
|
34
|
+
i += 2
|
|
35
|
+
when "--exclude"
|
|
36
|
+
args[:exclude] = Exa::CLI::Base.parse_json_or_file("--exclude", argv[i + 1], symbolize_names: true)
|
|
37
|
+
i += 2
|
|
38
|
+
when "--scope"
|
|
39
|
+
args[:scope] = Exa::CLI::Base.parse_json_or_file("--scope", argv[i + 1], symbolize_names: true)
|
|
40
|
+
i += 2
|
|
41
|
+
when "--recall"
|
|
42
|
+
args[:recall] = true
|
|
43
|
+
i += 1
|
|
44
|
+
when "--max-people-per-company"
|
|
45
|
+
args[:max_people_per_company] = Exa::CLI::Base.parse_integer("--max-people-per-company", argv[i + 1])
|
|
46
|
+
i += 2
|
|
47
|
+
when "--behavior"
|
|
48
|
+
behavior = Exa::CLI::Base.text_value("--behavior", argv[i + 1])
|
|
49
|
+
unless ["override", "append"].include?(behavior)
|
|
50
|
+
$stderr.puts "Error: --behavior must be override or append"
|
|
51
|
+
exit 1
|
|
52
|
+
end
|
|
53
|
+
args[:behavior] = behavior
|
|
54
|
+
i += 2
|
|
55
|
+
when "--metadata"
|
|
56
|
+
args[:metadata] = Exa::CLI::Base.parse_json_or_file("--metadata", argv[i + 1], symbolize_names: true)
|
|
57
|
+
i += 2
|
|
58
|
+
when "--api-key"
|
|
59
|
+
args[:api_key] = Exa::CLI::Base.text_value("--api-key", argv[i + 1])
|
|
60
|
+
i += 2
|
|
61
|
+
when "--output-format"
|
|
62
|
+
args[:output_format] = Exa::CLI::Base.text_value("--output-format", argv[i + 1])
|
|
63
|
+
i += 2
|
|
64
|
+
when "--help", "-h"
|
|
65
|
+
puts <<~HELP
|
|
66
|
+
Usage: exa-ai webset-search-create <webset_id> [OPTIONS]
|
|
67
|
+
|
|
68
|
+
Create a new search within a webset
|
|
69
|
+
|
|
70
|
+
Arguments:
|
|
71
|
+
webset_id ID of the webset (required)
|
|
72
|
+
|
|
73
|
+
Options:
|
|
74
|
+
--query QUERY Search query (required)
|
|
75
|
+
--count N Number of results to find (required)
|
|
76
|
+
--entity TYPE Entity type: person, company, article, research_paper, custom
|
|
77
|
+
--entity-description TXT Description for custom entity type (required with --entity custom)
|
|
78
|
+
--criteria JSON Search criteria array (supports @file.json)
|
|
79
|
+
Format: [{"description":"criterion 1"},{"description":"criterion 2"}]
|
|
80
|
+
--exclude JSON Items to exclude from results (supports @file.json)
|
|
81
|
+
Format: [{"source":"import|webset","id":"..."}]
|
|
82
|
+
--scope JSON Limit search to specific sources (supports @file.json)
|
|
83
|
+
Format: [{"source":"import|webset","id":"..."}]
|
|
84
|
+
Filters this search to only items from these sources
|
|
85
|
+
With relationship (hop search):
|
|
86
|
+
[{"source":"webset","id":"ws_123",
|
|
87
|
+
"relationship":{"definition":"investors of","limit":3}}]
|
|
88
|
+
--max-people-per-company N Most people to find for each company (with --entity person)
|
|
89
|
+
--recall Estimate total available results
|
|
90
|
+
--behavior TYPE "override" (replace items) or "append" (add items)
|
|
91
|
+
Default: override when scope is present, append otherwise
|
|
92
|
+
--metadata JSON Custom metadata (supports @file.json)
|
|
93
|
+
Format: {"key":"value"}
|
|
94
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
95
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
96
|
+
--help, -h Show this help message
|
|
97
|
+
|
|
98
|
+
Examples:
|
|
99
|
+
# Basic search
|
|
100
|
+
exa-ai webset-search-create ws_123 --query "AI startups" --count 10
|
|
101
|
+
|
|
102
|
+
# Search with entity type
|
|
103
|
+
exa-ai webset-search-create ws_123 --query "tech CEOs" --count 10 --entity person
|
|
104
|
+
exa-ai webset-search-create ws_123 --query "Silicon Valley firms" --count 10 --entity company
|
|
105
|
+
|
|
106
|
+
# Scoped search (filter to specific import)
|
|
107
|
+
exa-ai webset-search-create ws_123 --query "CTOs" --count 10 \\
|
|
108
|
+
--scope '[{"source":"import","id":"import_abc"}]'
|
|
109
|
+
|
|
110
|
+
# Hop search (find investors of companies in webset)
|
|
111
|
+
exa-ai webset-search-create ws_123 --query "investors" --count 10 \\
|
|
112
|
+
--scope '[{"source":"webset","id":"ws_companies","relationship":{"definition":"investors of","limit":5}}]'
|
|
113
|
+
|
|
114
|
+
# Search with criteria and behavior
|
|
115
|
+
exa-ai webset-search-create ws_123 --query "machine learning" --count 50
|
|
116
|
+
exa-ai webset-search-create ws_123 --query "research" --count 10 --behavior append --recall
|
|
117
|
+
HELP
|
|
118
|
+
exit 0
|
|
119
|
+
else
|
|
120
|
+
# First positional argument is webset_id
|
|
121
|
+
if !webset_id_found && !arg.start_with?("-")
|
|
122
|
+
args[:webset_id] = arg
|
|
123
|
+
webset_id_found = true
|
|
124
|
+
else
|
|
125
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
126
|
+
exit 1
|
|
127
|
+
end
|
|
128
|
+
i += 1
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
args
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Main execution
|
|
136
|
+
begin
|
|
137
|
+
args = parse_args(ARGV)
|
|
138
|
+
|
|
139
|
+
# Validate required parameters
|
|
140
|
+
unless args[:webset_id]
|
|
141
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
142
|
+
$stderr.puts "Run 'exa-ai webset-search-create --help' for usage information"
|
|
143
|
+
exit 1
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
unless args[:query]
|
|
147
|
+
$stderr.puts "Error: --query is required"
|
|
148
|
+
$stderr.puts "Run 'exa-ai webset-search-create --help' for usage information"
|
|
149
|
+
exit 1
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
unless args[:count]
|
|
153
|
+
$stderr.puts "Error: --count is required"
|
|
154
|
+
$stderr.puts "Run 'exa-ai webset-search-create --help' for usage information"
|
|
155
|
+
exit 1
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Resolve API key
|
|
159
|
+
api_key = Exa::CLI::Base.resolve_api_key(args[:api_key])
|
|
160
|
+
|
|
161
|
+
# Resolve output format
|
|
162
|
+
output_format = Exa::CLI::Base.resolve_output_format(args[:output_format])
|
|
163
|
+
|
|
164
|
+
# Build client
|
|
165
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
166
|
+
|
|
167
|
+
# Build entity parameter from --entity and --entity-description
|
|
168
|
+
entity = nil
|
|
169
|
+
if args[:entity]
|
|
170
|
+
# Build entity hash from string type
|
|
171
|
+
entity = { type: args[:entity] }
|
|
172
|
+
if args[:entity] == "custom"
|
|
173
|
+
unless args[:entity_description]
|
|
174
|
+
$stderr.puts "Error: --entity-description is required when --entity is 'custom'"
|
|
175
|
+
exit 1
|
|
176
|
+
end
|
|
177
|
+
entity[:description] = args[:entity_description]
|
|
178
|
+
elsif args[:entity_description]
|
|
179
|
+
$stderr.puts "Warning: --entity-description is only used with --entity custom (ignoring)"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Prepare search parameters
|
|
184
|
+
search_params = { query: args[:query] }
|
|
185
|
+
search_params[:count] = args[:count] if args[:count]
|
|
186
|
+
search_params[:entity] = entity if entity
|
|
187
|
+
search_params[:criteria] = args[:criteria] if args[:criteria]
|
|
188
|
+
search_params[:exclude] = args[:exclude] if args[:exclude]
|
|
189
|
+
search_params[:scope] = args[:scope] if args[:scope]
|
|
190
|
+
search_params[:recall] = args[:recall] if args[:recall]
|
|
191
|
+
search_params[:max_people_per_company] = args[:max_people_per_company] if args[:max_people_per_company]
|
|
192
|
+
search_params[:behavior] = args[:behavior] if args[:behavior]
|
|
193
|
+
search_params[:metadata] = args[:metadata] if args[:metadata]
|
|
194
|
+
|
|
195
|
+
# Create search
|
|
196
|
+
search = client.create_webset_search(webset_id: args[:webset_id], **search_params)
|
|
197
|
+
|
|
198
|
+
# Format and output result
|
|
199
|
+
output = Exa::CLI::Formatters::WebsetSearchFormatter.format(search, output_format)
|
|
200
|
+
puts output
|
|
201
|
+
$stdout.flush
|
|
202
|
+
|
|
203
|
+
rescue Exa::ConfigurationError => e
|
|
204
|
+
$stderr.puts "Configuration error: #{e.message}"
|
|
205
|
+
exit 1
|
|
206
|
+
rescue Exa::Unauthorized => e
|
|
207
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
208
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
209
|
+
exit 1
|
|
210
|
+
rescue Exa::NotFound => e
|
|
211
|
+
$stderr.puts "Webset not found: #{e.message}"
|
|
212
|
+
exit 1
|
|
213
|
+
rescue Exa::ClientError => e
|
|
214
|
+
$stderr.puts "Client error: #{e.message}"
|
|
215
|
+
exit 1
|
|
216
|
+
rescue Exa::ServerError => e
|
|
217
|
+
$stderr.puts "Server error: #{e.message}"
|
|
218
|
+
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
219
|
+
exit 1
|
|
220
|
+
rescue Exa::Error => e
|
|
221
|
+
$stderr.puts "Error: #{e.message}"
|
|
222
|
+
exit 1
|
|
223
|
+
rescue ArgumentError => e
|
|
224
|
+
# create_webset_search refuses bad params, such as a count below 1.
|
|
225
|
+
$stderr.puts "Error: #{e.message}"
|
|
226
|
+
exit 1
|
|
227
|
+
rescue StandardError => e
|
|
228
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
229
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
230
|
+
exit 1
|
|
231
|
+
end
|