exa-ai 0.3.1 → 0.4.1
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/README.md +58 -17
- data/exe/exa-ai +111 -6
- data/exe/exa-ai-enrichment-cancel +107 -0
- data/exe/exa-ai-enrichment-create +235 -0
- data/exe/exa-ai-enrichment-delete +121 -0
- data/exe/exa-ai-enrichment-get +103 -0
- data/exe/exa-ai-enrichment-list +98 -0
- data/exe/exa-ai-enrichment-update +170 -0
- data/exe/exa-ai-find-similar +240 -0
- data/exe/exa-ai-webset-cancel +96 -0
- data/exe/exa-ai-webset-create +192 -0
- data/exe/exa-ai-webset-delete +110 -0
- data/exe/exa-ai-webset-get +92 -0
- data/exe/exa-ai-webset-item-delete +111 -0
- data/exe/exa-ai-webset-item-get +104 -0
- data/exe/exa-ai-webset-item-list +93 -0
- data/exe/exa-ai-webset-list +90 -0
- data/exe/exa-ai-webset-search-cancel +103 -0
- data/exe/exa-ai-webset-search-create +233 -0
- data/exe/exa-ai-webset-search-get +104 -0
- data/exe/exa-ai-webset-update +139 -0
- data/lib/exa/cli/formatters/enrichment_formatter.rb +69 -0
- data/lib/exa/cli/formatters/webset_formatter.rb +68 -0
- data/lib/exa/cli/formatters/webset_item_formatter.rb +69 -0
- data/lib/exa/client.rb +171 -0
- data/lib/exa/resources/webset.rb +74 -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_search.rb +112 -0
- data/lib/exa/services/parameter_converter.rb +1 -0
- data/lib/exa/services/websets/cancel.rb +36 -0
- data/lib/exa/services/websets/cancel_enrichment.rb +35 -0
- data/lib/exa/services/websets/cancel_search.rb +44 -0
- data/lib/exa/services/websets/create.rb +45 -0
- data/lib/exa/services/websets/create_enrichment.rb +35 -0
- data/lib/exa/services/websets/create_search.rb +48 -0
- data/lib/exa/services/websets/create_search_validator.rb +128 -0
- data/lib/exa/services/websets/create_validator.rb +189 -0
- data/lib/exa/services/websets/delete.rb +36 -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 +43 -0
- data/lib/exa/services/websets/list.rb +25 -0
- data/lib/exa/services/websets/list_items.rb +20 -0
- data/lib/exa/services/websets/retrieve.rb +47 -0
- data/lib/exa/services/websets/retrieve_enrichment.rb +35 -0
- data/lib/exa/services/websets/update.rb +37 -0
- data/lib/exa/services/websets/update_enrichment.rb +36 -0
- data/lib/exa/services/websets_parameter_converter.rb +45 -0
- data/lib/exa/version.rb +1 -1
- data/lib/exa.rb +25 -0
- metadata +64 -3
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
|
|
11
|
+
args = ARGV.dup
|
|
12
|
+
while args.any?
|
|
13
|
+
arg = args.shift
|
|
14
|
+
case arg
|
|
15
|
+
when "--api-key"
|
|
16
|
+
api_key = args.shift
|
|
17
|
+
when "--output-format"
|
|
18
|
+
output_format = args.shift
|
|
19
|
+
when "--help", "-h"
|
|
20
|
+
puts <<~HELP
|
|
21
|
+
Usage: exa-ai webset-get <webset_id> [OPTIONS]
|
|
22
|
+
|
|
23
|
+
Retrieve details for a webset
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
webset_id ID of the webset to retrieve (required)
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
30
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
31
|
+
--help, -h Show this help message
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
exa-ai webset-get ws_abc123
|
|
35
|
+
exa-ai webset-get ws_abc123 --output-format pretty
|
|
36
|
+
HELP
|
|
37
|
+
exit 0
|
|
38
|
+
else
|
|
39
|
+
# First positional argument is webset_id
|
|
40
|
+
if webset_id.nil?
|
|
41
|
+
webset_id = arg
|
|
42
|
+
else
|
|
43
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
44
|
+
exit 1
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Validate
|
|
50
|
+
if webset_id.nil?
|
|
51
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
52
|
+
$stderr.puts "Usage: exa-ai webset-get <webset_id> [OPTIONS]"
|
|
53
|
+
$stderr.puts "Try 'exa-ai webset-get --help' for more information"
|
|
54
|
+
exit 1
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
begin
|
|
58
|
+
# Resolve API key and format
|
|
59
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
60
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
61
|
+
|
|
62
|
+
# Build client
|
|
63
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
64
|
+
|
|
65
|
+
# Get webset
|
|
66
|
+
webset = client.get_webset(webset_id)
|
|
67
|
+
|
|
68
|
+
# Format and output
|
|
69
|
+
output = Exa::CLI::Formatters::WebsetFormatter.format(webset, output_format)
|
|
70
|
+
puts output
|
|
71
|
+
|
|
72
|
+
rescue Exa::NotFound => e
|
|
73
|
+
$stderr.puts "Webset not found: #{e.message}"
|
|
74
|
+
exit 1
|
|
75
|
+
rescue Exa::Unauthorized => e
|
|
76
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
77
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
78
|
+
exit 1
|
|
79
|
+
rescue Exa::ClientError => e
|
|
80
|
+
$stderr.puts "Client error: #{e.message}"
|
|
81
|
+
exit 1
|
|
82
|
+
rescue Exa::ServerError => e
|
|
83
|
+
$stderr.puts "Server error: #{e.message}"
|
|
84
|
+
exit 1
|
|
85
|
+
rescue Exa::Error => e
|
|
86
|
+
$stderr.puts "Error: #{e.message}"
|
|
87
|
+
exit 1
|
|
88
|
+
rescue StandardError => e
|
|
89
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
90
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
91
|
+
exit 1
|
|
92
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
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 = args.shift
|
|
18
|
+
when "--output-format"
|
|
19
|
+
output_format = args.shift
|
|
20
|
+
when "--help", "-h"
|
|
21
|
+
puts <<~HELP
|
|
22
|
+
Usage: exa-ai webset-item-delete <webset_id> <item_id> [OPTIONS]
|
|
23
|
+
|
|
24
|
+
Delete 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-delete ws_123 item_456
|
|
37
|
+
exa-ai webset-item-delete ws_123 item_456 --output-format text
|
|
38
|
+
HELP
|
|
39
|
+
exit 0
|
|
40
|
+
else
|
|
41
|
+
# First positional argument is webset_id, second is item_id
|
|
42
|
+
if webset_id.nil?
|
|
43
|
+
webset_id = arg
|
|
44
|
+
elsif item_id.nil?
|
|
45
|
+
item_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-item-delete <webset_id> <item_id> [OPTIONS]"
|
|
57
|
+
$stderr.puts "Try 'exa-ai webset-item-delete --help' for more information"
|
|
58
|
+
exit 1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if item_id.nil?
|
|
62
|
+
$stderr.puts "Error: item_id argument is required"
|
|
63
|
+
$stderr.puts "Usage: exa-ai webset-item-delete <webset_id> <item_id> [OPTIONS]"
|
|
64
|
+
$stderr.puts "Try 'exa-ai webset-item-delete --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
|
+
# Delete item
|
|
77
|
+
result = client.delete_item(webset_id: webset_id, id: item_id)
|
|
78
|
+
|
|
79
|
+
# Format and output
|
|
80
|
+
if result
|
|
81
|
+
case output_format
|
|
82
|
+
when :text
|
|
83
|
+
puts "Item #{item_id} deleted successfully"
|
|
84
|
+
when :pretty
|
|
85
|
+
puts JSON.pretty_generate({ success: true, item_id: item_id })
|
|
86
|
+
else
|
|
87
|
+
puts JSON.generate({ success: true, item_id: item_id })
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
rescue Exa::NotFound => e
|
|
92
|
+
$stderr.puts "Item not found: #{e.message}"
|
|
93
|
+
exit 1
|
|
94
|
+
rescue Exa::Unauthorized => e
|
|
95
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
96
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
97
|
+
exit 1
|
|
98
|
+
rescue Exa::ClientError => e
|
|
99
|
+
$stderr.puts "Client error: #{e.message}"
|
|
100
|
+
exit 1
|
|
101
|
+
rescue Exa::ServerError => e
|
|
102
|
+
$stderr.puts "Server error: #{e.message}"
|
|
103
|
+
exit 1
|
|
104
|
+
rescue Exa::Error => e
|
|
105
|
+
$stderr.puts "Error: #{e.message}"
|
|
106
|
+
exit 1
|
|
107
|
+
rescue StandardError => e
|
|
108
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
109
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
110
|
+
exit 1
|
|
111
|
+
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
|
+
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 = args.shift
|
|
18
|
+
when "--output-format"
|
|
19
|
+
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?
|
|
44
|
+
webset_id = arg
|
|
45
|
+
elsif item_id.nil?
|
|
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
|
+
|
|
84
|
+
rescue Exa::NotFound => e
|
|
85
|
+
$stderr.puts "Item 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,93 @@
|
|
|
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
|
+
|
|
11
|
+
args = ARGV.dup
|
|
12
|
+
while args.any?
|
|
13
|
+
arg = args.shift
|
|
14
|
+
case arg
|
|
15
|
+
when "--api-key"
|
|
16
|
+
api_key = args.shift
|
|
17
|
+
when "--output-format"
|
|
18
|
+
output_format = args.shift
|
|
19
|
+
when "--help", "-h"
|
|
20
|
+
puts <<~HELP
|
|
21
|
+
Usage: exa-ai webset-item-list <webset_id> [OPTIONS]
|
|
22
|
+
|
|
23
|
+
List all items in a webset
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
webset_id ID of the webset (required)
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
30
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
31
|
+
--help, -h Show this help message
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
exa-ai webset-item-list ws_123
|
|
35
|
+
exa-ai webset-item-list ws_123 --output-format pretty
|
|
36
|
+
exa-ai webset-item-list ws_123 --output-format text
|
|
37
|
+
HELP
|
|
38
|
+
exit 0
|
|
39
|
+
else
|
|
40
|
+
# First positional argument is webset_id
|
|
41
|
+
if webset_id.nil?
|
|
42
|
+
webset_id = arg
|
|
43
|
+
else
|
|
44
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
45
|
+
exit 1
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Validate
|
|
51
|
+
if webset_id.nil?
|
|
52
|
+
$stderr.puts "Error: webset_id argument is required"
|
|
53
|
+
$stderr.puts "Usage: exa-ai webset-item-list <webset_id> [OPTIONS]"
|
|
54
|
+
$stderr.puts "Try 'exa-ai webset-item-list --help' for more information"
|
|
55
|
+
exit 1
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
begin
|
|
59
|
+
# Resolve API key and format
|
|
60
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
61
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
62
|
+
|
|
63
|
+
# Build client
|
|
64
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
65
|
+
|
|
66
|
+
# List items
|
|
67
|
+
items = client.list_items(webset_id: webset_id)
|
|
68
|
+
|
|
69
|
+
# Format and output
|
|
70
|
+
output = Exa::CLI::Formatters::WebsetItemFormatter.format_collection(items, output_format)
|
|
71
|
+
puts output
|
|
72
|
+
|
|
73
|
+
rescue Exa::NotFound => e
|
|
74
|
+
$stderr.puts "Webset not found: #{e.message}"
|
|
75
|
+
exit 1
|
|
76
|
+
rescue Exa::Unauthorized => e
|
|
77
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
78
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
79
|
+
exit 1
|
|
80
|
+
rescue Exa::ClientError => e
|
|
81
|
+
$stderr.puts "Client error: #{e.message}"
|
|
82
|
+
exit 1
|
|
83
|
+
rescue Exa::ServerError => e
|
|
84
|
+
$stderr.puts "Server error: #{e.message}"
|
|
85
|
+
exit 1
|
|
86
|
+
rescue Exa::Error => e
|
|
87
|
+
$stderr.puts "Error: #{e.message}"
|
|
88
|
+
exit 1
|
|
89
|
+
rescue StandardError => e
|
|
90
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
91
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
92
|
+
exit 1
|
|
93
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
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 "--limit"
|
|
17
|
+
limit = args.shift&.to_i
|
|
18
|
+
when "--cursor"
|
|
19
|
+
cursor = args.shift
|
|
20
|
+
when "--api-key"
|
|
21
|
+
api_key = args.shift
|
|
22
|
+
when "--output-format"
|
|
23
|
+
output_format = args.shift
|
|
24
|
+
when "--help", "-h"
|
|
25
|
+
puts <<~HELP
|
|
26
|
+
Usage: exa-ai webset-list [OPTIONS]
|
|
27
|
+
|
|
28
|
+
List all websets with optional pagination
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--limit N Maximum number of websets to return (default: 25, max: 100)
|
|
32
|
+
--cursor CURSOR Cursor for pagination (use nextCursor from previous response)
|
|
33
|
+
--api-key KEY Exa API key (or set EXA_API_KEY env var)
|
|
34
|
+
--output-format FMT Output format: json, pretty, or text (default: json)
|
|
35
|
+
--help, -h Show this help message
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
exa-ai webset-list
|
|
39
|
+
exa-ai webset-list --limit 10
|
|
40
|
+
exa-ai webset-list --limit 5 --cursor "abc123"
|
|
41
|
+
exa-ai webset-list --output-format pretty
|
|
42
|
+
HELP
|
|
43
|
+
exit 0
|
|
44
|
+
else
|
|
45
|
+
$stderr.puts "Unknown option: #{arg}"
|
|
46
|
+
exit 1
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
begin
|
|
51
|
+
# Resolve API key and format
|
|
52
|
+
api_key = Exa::CLI::Base.resolve_api_key(api_key)
|
|
53
|
+
output_format = Exa::CLI::Base.resolve_output_format(output_format)
|
|
54
|
+
|
|
55
|
+
# Build client
|
|
56
|
+
client = Exa::CLI::Base.build_client(api_key)
|
|
57
|
+
|
|
58
|
+
# List websets with optional pagination
|
|
59
|
+
list_params = {}
|
|
60
|
+
list_params[:limit] = limit if limit
|
|
61
|
+
list_params[:cursor] = cursor if cursor
|
|
62
|
+
|
|
63
|
+
collection = client.list_websets(**list_params)
|
|
64
|
+
|
|
65
|
+
# Format and output
|
|
66
|
+
output = Exa::CLI::Formatters::WebsetFormatter.format_collection(collection, output_format)
|
|
67
|
+
puts output
|
|
68
|
+
|
|
69
|
+
rescue Exa::ConfigurationError => e
|
|
70
|
+
$stderr.puts "Configuration error: #{e.message}"
|
|
71
|
+
exit 1
|
|
72
|
+
rescue Exa::Unauthorized => e
|
|
73
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
74
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
75
|
+
exit 1
|
|
76
|
+
rescue Exa::ClientError => e
|
|
77
|
+
$stderr.puts "Client error: #{e.message}"
|
|
78
|
+
exit 1
|
|
79
|
+
rescue Exa::ServerError => e
|
|
80
|
+
$stderr.puts "Server error: #{e.message}"
|
|
81
|
+
$stderr.puts "The Exa API may be experiencing issues. Please try again later."
|
|
82
|
+
exit 1
|
|
83
|
+
rescue Exa::Error => e
|
|
84
|
+
$stderr.puts "Error: #{e.message}"
|
|
85
|
+
exit 1
|
|
86
|
+
rescue StandardError => e
|
|
87
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
88
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
89
|
+
exit 1
|
|
90
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
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 = args.shift
|
|
18
|
+
when "--output-format"
|
|
19
|
+
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?
|
|
43
|
+
webset_id = arg
|
|
44
|
+
elsif search_id.nil?
|
|
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
|
+
|
|
83
|
+
rescue Exa::NotFound => e
|
|
84
|
+
$stderr.puts "Search not found: #{e.message}"
|
|
85
|
+
exit 1
|
|
86
|
+
rescue Exa::Unauthorized => e
|
|
87
|
+
$stderr.puts "Authentication error: #{e.message}"
|
|
88
|
+
$stderr.puts "Check your API key (set EXA_API_KEY or use --api-key)"
|
|
89
|
+
exit 1
|
|
90
|
+
rescue Exa::ClientError => e
|
|
91
|
+
$stderr.puts "Client error: #{e.message}"
|
|
92
|
+
exit 1
|
|
93
|
+
rescue Exa::ServerError => e
|
|
94
|
+
$stderr.puts "Server error: #{e.message}"
|
|
95
|
+
exit 1
|
|
96
|
+
rescue Exa::Error => e
|
|
97
|
+
$stderr.puts "Error: #{e.message}"
|
|
98
|
+
exit 1
|
|
99
|
+
rescue StandardError => e
|
|
100
|
+
$stderr.puts "Unexpected error: #{e.message}"
|
|
101
|
+
$stderr.puts e.backtrace.first(5) if ENV["DEBUG"]
|
|
102
|
+
exit 1
|
|
103
|
+
end
|