context.dev 1.20.1 → 1.21.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 +8 -0
- data/README.md +1 -1
- data/lib/context_dev/models/web_search_params.rb +218 -0
- data/lib/context_dev/models/web_search_response.rb +124 -0
- data/lib/context_dev/models.rb +2 -0
- data/lib/context_dev/resources/web.rb +37 -0
- data/lib/context_dev/version.rb +1 -1
- data/lib/context_dev.rb +2 -0
- data/rbi/context_dev/models/web_search_params.rbi +375 -0
- data/rbi/context_dev/models/web_search_response.rbi +271 -0
- data/rbi/context_dev/models.rbi +2 -0
- data/rbi/context_dev/resources/web.rbi +37 -0
- data/sig/context_dev/models/web_search_params.rbs +193 -0
- data/sig/context_dev/models/web_search_response.rbs +115 -0
- data/sig/context_dev/models.rbs +2 -0
- data/sig/context_dev/resources/web.rbs +11 -0
- metadata +8 -2
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module ContextDev
|
|
4
|
+
module Models
|
|
5
|
+
class WebSearchParams < ContextDev::Internal::Type::BaseModel
|
|
6
|
+
extend ContextDev::Internal::Type::RequestParameters::Converter
|
|
7
|
+
include ContextDev::Internal::Type::RequestParameters
|
|
8
|
+
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(ContextDev::WebSearchParams, ContextDev::Internal::AnyHash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Natural-language search query.
|
|
15
|
+
sig { returns(String) }
|
|
16
|
+
attr_accessor :query
|
|
17
|
+
|
|
18
|
+
# Blocklist — drop results from these domains. Example: ["pinterest.com",
|
|
19
|
+
# "reddit.com"].
|
|
20
|
+
sig { returns(T.nilable(T::Array[String])) }
|
|
21
|
+
attr_reader :exclude_domains
|
|
22
|
+
|
|
23
|
+
sig { params(exclude_domains: T::Array[String]).void }
|
|
24
|
+
attr_writer :exclude_domains
|
|
25
|
+
|
|
26
|
+
# Restrict results to content published within this window.
|
|
27
|
+
sig do
|
|
28
|
+
returns(T.nilable(ContextDev::WebSearchParams::Freshness::OrSymbol))
|
|
29
|
+
end
|
|
30
|
+
attr_reader :freshness
|
|
31
|
+
|
|
32
|
+
sig do
|
|
33
|
+
params(freshness: ContextDev::WebSearchParams::Freshness::OrSymbol).void
|
|
34
|
+
end
|
|
35
|
+
attr_writer :freshness
|
|
36
|
+
|
|
37
|
+
# Allowlist — only return results from these domains. Example: ["arxiv.org",
|
|
38
|
+
# "github.com"].
|
|
39
|
+
sig { returns(T.nilable(T::Array[String])) }
|
|
40
|
+
attr_reader :include_domains
|
|
41
|
+
|
|
42
|
+
sig { params(include_domains: T::Array[String]).void }
|
|
43
|
+
attr_writer :include_domains
|
|
44
|
+
|
|
45
|
+
# Inline Markdown scraping for each result. Set `enabled: true` to activate.
|
|
46
|
+
sig { returns(T.nilable(ContextDev::WebSearchParams::MarkdownOptions)) }
|
|
47
|
+
attr_reader :markdown_options
|
|
48
|
+
|
|
49
|
+
sig do
|
|
50
|
+
params(
|
|
51
|
+
markdown_options: ContextDev::WebSearchParams::MarkdownOptions::OrHash
|
|
52
|
+
).void
|
|
53
|
+
end
|
|
54
|
+
attr_writer :markdown_options
|
|
55
|
+
|
|
56
|
+
# Expand the query into multiple parallel variants for broader recall.
|
|
57
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
58
|
+
attr_reader :query_fanout
|
|
59
|
+
|
|
60
|
+
sig { params(query_fanout: T::Boolean).void }
|
|
61
|
+
attr_writer :query_fanout
|
|
62
|
+
|
|
63
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
64
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
65
|
+
# value is 300000ms (5 minutes).
|
|
66
|
+
sig { returns(T.nilable(Integer)) }
|
|
67
|
+
attr_reader :timeout_ms
|
|
68
|
+
|
|
69
|
+
sig { params(timeout_ms: Integer).void }
|
|
70
|
+
attr_writer :timeout_ms
|
|
71
|
+
|
|
72
|
+
sig do
|
|
73
|
+
params(
|
|
74
|
+
query: String,
|
|
75
|
+
exclude_domains: T::Array[String],
|
|
76
|
+
freshness: ContextDev::WebSearchParams::Freshness::OrSymbol,
|
|
77
|
+
include_domains: T::Array[String],
|
|
78
|
+
markdown_options:
|
|
79
|
+
ContextDev::WebSearchParams::MarkdownOptions::OrHash,
|
|
80
|
+
query_fanout: T::Boolean,
|
|
81
|
+
timeout_ms: Integer,
|
|
82
|
+
request_options: ContextDev::RequestOptions::OrHash
|
|
83
|
+
).returns(T.attached_class)
|
|
84
|
+
end
|
|
85
|
+
def self.new(
|
|
86
|
+
# Natural-language search query.
|
|
87
|
+
query:,
|
|
88
|
+
# Blocklist — drop results from these domains. Example: ["pinterest.com",
|
|
89
|
+
# "reddit.com"].
|
|
90
|
+
exclude_domains: nil,
|
|
91
|
+
# Restrict results to content published within this window.
|
|
92
|
+
freshness: nil,
|
|
93
|
+
# Allowlist — only return results from these domains. Example: ["arxiv.org",
|
|
94
|
+
# "github.com"].
|
|
95
|
+
include_domains: nil,
|
|
96
|
+
# Inline Markdown scraping for each result. Set `enabled: true` to activate.
|
|
97
|
+
markdown_options: nil,
|
|
98
|
+
# Expand the query into multiple parallel variants for broader recall.
|
|
99
|
+
query_fanout: nil,
|
|
100
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
101
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
102
|
+
# value is 300000ms (5 minutes).
|
|
103
|
+
timeout_ms: nil,
|
|
104
|
+
request_options: {}
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
sig do
|
|
109
|
+
override.returns(
|
|
110
|
+
{
|
|
111
|
+
query: String,
|
|
112
|
+
exclude_domains: T::Array[String],
|
|
113
|
+
freshness: ContextDev::WebSearchParams::Freshness::OrSymbol,
|
|
114
|
+
include_domains: T::Array[String],
|
|
115
|
+
markdown_options: ContextDev::WebSearchParams::MarkdownOptions,
|
|
116
|
+
query_fanout: T::Boolean,
|
|
117
|
+
timeout_ms: Integer,
|
|
118
|
+
request_options: ContextDev::RequestOptions
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
def to_hash
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Restrict results to content published within this window.
|
|
126
|
+
module Freshness
|
|
127
|
+
extend ContextDev::Internal::Type::Enum
|
|
128
|
+
|
|
129
|
+
TaggedSymbol =
|
|
130
|
+
T.type_alias { T.all(Symbol, ContextDev::WebSearchParams::Freshness) }
|
|
131
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
132
|
+
|
|
133
|
+
LAST_24_HOURS =
|
|
134
|
+
T.let(
|
|
135
|
+
:last_24_hours,
|
|
136
|
+
ContextDev::WebSearchParams::Freshness::TaggedSymbol
|
|
137
|
+
)
|
|
138
|
+
LAST_WEEK =
|
|
139
|
+
T.let(
|
|
140
|
+
:last_week,
|
|
141
|
+
ContextDev::WebSearchParams::Freshness::TaggedSymbol
|
|
142
|
+
)
|
|
143
|
+
LAST_MONTH =
|
|
144
|
+
T.let(
|
|
145
|
+
:last_month,
|
|
146
|
+
ContextDev::WebSearchParams::Freshness::TaggedSymbol
|
|
147
|
+
)
|
|
148
|
+
LAST_YEAR =
|
|
149
|
+
T.let(
|
|
150
|
+
:last_year,
|
|
151
|
+
ContextDev::WebSearchParams::Freshness::TaggedSymbol
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
sig do
|
|
155
|
+
override.returns(
|
|
156
|
+
T::Array[ContextDev::WebSearchParams::Freshness::TaggedSymbol]
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
def self.values
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
class MarkdownOptions < ContextDev::Internal::Type::BaseModel
|
|
164
|
+
OrHash =
|
|
165
|
+
T.type_alias do
|
|
166
|
+
T.any(
|
|
167
|
+
ContextDev::WebSearchParams::MarkdownOptions,
|
|
168
|
+
ContextDev::Internal::AnyHash
|
|
169
|
+
)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Scrape each result to Markdown. Off by default to keep search cheap and fast.
|
|
173
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
174
|
+
attr_reader :enabled
|
|
175
|
+
|
|
176
|
+
sig { params(enabled: T::Boolean).void }
|
|
177
|
+
attr_writer :enabled
|
|
178
|
+
|
|
179
|
+
# Render iframe contents into the Markdown.
|
|
180
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
181
|
+
attr_reader :include_frames
|
|
182
|
+
|
|
183
|
+
sig { params(include_frames: T::Boolean).void }
|
|
184
|
+
attr_writer :include_frames
|
|
185
|
+
|
|
186
|
+
# Emit image references in the Markdown.
|
|
187
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
188
|
+
attr_reader :include_images
|
|
189
|
+
|
|
190
|
+
sig { params(include_images: T::Boolean).void }
|
|
191
|
+
attr_writer :include_images
|
|
192
|
+
|
|
193
|
+
# Keep hyperlinks in the Markdown.
|
|
194
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
195
|
+
attr_reader :include_links
|
|
196
|
+
|
|
197
|
+
sig { params(include_links: T::Boolean).void }
|
|
198
|
+
attr_writer :include_links
|
|
199
|
+
|
|
200
|
+
# Cache TTL in ms for scraped Markdown keyed by URL + options. Default 1 day, max
|
|
201
|
+
# 30 days. Set to 0 to force a fresh scrape.
|
|
202
|
+
sig { returns(T.nilable(Integer)) }
|
|
203
|
+
attr_reader :max_age_ms
|
|
204
|
+
|
|
205
|
+
sig { params(max_age_ms: Integer).void }
|
|
206
|
+
attr_writer :max_age_ms
|
|
207
|
+
|
|
208
|
+
# PDF handling. Use start/end to bound text extraction and OCR to a page range.
|
|
209
|
+
sig do
|
|
210
|
+
returns(T.nilable(ContextDev::WebSearchParams::MarkdownOptions::Pdf))
|
|
211
|
+
end
|
|
212
|
+
attr_reader :pdf
|
|
213
|
+
|
|
214
|
+
sig do
|
|
215
|
+
params(
|
|
216
|
+
pdf: ContextDev::WebSearchParams::MarkdownOptions::Pdf::OrHash
|
|
217
|
+
).void
|
|
218
|
+
end
|
|
219
|
+
attr_writer :pdf
|
|
220
|
+
|
|
221
|
+
# Truncate inline base64 image payloads to keep responses small.
|
|
222
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
223
|
+
attr_reader :shorten_base64_images
|
|
224
|
+
|
|
225
|
+
sig { params(shorten_base64_images: T::Boolean).void }
|
|
226
|
+
attr_writer :shorten_base64_images
|
|
227
|
+
|
|
228
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
229
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
230
|
+
# value is 300000ms (5 minutes).
|
|
231
|
+
sig { returns(T.nilable(Integer)) }
|
|
232
|
+
attr_reader :timeout_ms
|
|
233
|
+
|
|
234
|
+
sig { params(timeout_ms: Integer).void }
|
|
235
|
+
attr_writer :timeout_ms
|
|
236
|
+
|
|
237
|
+
# Strip nav, header, footer, and sidebar — keep only the primary article content.
|
|
238
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
239
|
+
attr_reader :use_main_content_only
|
|
240
|
+
|
|
241
|
+
sig { params(use_main_content_only: T::Boolean).void }
|
|
242
|
+
attr_writer :use_main_content_only
|
|
243
|
+
|
|
244
|
+
# Extra wait after page load before rendering, in ms (0–30000). Useful for
|
|
245
|
+
# JS-heavy pages.
|
|
246
|
+
sig { returns(T.nilable(Integer)) }
|
|
247
|
+
attr_reader :wait_for_ms
|
|
248
|
+
|
|
249
|
+
sig { params(wait_for_ms: Integer).void }
|
|
250
|
+
attr_writer :wait_for_ms
|
|
251
|
+
|
|
252
|
+
# Inline Markdown scraping for each result. Set `enabled: true` to activate.
|
|
253
|
+
sig do
|
|
254
|
+
params(
|
|
255
|
+
enabled: T::Boolean,
|
|
256
|
+
include_frames: T::Boolean,
|
|
257
|
+
include_images: T::Boolean,
|
|
258
|
+
include_links: T::Boolean,
|
|
259
|
+
max_age_ms: Integer,
|
|
260
|
+
pdf: ContextDev::WebSearchParams::MarkdownOptions::Pdf::OrHash,
|
|
261
|
+
shorten_base64_images: T::Boolean,
|
|
262
|
+
timeout_ms: Integer,
|
|
263
|
+
use_main_content_only: T::Boolean,
|
|
264
|
+
wait_for_ms: Integer
|
|
265
|
+
).returns(T.attached_class)
|
|
266
|
+
end
|
|
267
|
+
def self.new(
|
|
268
|
+
# Scrape each result to Markdown. Off by default to keep search cheap and fast.
|
|
269
|
+
enabled: nil,
|
|
270
|
+
# Render iframe contents into the Markdown.
|
|
271
|
+
include_frames: nil,
|
|
272
|
+
# Emit image references in the Markdown.
|
|
273
|
+
include_images: nil,
|
|
274
|
+
# Keep hyperlinks in the Markdown.
|
|
275
|
+
include_links: nil,
|
|
276
|
+
# Cache TTL in ms for scraped Markdown keyed by URL + options. Default 1 day, max
|
|
277
|
+
# 30 days. Set to 0 to force a fresh scrape.
|
|
278
|
+
max_age_ms: nil,
|
|
279
|
+
# PDF handling. Use start/end to bound text extraction and OCR to a page range.
|
|
280
|
+
pdf: nil,
|
|
281
|
+
# Truncate inline base64 image payloads to keep responses small.
|
|
282
|
+
shorten_base64_images: nil,
|
|
283
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
284
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
285
|
+
# value is 300000ms (5 minutes).
|
|
286
|
+
timeout_ms: nil,
|
|
287
|
+
# Strip nav, header, footer, and sidebar — keep only the primary article content.
|
|
288
|
+
use_main_content_only: nil,
|
|
289
|
+
# Extra wait after page load before rendering, in ms (0–30000). Useful for
|
|
290
|
+
# JS-heavy pages.
|
|
291
|
+
wait_for_ms: nil
|
|
292
|
+
)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
sig do
|
|
296
|
+
override.returns(
|
|
297
|
+
{
|
|
298
|
+
enabled: T::Boolean,
|
|
299
|
+
include_frames: T::Boolean,
|
|
300
|
+
include_images: T::Boolean,
|
|
301
|
+
include_links: T::Boolean,
|
|
302
|
+
max_age_ms: Integer,
|
|
303
|
+
pdf: ContextDev::WebSearchParams::MarkdownOptions::Pdf,
|
|
304
|
+
shorten_base64_images: T::Boolean,
|
|
305
|
+
timeout_ms: Integer,
|
|
306
|
+
use_main_content_only: T::Boolean,
|
|
307
|
+
wait_for_ms: Integer
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
end
|
|
311
|
+
def to_hash
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
class Pdf < ContextDev::Internal::Type::BaseModel
|
|
315
|
+
OrHash =
|
|
316
|
+
T.type_alias do
|
|
317
|
+
T.any(
|
|
318
|
+
ContextDev::WebSearchParams::MarkdownOptions::Pdf,
|
|
319
|
+
ContextDev::Internal::AnyHash
|
|
320
|
+
)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Last PDF page to parse (1-based, inclusive). Defaults to the final page. Must
|
|
324
|
+
# be >= start.
|
|
325
|
+
sig { returns(T.nilable(Integer)) }
|
|
326
|
+
attr_reader :end_
|
|
327
|
+
|
|
328
|
+
sig { params(end_: Integer).void }
|
|
329
|
+
attr_writer :end_
|
|
330
|
+
|
|
331
|
+
# Parse PDF URLs. When false, PDF results are skipped with WEBSITE_ACCESS_ERROR.
|
|
332
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
333
|
+
attr_reader :should_parse
|
|
334
|
+
|
|
335
|
+
sig { params(should_parse: T::Boolean).void }
|
|
336
|
+
attr_writer :should_parse
|
|
337
|
+
|
|
338
|
+
# First PDF page to parse (1-based, inclusive). Defaults to page 1.
|
|
339
|
+
sig { returns(T.nilable(Integer)) }
|
|
340
|
+
attr_reader :start
|
|
341
|
+
|
|
342
|
+
sig { params(start: Integer).void }
|
|
343
|
+
attr_writer :start
|
|
344
|
+
|
|
345
|
+
# PDF handling. Use start/end to bound text extraction and OCR to a page range.
|
|
346
|
+
sig do
|
|
347
|
+
params(
|
|
348
|
+
end_: Integer,
|
|
349
|
+
should_parse: T::Boolean,
|
|
350
|
+
start: Integer
|
|
351
|
+
).returns(T.attached_class)
|
|
352
|
+
end
|
|
353
|
+
def self.new(
|
|
354
|
+
# Last PDF page to parse (1-based, inclusive). Defaults to the final page. Must
|
|
355
|
+
# be >= start.
|
|
356
|
+
end_: nil,
|
|
357
|
+
# Parse PDF URLs. When false, PDF results are skipped with WEBSITE_ACCESS_ERROR.
|
|
358
|
+
should_parse: nil,
|
|
359
|
+
# First PDF page to parse (1-based, inclusive). Defaults to page 1.
|
|
360
|
+
start: nil
|
|
361
|
+
)
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
sig do
|
|
365
|
+
override.returns(
|
|
366
|
+
{ end_: Integer, should_parse: T::Boolean, start: Integer }
|
|
367
|
+
)
|
|
368
|
+
end
|
|
369
|
+
def to_hash
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module ContextDev
|
|
4
|
+
module Models
|
|
5
|
+
class WebSearchResponse < ContextDev::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias do
|
|
8
|
+
T.any(
|
|
9
|
+
ContextDev::Models::WebSearchResponse,
|
|
10
|
+
ContextDev::Internal::AnyHash
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Echo of the original query (useful when fanout was enabled).
|
|
15
|
+
sig { returns(String) }
|
|
16
|
+
attr_accessor :query
|
|
17
|
+
|
|
18
|
+
sig { returns(T::Array[ContextDev::Models::WebSearchResponse::Result]) }
|
|
19
|
+
attr_accessor :results
|
|
20
|
+
|
|
21
|
+
sig do
|
|
22
|
+
params(
|
|
23
|
+
query: String,
|
|
24
|
+
results:
|
|
25
|
+
T::Array[ContextDev::Models::WebSearchResponse::Result::OrHash]
|
|
26
|
+
).returns(T.attached_class)
|
|
27
|
+
end
|
|
28
|
+
def self.new(
|
|
29
|
+
# Echo of the original query (useful when fanout was enabled).
|
|
30
|
+
query:,
|
|
31
|
+
results:
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
sig do
|
|
36
|
+
override.returns(
|
|
37
|
+
{
|
|
38
|
+
query: String,
|
|
39
|
+
results: T::Array[ContextDev::Models::WebSearchResponse::Result]
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
def to_hash
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class Result < ContextDev::Internal::Type::BaseModel
|
|
47
|
+
OrHash =
|
|
48
|
+
T.type_alias do
|
|
49
|
+
T.any(
|
|
50
|
+
ContextDev::Models::WebSearchResponse::Result,
|
|
51
|
+
ContextDev::Internal::AnyHash
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Snippet excerpt from the page.
|
|
56
|
+
sig { returns(String) }
|
|
57
|
+
attr_accessor :description
|
|
58
|
+
|
|
59
|
+
# Markdown scrape status and content for this result.
|
|
60
|
+
sig { returns(ContextDev::Models::WebSearchResponse::Result::Markdown) }
|
|
61
|
+
attr_reader :markdown
|
|
62
|
+
|
|
63
|
+
sig do
|
|
64
|
+
params(
|
|
65
|
+
markdown:
|
|
66
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::OrHash
|
|
67
|
+
).void
|
|
68
|
+
end
|
|
69
|
+
attr_writer :markdown
|
|
70
|
+
|
|
71
|
+
# Model-judged relevance to the original query.
|
|
72
|
+
sig do
|
|
73
|
+
returns(
|
|
74
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
attr_accessor :relevance
|
|
78
|
+
|
|
79
|
+
# Page title.
|
|
80
|
+
sig { returns(String) }
|
|
81
|
+
attr_accessor :title
|
|
82
|
+
|
|
83
|
+
# Canonical result URL.
|
|
84
|
+
sig { returns(String) }
|
|
85
|
+
attr_accessor :url
|
|
86
|
+
|
|
87
|
+
sig do
|
|
88
|
+
params(
|
|
89
|
+
description: String,
|
|
90
|
+
markdown:
|
|
91
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::OrHash,
|
|
92
|
+
relevance:
|
|
93
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::OrSymbol,
|
|
94
|
+
title: String,
|
|
95
|
+
url: String
|
|
96
|
+
).returns(T.attached_class)
|
|
97
|
+
end
|
|
98
|
+
def self.new(
|
|
99
|
+
# Snippet excerpt from the page.
|
|
100
|
+
description:,
|
|
101
|
+
# Markdown scrape status and content for this result.
|
|
102
|
+
markdown:,
|
|
103
|
+
# Model-judged relevance to the original query.
|
|
104
|
+
relevance:,
|
|
105
|
+
# Page title.
|
|
106
|
+
title:,
|
|
107
|
+
# Canonical result URL.
|
|
108
|
+
url:
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
sig do
|
|
113
|
+
override.returns(
|
|
114
|
+
{
|
|
115
|
+
description: String,
|
|
116
|
+
markdown: ContextDev::Models::WebSearchResponse::Result::Markdown,
|
|
117
|
+
relevance:
|
|
118
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol,
|
|
119
|
+
title: String,
|
|
120
|
+
url: String
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
def to_hash
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class Markdown < ContextDev::Internal::Type::BaseModel
|
|
128
|
+
OrHash =
|
|
129
|
+
T.type_alias do
|
|
130
|
+
T.any(
|
|
131
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown,
|
|
132
|
+
ContextDev::Internal::AnyHash
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Per-result scrape outcome. Inspect this before reading `markdown`.
|
|
137
|
+
sig do
|
|
138
|
+
returns(
|
|
139
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
140
|
+
)
|
|
141
|
+
end
|
|
142
|
+
attr_accessor :code
|
|
143
|
+
|
|
144
|
+
# GFM Markdown of the page. Null unless markdownOptions.enabled is true and
|
|
145
|
+
# scraping succeeded.
|
|
146
|
+
sig { returns(T.nilable(String)) }
|
|
147
|
+
attr_accessor :markdown
|
|
148
|
+
|
|
149
|
+
# Markdown scrape status and content for this result.
|
|
150
|
+
sig do
|
|
151
|
+
params(
|
|
152
|
+
code:
|
|
153
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::OrSymbol,
|
|
154
|
+
markdown: T.nilable(String)
|
|
155
|
+
).returns(T.attached_class)
|
|
156
|
+
end
|
|
157
|
+
def self.new(
|
|
158
|
+
# Per-result scrape outcome. Inspect this before reading `markdown`.
|
|
159
|
+
code:,
|
|
160
|
+
# GFM Markdown of the page. Null unless markdownOptions.enabled is true and
|
|
161
|
+
# scraping succeeded.
|
|
162
|
+
markdown:
|
|
163
|
+
)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
sig do
|
|
167
|
+
override.returns(
|
|
168
|
+
{
|
|
169
|
+
code:
|
|
170
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol,
|
|
171
|
+
markdown: T.nilable(String)
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
end
|
|
175
|
+
def to_hash
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Per-result scrape outcome. Inspect this before reading `markdown`.
|
|
179
|
+
module Code
|
|
180
|
+
extend ContextDev::Internal::Type::Enum
|
|
181
|
+
|
|
182
|
+
TaggedSymbol =
|
|
183
|
+
T.type_alias do
|
|
184
|
+
T.all(
|
|
185
|
+
Symbol,
|
|
186
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code
|
|
187
|
+
)
|
|
188
|
+
end
|
|
189
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
190
|
+
|
|
191
|
+
SUCCESS =
|
|
192
|
+
T.let(
|
|
193
|
+
:SUCCESS,
|
|
194
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
195
|
+
)
|
|
196
|
+
NOT_REQUESTED =
|
|
197
|
+
T.let(
|
|
198
|
+
:NOT_REQUESTED,
|
|
199
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
200
|
+
)
|
|
201
|
+
TIMEOUT =
|
|
202
|
+
T.let(
|
|
203
|
+
:TIMEOUT,
|
|
204
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
205
|
+
)
|
|
206
|
+
WEBSITE_ACCESS_ERROR =
|
|
207
|
+
T.let(
|
|
208
|
+
:WEBSITE_ACCESS_ERROR,
|
|
209
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
210
|
+
)
|
|
211
|
+
ERROR =
|
|
212
|
+
T.let(
|
|
213
|
+
:ERROR,
|
|
214
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
sig do
|
|
218
|
+
override.returns(
|
|
219
|
+
T::Array[
|
|
220
|
+
ContextDev::Models::WebSearchResponse::Result::Markdown::Code::TaggedSymbol
|
|
221
|
+
]
|
|
222
|
+
)
|
|
223
|
+
end
|
|
224
|
+
def self.values
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Model-judged relevance to the original query.
|
|
230
|
+
module Relevance
|
|
231
|
+
extend ContextDev::Internal::Type::Enum
|
|
232
|
+
|
|
233
|
+
TaggedSymbol =
|
|
234
|
+
T.type_alias do
|
|
235
|
+
T.all(
|
|
236
|
+
Symbol,
|
|
237
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance
|
|
238
|
+
)
|
|
239
|
+
end
|
|
240
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
241
|
+
|
|
242
|
+
HIGH =
|
|
243
|
+
T.let(
|
|
244
|
+
:high,
|
|
245
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol
|
|
246
|
+
)
|
|
247
|
+
MEDIUM =
|
|
248
|
+
T.let(
|
|
249
|
+
:medium,
|
|
250
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol
|
|
251
|
+
)
|
|
252
|
+
LOW =
|
|
253
|
+
T.let(
|
|
254
|
+
:low,
|
|
255
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
sig do
|
|
259
|
+
override.returns(
|
|
260
|
+
T::Array[
|
|
261
|
+
ContextDev::Models::WebSearchResponse::Result::Relevance::TaggedSymbol
|
|
262
|
+
]
|
|
263
|
+
)
|
|
264
|
+
end
|
|
265
|
+
def self.values
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
data/rbi/context_dev/models.rbi
CHANGED
|
@@ -38,6 +38,8 @@ module ContextDev
|
|
|
38
38
|
|
|
39
39
|
WebScreenshotParams = ContextDev::Models::WebScreenshotParams
|
|
40
40
|
|
|
41
|
+
WebSearchParams = ContextDev::Models::WebSearchParams
|
|
42
|
+
|
|
41
43
|
WebWebCrawlMdParams = ContextDev::Models::WebWebCrawlMdParams
|
|
42
44
|
|
|
43
45
|
WebWebScrapeHTMLParams = ContextDev::Models::WebWebScrapeHTMLParams
|
|
@@ -116,6 +116,43 @@ module ContextDev
|
|
|
116
116
|
)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
+
# Search the web and optionally scrape each result to Markdown in one round-trip.
|
|
120
|
+
sig do
|
|
121
|
+
params(
|
|
122
|
+
query: String,
|
|
123
|
+
exclude_domains: T::Array[String],
|
|
124
|
+
freshness: ContextDev::WebSearchParams::Freshness::OrSymbol,
|
|
125
|
+
include_domains: T::Array[String],
|
|
126
|
+
markdown_options:
|
|
127
|
+
ContextDev::WebSearchParams::MarkdownOptions::OrHash,
|
|
128
|
+
query_fanout: T::Boolean,
|
|
129
|
+
timeout_ms: Integer,
|
|
130
|
+
request_options: ContextDev::RequestOptions::OrHash
|
|
131
|
+
).returns(ContextDev::Models::WebSearchResponse)
|
|
132
|
+
end
|
|
133
|
+
def search(
|
|
134
|
+
# Natural-language search query.
|
|
135
|
+
query:,
|
|
136
|
+
# Blocklist — drop results from these domains. Example: ["pinterest.com",
|
|
137
|
+
# "reddit.com"].
|
|
138
|
+
exclude_domains: nil,
|
|
139
|
+
# Restrict results to content published within this window.
|
|
140
|
+
freshness: nil,
|
|
141
|
+
# Allowlist — only return results from these domains. Example: ["arxiv.org",
|
|
142
|
+
# "github.com"].
|
|
143
|
+
include_domains: nil,
|
|
144
|
+
# Inline Markdown scraping for each result. Set `enabled: true` to activate.
|
|
145
|
+
markdown_options: nil,
|
|
146
|
+
# Expand the query into multiple parallel variants for broader recall.
|
|
147
|
+
query_fanout: nil,
|
|
148
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
149
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
150
|
+
# value is 300000ms (5 minutes).
|
|
151
|
+
timeout_ms: nil,
|
|
152
|
+
request_options: {}
|
|
153
|
+
)
|
|
154
|
+
end
|
|
155
|
+
|
|
119
156
|
# Performs a crawl starting from a given URL, extracts page content as Markdown,
|
|
120
157
|
# and returns results for all crawled pages.
|
|
121
158
|
sig do
|