parallel-web 0.3.1 → 0.4.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.
- package/CHANGELOG.md +76 -0
- package/README.md +2 -2
- package/client.d.mts +46 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +46 -3
- package/client.d.ts.map +1 -1
- package/client.js +66 -19
- package/client.js.map +1 -1
- package/client.mjs +66 -19
- package/client.mjs.map +1 -1
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/utils/env.js +2 -2
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +2 -2
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/query.d.mts +5 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +5 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +23 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +20 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +12 -1
- package/resources/beta/beta.d.mts +52 -72
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +52 -72
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +10 -4
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +10 -4
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/findall.d.mts +171 -9
- package/resources/beta/findall.d.mts.map +1 -1
- package/resources/beta/findall.d.ts +171 -9
- package/resources/beta/findall.d.ts.map +1 -1
- package/resources/beta/findall.js +111 -0
- package/resources/beta/findall.js.map +1 -1
- package/resources/beta/findall.mjs +111 -0
- package/resources/beta/findall.mjs.map +1 -1
- package/resources/beta/index.d.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/task-group.d.mts +60 -4
- package/resources/beta/task-group.d.mts.map +1 -1
- package/resources/beta/task-group.d.ts +60 -4
- package/resources/beta/task-group.d.ts.map +1 -1
- package/resources/beta/task-group.js +52 -1
- package/resources/beta/task-group.js.map +1 -1
- package/resources/beta/task-group.mjs +52 -1
- package/resources/beta/task-group.mjs.map +1 -1
- package/resources/beta/task-run.d.mts +85 -266
- package/resources/beta/task-run.d.mts.map +1 -1
- package/resources/beta/task-run.d.ts +85 -266
- package/resources/beta/task-run.d.ts.map +1 -1
- package/resources/beta/task-run.js +21 -2
- package/resources/beta/task-run.js.map +1 -1
- package/resources/beta/task-run.mjs +21 -2
- package/resources/beta/task-run.mjs.map +1 -1
- package/resources/index.d.mts +2 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/shared.d.mts +4 -2
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +4 -2
- package/resources/shared.d.ts.map +1 -1
- package/resources/task-run.d.mts +324 -29
- package/resources/task-run.d.mts.map +1 -1
- package/resources/task-run.d.ts +324 -29
- package/resources/task-run.d.ts.map +1 -1
- package/resources/task-run.js +71 -4
- package/resources/task-run.js.map +1 -1
- package/resources/task-run.mjs +71 -4
- package/resources/task-run.mjs.map +1 -1
- package/resources/top-level.d.mts +317 -0
- package/resources/top-level.d.mts.map +1 -0
- package/resources/top-level.d.ts +317 -0
- package/resources/top-level.d.ts.map +1 -0
- package/resources/top-level.js +4 -0
- package/resources/top-level.js.map +1 -0
- package/resources/top-level.mjs +3 -0
- package/resources/top-level.mjs.map +1 -0
- package/src/client.ts +118 -24
- package/src/core/streaming.ts +2 -2
- package/src/internal/parse.ts +6 -0
- package/src/internal/utils/env.ts +2 -2
- package/src/internal/utils/query.ts +23 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/beta/api.md +87 -0
- package/src/resources/beta/beta.ts +67 -84
- package/src/resources/beta/findall.ts +191 -7
- package/src/resources/beta/index.ts +7 -4
- package/src/resources/beta/task-group.ts +64 -6
- package/src/resources/beta/task-run.ts +103 -300
- package/src/resources/index.ts +20 -0
- package/src/resources/shared.ts +4 -2
- package/src/resources/task-run.ts +410 -31
- package/src/resources/top-level.ts +385 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import * as Shared from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Advanced extract configuration.
|
|
4
|
+
*
|
|
5
|
+
* These settings may impact result quality and latency unless used carefully. See
|
|
6
|
+
* https://docs.parallel.ai/search/advanced-extract-settings for more info.
|
|
7
|
+
*/
|
|
8
|
+
export interface AdvancedExtractSettings {
|
|
9
|
+
/**
|
|
10
|
+
* Optional settings for returning relevant excerpts.
|
|
11
|
+
*/
|
|
12
|
+
excerpt_settings?: ExcerptSettings | null;
|
|
13
|
+
/**
|
|
14
|
+
* Policy for live fetching web results.
|
|
15
|
+
*/
|
|
16
|
+
fetch_policy?: FetchPolicy | null;
|
|
17
|
+
/**
|
|
18
|
+
* Controls full content extraction. Set to true to enable with defaults, false to
|
|
19
|
+
* disable, or provide FullContentSettings for fine-grained control.
|
|
20
|
+
*/
|
|
21
|
+
full_content?: AdvancedExtractSettings.FullContentSettings | boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace AdvancedExtractSettings {
|
|
24
|
+
/**
|
|
25
|
+
* Optional settings for returning full content.
|
|
26
|
+
*/
|
|
27
|
+
interface FullContentSettings {
|
|
28
|
+
/**
|
|
29
|
+
* Optional limit on the number of characters to include in the full content for
|
|
30
|
+
* each url. Full content always starts at the beginning of the page and is
|
|
31
|
+
* truncated at the limit if necessary.
|
|
32
|
+
*/
|
|
33
|
+
max_chars_per_result?: number | null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Advanced search configuration.
|
|
38
|
+
*
|
|
39
|
+
* These settings may impact result quality and latency unless used carefully. See
|
|
40
|
+
* https://docs.parallel.ai/search/advanced-search-settings for more info.
|
|
41
|
+
*/
|
|
42
|
+
export interface AdvancedSearchSettings {
|
|
43
|
+
/**
|
|
44
|
+
* Optional settings for returning relevant excerpts.
|
|
45
|
+
*/
|
|
46
|
+
excerpt_settings?: ExcerptSettings | null;
|
|
47
|
+
/**
|
|
48
|
+
* Policy for live fetching web results.
|
|
49
|
+
*/
|
|
50
|
+
fetch_policy?: FetchPolicy | null;
|
|
51
|
+
/**
|
|
52
|
+
* ISO 3166-1 alpha-2 country code for geo-targeted search results.
|
|
53
|
+
*/
|
|
54
|
+
location?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Upper bound on the number of results to return. Defaults to 10 if not provided.
|
|
57
|
+
*/
|
|
58
|
+
max_results?: number | null;
|
|
59
|
+
/**
|
|
60
|
+
* Source policy for web search results.
|
|
61
|
+
*
|
|
62
|
+
* This policy governs which sources are allowed/disallowed in results.
|
|
63
|
+
*/
|
|
64
|
+
source_policy?: Shared.SourcePolicy | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Optional settings for returning relevant excerpts.
|
|
68
|
+
*/
|
|
69
|
+
export interface ExcerptSettings {
|
|
70
|
+
/**
|
|
71
|
+
* Optional upper bound on the total number of characters to include per url.
|
|
72
|
+
* Excerpts may contain fewer characters than this limit to maximize relevance and
|
|
73
|
+
* token efficiency. Values below 1000 will be automatically set to 1000.
|
|
74
|
+
*/
|
|
75
|
+
max_chars_per_result?: number | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract error details.
|
|
79
|
+
*/
|
|
80
|
+
export interface ExtractError {
|
|
81
|
+
/**
|
|
82
|
+
* Content returned for http client or server errors, if any.
|
|
83
|
+
*/
|
|
84
|
+
content: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Error type.
|
|
87
|
+
*/
|
|
88
|
+
error_type: string;
|
|
89
|
+
/**
|
|
90
|
+
* HTTP status code, if available.
|
|
91
|
+
*/
|
|
92
|
+
http_status_code: number | null;
|
|
93
|
+
url: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Extract response.
|
|
97
|
+
*/
|
|
98
|
+
export interface ExtractResponse {
|
|
99
|
+
/**
|
|
100
|
+
* Extract errors: requested URLs not in the results.
|
|
101
|
+
*/
|
|
102
|
+
errors: Array<ExtractError>;
|
|
103
|
+
/**
|
|
104
|
+
* Extract request ID, e.g. `extract_cad0a6d2dec046bd95ae900527d880e7`
|
|
105
|
+
*/
|
|
106
|
+
extract_id: string;
|
|
107
|
+
/**
|
|
108
|
+
* Successful extract results.
|
|
109
|
+
*/
|
|
110
|
+
results: Array<ExtractResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Session identifier. Echoed back from the request if provided, otherwise
|
|
113
|
+
* generated by the server. Should be passed to future search and extract calls
|
|
114
|
+
* made by the agent as part of the same larger task.
|
|
115
|
+
*/
|
|
116
|
+
session_id: string;
|
|
117
|
+
/**
|
|
118
|
+
* Usage metrics for the extract request.
|
|
119
|
+
*/
|
|
120
|
+
usage?: Array<UsageItem> | null;
|
|
121
|
+
/**
|
|
122
|
+
* Warnings for the extract request, if any.
|
|
123
|
+
*/
|
|
124
|
+
warnings?: Array<Shared.Warning> | null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Extract result for a single URL.
|
|
128
|
+
*/
|
|
129
|
+
export interface ExtractResult {
|
|
130
|
+
/**
|
|
131
|
+
* Relevant excerpted content from the URL, formatted as markdown.
|
|
132
|
+
*/
|
|
133
|
+
excerpts: Array<string>;
|
|
134
|
+
/**
|
|
135
|
+
* URL associated with the search result.
|
|
136
|
+
*/
|
|
137
|
+
url: string;
|
|
138
|
+
/**
|
|
139
|
+
* Full content from the URL formatted as markdown, if requested.
|
|
140
|
+
*/
|
|
141
|
+
full_content?: string | null;
|
|
142
|
+
/**
|
|
143
|
+
* Publish date of the webpage in YYYY-MM-DD format, if available.
|
|
144
|
+
*/
|
|
145
|
+
publish_date?: string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Title of the webpage, if available.
|
|
148
|
+
*/
|
|
149
|
+
title?: string | null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Policy for live fetching web results.
|
|
153
|
+
*/
|
|
154
|
+
export interface FetchPolicy {
|
|
155
|
+
/**
|
|
156
|
+
* If false, fallback to cached content older than max-age if live fetch fails or
|
|
157
|
+
* times out. If true, returns an error instead.
|
|
158
|
+
*/
|
|
159
|
+
disable_cache_fallback?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Maximum age of cached content in seconds to trigger a live fetch. Minimum value
|
|
162
|
+
* 600 seconds (10 minutes).
|
|
163
|
+
*/
|
|
164
|
+
max_age_seconds?: number | null;
|
|
165
|
+
/**
|
|
166
|
+
* Timeout in seconds for fetching live content if unavailable in cache.
|
|
167
|
+
*/
|
|
168
|
+
timeout_seconds?: number | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Search response.
|
|
172
|
+
*/
|
|
173
|
+
export interface SearchResult {
|
|
174
|
+
/**
|
|
175
|
+
* A list of search results, ordered by decreasing relevance.
|
|
176
|
+
*/
|
|
177
|
+
results: Array<WebSearchResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Search ID. Example: `search_cad0a6d2dec046bd95ae900527d880e7`
|
|
180
|
+
*/
|
|
181
|
+
search_id: string;
|
|
182
|
+
/**
|
|
183
|
+
* Session identifier, echoed back from the request if provided, otherwise
|
|
184
|
+
* generated by the server. Should be passed to future search and extract calls
|
|
185
|
+
* made by the agent as part of the same larger task.
|
|
186
|
+
*/
|
|
187
|
+
session_id: string;
|
|
188
|
+
/**
|
|
189
|
+
* Usage metrics for the search request.
|
|
190
|
+
*/
|
|
191
|
+
usage?: Array<UsageItem> | null;
|
|
192
|
+
/**
|
|
193
|
+
* Warnings for the search request, if any.
|
|
194
|
+
*/
|
|
195
|
+
warnings?: Array<Shared.Warning> | null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Usage item for a single operation.
|
|
199
|
+
*/
|
|
200
|
+
export interface UsageItem {
|
|
201
|
+
/**
|
|
202
|
+
* Count of the SKU.
|
|
203
|
+
*/
|
|
204
|
+
count: number;
|
|
205
|
+
/**
|
|
206
|
+
* Name of the SKU.
|
|
207
|
+
*/
|
|
208
|
+
name: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A single search result from the web search API.
|
|
212
|
+
*/
|
|
213
|
+
export interface WebSearchResult {
|
|
214
|
+
/**
|
|
215
|
+
* Relevant excerpted content from the URL, formatted as markdown.
|
|
216
|
+
*/
|
|
217
|
+
excerpts: Array<string>;
|
|
218
|
+
/**
|
|
219
|
+
* URL associated with the search result.
|
|
220
|
+
*/
|
|
221
|
+
url: string;
|
|
222
|
+
/**
|
|
223
|
+
* Publish date of the webpage in YYYY-MM-DD format, if available.
|
|
224
|
+
*/
|
|
225
|
+
publish_date?: string | null;
|
|
226
|
+
/**
|
|
227
|
+
* Title of the webpage, if available.
|
|
228
|
+
*/
|
|
229
|
+
title?: string | null;
|
|
230
|
+
}
|
|
231
|
+
export interface ExtractParams {
|
|
232
|
+
/**
|
|
233
|
+
* URLs to extract content from. Up to 20 URLs.
|
|
234
|
+
*/
|
|
235
|
+
urls: Array<string>;
|
|
236
|
+
/**
|
|
237
|
+
* Advanced extract configuration.
|
|
238
|
+
*
|
|
239
|
+
* These settings may impact result quality and latency unless used carefully. See
|
|
240
|
+
* https://docs.parallel.ai/search/advanced-extract-settings for more info.
|
|
241
|
+
*/
|
|
242
|
+
advanced_settings?: AdvancedExtractSettings | null;
|
|
243
|
+
/**
|
|
244
|
+
* The model generating this request and consuming the results. Enables
|
|
245
|
+
* optimizations and tailors default settings for the model's capabilities.
|
|
246
|
+
*/
|
|
247
|
+
client_model?: string | null;
|
|
248
|
+
/**
|
|
249
|
+
* Upper bound on total characters across excerpts from all extracted results.
|
|
250
|
+
*/
|
|
251
|
+
max_chars_total?: number | null;
|
|
252
|
+
/**
|
|
253
|
+
* As in SearchRequest, a natural-language description of the underlying question
|
|
254
|
+
* or goal driving the request. Used together with search_queries to focus excerpts
|
|
255
|
+
* on the most relevant content.
|
|
256
|
+
*/
|
|
257
|
+
objective?: string | null;
|
|
258
|
+
/**
|
|
259
|
+
* Optional keyword search queries, as in SearchRequest. Used together with
|
|
260
|
+
* objective to focus excerpts on the most relevant content.
|
|
261
|
+
*/
|
|
262
|
+
search_queries?: Array<string> | null;
|
|
263
|
+
/**
|
|
264
|
+
* Session identifier to track calls across separate search and extract calls, to
|
|
265
|
+
* be used as part of a larger task. Specifying it may give better contextual
|
|
266
|
+
* results for subsequent API calls.
|
|
267
|
+
*/
|
|
268
|
+
session_id?: string | null;
|
|
269
|
+
}
|
|
270
|
+
export interface SearchParams {
|
|
271
|
+
/**
|
|
272
|
+
* Concise keyword search queries, 3-6 words each. At least one query is required,
|
|
273
|
+
* provide 2-3 for best results. Used together with objective to focus results on
|
|
274
|
+
* the most relevant content.
|
|
275
|
+
*/
|
|
276
|
+
search_queries: Array<string>;
|
|
277
|
+
/**
|
|
278
|
+
* Advanced search configuration.
|
|
279
|
+
*
|
|
280
|
+
* These settings may impact result quality and latency unless used carefully. See
|
|
281
|
+
* https://docs.parallel.ai/search/advanced-search-settings for more info.
|
|
282
|
+
*/
|
|
283
|
+
advanced_settings?: AdvancedSearchSettings | null;
|
|
284
|
+
/**
|
|
285
|
+
* The model generating this request and consuming the results. Enables
|
|
286
|
+
* optimizations and tailors default settings for the model's capabilities.
|
|
287
|
+
*/
|
|
288
|
+
client_model?: string | null;
|
|
289
|
+
/**
|
|
290
|
+
* Upper bound on total characters across excerpts from all results.
|
|
291
|
+
*/
|
|
292
|
+
max_chars_total?: number | null;
|
|
293
|
+
/**
|
|
294
|
+
* Search mode preset: supported values are `basic` and `advanced`. Basic mode
|
|
295
|
+
* offers the lowest latency and works best with 2-3 high-quality search_queries.
|
|
296
|
+
* Advanced mode provides higher quality with more advanced retrieval and
|
|
297
|
+
* compression. Defaults to `advanced` when omitted.
|
|
298
|
+
*/
|
|
299
|
+
mode?: 'basic' | 'advanced' | null;
|
|
300
|
+
/**
|
|
301
|
+
* Natural-language description of the underlying question or goal driving the
|
|
302
|
+
* search. Used together with search_queries to focus results on the most relevant
|
|
303
|
+
* content. Should be self-contained with enough context to understand the intent
|
|
304
|
+
* of the search.
|
|
305
|
+
*/
|
|
306
|
+
objective?: string | null;
|
|
307
|
+
/**
|
|
308
|
+
* Session identifier to track calls across separate search and extract calls, to
|
|
309
|
+
* be used as part of a larger task. Specifying it may give better contextual
|
|
310
|
+
* results for subsequent API calls.
|
|
311
|
+
*/
|
|
312
|
+
session_id?: string | null;
|
|
313
|
+
}
|
|
314
|
+
export declare namespace TopLevel {
|
|
315
|
+
export { type AdvancedExtractSettings as AdvancedExtractSettings, type AdvancedSearchSettings as AdvancedSearchSettings, type ExcerptSettings as ExcerptSettings, type ExtractError as ExtractError, type ExtractResponse as ExtractResponse, type ExtractResult as ExtractResult, type FetchPolicy as FetchPolicy, type SearchResult as SearchResult, type UsageItem as UsageItem, type WebSearchResult as WebSearchResult, type ExtractParams as ExtractParams, type SearchParams as SearchParams, };
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=top-level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-level.d.ts","sourceRoot":"","sources":["../src/resources/top-level.ts"],"names":[],"mappings":"OAEO,KAAK,MAAM;A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CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,YAAY,IAAI,YAAY,GAClC,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-level.js","sourceRoot":"","sources":["../src/resources/top-level.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-level.mjs","sourceRoot":"","sources":["../src/resources/top-level.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
package/src/client.ts
CHANGED
|
@@ -11,25 +11,47 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
14
15
|
import { VERSION } from './version';
|
|
15
16
|
import * as Errors from './core/error';
|
|
16
17
|
import * as Uploads from './core/uploads';
|
|
17
18
|
import * as API from './resources/index';
|
|
19
|
+
import * as TopLevelAPI from './resources/top-level';
|
|
20
|
+
import {
|
|
21
|
+
AdvancedExtractSettings,
|
|
22
|
+
AdvancedSearchSettings,
|
|
23
|
+
ExcerptSettings,
|
|
24
|
+
ExtractError,
|
|
25
|
+
ExtractParams,
|
|
26
|
+
ExtractResponse,
|
|
27
|
+
ExtractResult,
|
|
28
|
+
FetchPolicy,
|
|
29
|
+
SearchParams,
|
|
30
|
+
SearchResult,
|
|
31
|
+
UsageItem,
|
|
32
|
+
WebSearchResult,
|
|
33
|
+
} from './resources/top-level';
|
|
18
34
|
import { APIPromise } from './core/api-promise';
|
|
19
35
|
import {
|
|
20
36
|
AutoSchema,
|
|
21
37
|
Citation,
|
|
38
|
+
ErrorEvent,
|
|
22
39
|
FieldBasis,
|
|
23
40
|
JsonSchema,
|
|
41
|
+
McpServer,
|
|
42
|
+
McpToolCall,
|
|
24
43
|
RunInput,
|
|
25
44
|
TaskRun,
|
|
26
45
|
TaskRunCreateParams,
|
|
46
|
+
TaskRunEvent,
|
|
47
|
+
TaskRunEventsResponse,
|
|
27
48
|
TaskRunJsonOutput,
|
|
28
49
|
TaskRunResult,
|
|
29
50
|
TaskRunResultParams,
|
|
30
51
|
TaskRunTextOutput,
|
|
31
52
|
TaskSpec,
|
|
32
53
|
TextSchema,
|
|
54
|
+
Webhook,
|
|
33
55
|
} from './resources/task-run';
|
|
34
56
|
import { Beta } from './resources/beta/beta';
|
|
35
57
|
import { type Fetch } from './internal/builtin-types';
|
|
@@ -213,6 +235,43 @@ export class Parallel {
|
|
|
213
235
|
return this.baseURL !== 'https://api.parallel.ai';
|
|
214
236
|
}
|
|
215
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Extracts relevant content from specific web URLs.
|
|
240
|
+
*
|
|
241
|
+
* The legacy Extract API reference is available
|
|
242
|
+
* [here](https://docs.parallel.ai/api-reference/legacy/extract-beta/extract).
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* const extractResponse = await client.extract({
|
|
247
|
+
* urls: ['string'],
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
extract(
|
|
252
|
+
body: TopLevelAPI.ExtractParams,
|
|
253
|
+
options?: RequestOptions,
|
|
254
|
+
): APIPromise<TopLevelAPI.ExtractResponse> {
|
|
255
|
+
return this.post('/v1/extract', { body, ...options });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Searches the web.
|
|
260
|
+
*
|
|
261
|
+
* The legacy Search API reference is available
|
|
262
|
+
* [here](https://docs.parallel.ai/api-reference/legacy/search-beta/search).
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* const searchResult = await client.search({
|
|
267
|
+
* search_queries: ['string'],
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
search(body: TopLevelAPI.SearchParams, options?: RequestOptions): APIPromise<TopLevelAPI.SearchResult> {
|
|
272
|
+
return this.post('/v1/search', { body, ...options });
|
|
273
|
+
}
|
|
274
|
+
|
|
216
275
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
217
276
|
return this._options.defaultQuery;
|
|
218
277
|
}
|
|
@@ -228,21 +287,8 @@ export class Parallel {
|
|
|
228
287
|
/**
|
|
229
288
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
230
289
|
*/
|
|
231
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
232
|
-
return
|
|
233
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
234
|
-
.map(([key, value]) => {
|
|
235
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
236
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
237
|
-
}
|
|
238
|
-
if (value === null) {
|
|
239
|
-
return `${encodeURIComponent(key)}=`;
|
|
240
|
-
}
|
|
241
|
-
throw new Errors.ParallelError(
|
|
242
|
-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
243
|
-
);
|
|
244
|
-
})
|
|
245
|
-
.join('&');
|
|
290
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
291
|
+
return stringifyQuery(query);
|
|
246
292
|
}
|
|
247
293
|
|
|
248
294
|
private getUserAgent(): string {
|
|
@@ -274,12 +320,13 @@ export class Parallel {
|
|
|
274
320
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
275
321
|
|
|
276
322
|
const defaultQuery = this.defaultQuery();
|
|
277
|
-
|
|
278
|
-
|
|
323
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
324
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
325
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
279
326
|
}
|
|
280
327
|
|
|
281
328
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
282
|
-
url.search = this.stringifyQuery(query
|
|
329
|
+
url.search = this.stringifyQuery(query);
|
|
283
330
|
}
|
|
284
331
|
|
|
285
332
|
return url.toString();
|
|
@@ -463,7 +510,7 @@ export class Parallel {
|
|
|
463
510
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
464
511
|
|
|
465
512
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
466
|
-
const errJSON = safeJSON(errText);
|
|
513
|
+
const errJSON = safeJSON(errText) as any;
|
|
467
514
|
const errMessage = errJSON ? undefined : errText;
|
|
468
515
|
|
|
469
516
|
loggerFor(this).debug(
|
|
@@ -504,9 +551,10 @@ export class Parallel {
|
|
|
504
551
|
controller: AbortController,
|
|
505
552
|
): Promise<Response> {
|
|
506
553
|
const { signal, method, ...options } = init || {};
|
|
507
|
-
|
|
554
|
+
const abort = this._makeAbort(controller);
|
|
555
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
508
556
|
|
|
509
|
-
const timeout = setTimeout(
|
|
557
|
+
const timeout = setTimeout(abort, ms);
|
|
510
558
|
|
|
511
559
|
const isReadableBody =
|
|
512
560
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -583,9 +631,9 @@ export class Parallel {
|
|
|
583
631
|
}
|
|
584
632
|
}
|
|
585
633
|
|
|
586
|
-
// If the API asks us to wait a certain amount of time
|
|
587
|
-
//
|
|
588
|
-
if (
|
|
634
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
635
|
+
// says, but otherwise calculate a default
|
|
636
|
+
if (timeoutMillis === undefined) {
|
|
589
637
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
590
638
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
591
639
|
}
|
|
@@ -673,6 +721,12 @@ export class Parallel {
|
|
|
673
721
|
return headers.values;
|
|
674
722
|
}
|
|
675
723
|
|
|
724
|
+
private _makeAbort(controller: AbortController) {
|
|
725
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
726
|
+
// would capture all request options, and cause a memory leak.
|
|
727
|
+
return () => controller.abort();
|
|
728
|
+
}
|
|
729
|
+
|
|
676
730
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
677
731
|
bodyHeaders: HeadersLike;
|
|
678
732
|
body: BodyInit | undefined;
|
|
@@ -705,6 +759,14 @@ export class Parallel {
|
|
|
705
759
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
706
760
|
) {
|
|
707
761
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
762
|
+
} else if (
|
|
763
|
+
typeof body === 'object' &&
|
|
764
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
765
|
+
) {
|
|
766
|
+
return {
|
|
767
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
768
|
+
body: this.stringifyQuery(body),
|
|
769
|
+
};
|
|
708
770
|
} else {
|
|
709
771
|
return this.#encoder({ body, headers });
|
|
710
772
|
}
|
|
@@ -729,6 +791,17 @@ export class Parallel {
|
|
|
729
791
|
|
|
730
792
|
static toFile = Uploads.toFile;
|
|
731
793
|
|
|
794
|
+
/**
|
|
795
|
+
* The Task API executes web research and extraction tasks. Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
|
|
796
|
+
* - Output metadata: citations, excerpts, reasoning, and confidence per field
|
|
797
|
+
*
|
|
798
|
+
* Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
|
|
799
|
+
* - Submit hundreds or thousands of Tasks as a single group
|
|
800
|
+
* - Observe group progress and receive results as they complete
|
|
801
|
+
* - Real-time updates via Server-Sent Events (SSE)
|
|
802
|
+
* - Add tasks to an existing group while it is running
|
|
803
|
+
* - Group-level retry and error aggregation
|
|
804
|
+
*/
|
|
732
805
|
taskRun: API.TaskRun = new API.TaskRun(this);
|
|
733
806
|
beta: API.Beta = new API.Beta(this);
|
|
734
807
|
}
|
|
@@ -738,18 +811,39 @@ Parallel.Beta = Beta;
|
|
|
738
811
|
export declare namespace Parallel {
|
|
739
812
|
export type RequestOptions = Opts.RequestOptions;
|
|
740
813
|
|
|
814
|
+
export {
|
|
815
|
+
type AdvancedExtractSettings as AdvancedExtractSettings,
|
|
816
|
+
type AdvancedSearchSettings as AdvancedSearchSettings,
|
|
817
|
+
type ExcerptSettings as ExcerptSettings,
|
|
818
|
+
type ExtractError as ExtractError,
|
|
819
|
+
type ExtractResponse as ExtractResponse,
|
|
820
|
+
type ExtractResult as ExtractResult,
|
|
821
|
+
type FetchPolicy as FetchPolicy,
|
|
822
|
+
type SearchResult as SearchResult,
|
|
823
|
+
type UsageItem as UsageItem,
|
|
824
|
+
type WebSearchResult as WebSearchResult,
|
|
825
|
+
type ExtractParams as ExtractParams,
|
|
826
|
+
type SearchParams as SearchParams,
|
|
827
|
+
};
|
|
828
|
+
|
|
741
829
|
export {
|
|
742
830
|
type TaskRun as TaskRun,
|
|
743
831
|
type AutoSchema as AutoSchema,
|
|
744
832
|
type Citation as Citation,
|
|
833
|
+
type ErrorEvent as ErrorEvent,
|
|
745
834
|
type FieldBasis as FieldBasis,
|
|
746
835
|
type JsonSchema as JsonSchema,
|
|
836
|
+
type McpServer as McpServer,
|
|
837
|
+
type McpToolCall as McpToolCall,
|
|
747
838
|
type RunInput as RunInput,
|
|
839
|
+
type TaskRunEvent as TaskRunEvent,
|
|
748
840
|
type TaskRunJsonOutput as TaskRunJsonOutput,
|
|
749
841
|
type TaskRunResult as TaskRunResult,
|
|
750
842
|
type TaskRunTextOutput as TaskRunTextOutput,
|
|
751
843
|
type TaskSpec as TaskSpec,
|
|
752
844
|
type TextSchema as TextSchema,
|
|
845
|
+
type Webhook as Webhook,
|
|
846
|
+
type TaskRunEventsResponse as TaskRunEventsResponse,
|
|
753
847
|
type TaskRunCreateParams as TaskRunCreateParams,
|
|
754
848
|
type TaskRunResultParams as TaskRunResultParams,
|
|
755
849
|
};
|
package/src/core/streaming.ts
CHANGED
|
@@ -46,7 +46,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
46
46
|
try {
|
|
47
47
|
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
48
48
|
try {
|
|
49
|
-
yield JSON.parse(sse.data);
|
|
49
|
+
yield JSON.parse(sse.data) as Item;
|
|
50
50
|
} catch (e) {
|
|
51
51
|
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
52
52
|
logger.error(`From chunk:`, sse.raw);
|
|
@@ -102,7 +102,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
102
102
|
try {
|
|
103
103
|
for await (const line of iterLines()) {
|
|
104
104
|
if (done) continue;
|
|
105
|
-
if (line) yield JSON.parse(line);
|
|
105
|
+
if (line) yield JSON.parse(line) as Item;
|
|
106
106
|
}
|
|
107
107
|
done = true;
|
|
108
108
|
} catch (e) {
|
package/src/internal/parse.ts
CHANGED
|
@@ -43,6 +43,12 @@ export async function defaultParseResponse<T>(client: Parallel, props: APIRespon
|
|
|
43
43
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
44
44
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
45
45
|
if (isJSON) {
|
|
46
|
+
const contentLength = response.headers.get('content-length');
|
|
47
|
+
if (contentLength === '0') {
|
|
48
|
+
// if there is no content we can't do anything
|
|
49
|
+
return undefined as T;
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
const json = await response.json();
|
|
47
53
|
return json as T;
|
|
48
54
|
}
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const readEnv = (env: string): string | undefined => {
|
|
11
11
|
if (typeof (globalThis as any).process !== 'undefined') {
|
|
12
|
-
return (globalThis as any).process.env?.[env]?.trim()
|
|
12
|
+
return (globalThis as any).process.env?.[env]?.trim() || undefined;
|
|
13
13
|
}
|
|
14
14
|
if (typeof (globalThis as any).Deno !== 'undefined') {
|
|
15
|
-
return (globalThis as any).Deno.env?.get?.(env)?.trim();
|
|
15
|
+
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { ParallelError } from '../../core/error';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
7
|
+
*/
|
|
8
|
+
export function stringifyQuery(query: object | Record<string, unknown>) {
|
|
9
|
+
return Object.entries(query)
|
|
10
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
11
|
+
.map(([key, value]) => {
|
|
12
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
13
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
14
|
+
}
|
|
15
|
+
if (value === null) {
|
|
16
|
+
return `${encodeURIComponent(key)}=`;
|
|
17
|
+
}
|
|
18
|
+
throw new ParallelError(
|
|
19
|
+
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
20
|
+
);
|
|
21
|
+
})
|
|
22
|
+
.join('&');
|
|
23
|
+
}
|
package/src/internal/utils.ts
CHANGED