valyu-js 2.3.2 → 2.3.3
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/README.md +83 -3
- package/dist/index.d.mts +171 -1
- package/dist/index.d.ts +171 -1
- package/dist/index.js +189 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +189 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ The `deepresearch` namespace provides access to Valyu's AI-powered research agen
|
|
|
58
58
|
// Create a research task
|
|
59
59
|
const task = await valyu.deepresearch.create({
|
|
60
60
|
input: "What are the latest developments in quantum computing?",
|
|
61
|
-
model: "
|
|
61
|
+
model: "fast", // "fast" (Haiku) or "heavy" (thorough, Sonnet)
|
|
62
62
|
outputFormats: ["markdown", "pdf"] // Output formats
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -94,7 +94,7 @@ console.log(result.pdf_url); // PDF download URL
|
|
|
94
94
|
| Parameter | Type | Default | Description |
|
|
95
95
|
|-----------|------|---------|-------------|
|
|
96
96
|
| `input` | `string` | *required* | Research query or task description |
|
|
97
|
-
| `model` | `"
|
|
97
|
+
| `model` | `"fast" \| "heavy"` | `"fast"` | Research model - fast or heavy (thorough) |
|
|
98
98
|
| `outputFormats` | `("markdown" \| "pdf")[]` | `["markdown"]` | Output formats for the report |
|
|
99
99
|
| `strategy` | `string` | - | Natural language research strategy |
|
|
100
100
|
| `search` | `object` | - | Search configuration (type, sources) |
|
|
@@ -112,7 +112,7 @@ console.log(result.pdf_url); // PDF download URL
|
|
|
112
112
|
```javascript
|
|
113
113
|
const task = await valyu.deepresearch.create({
|
|
114
114
|
input: "Summarize recent AI safety research",
|
|
115
|
-
model: "
|
|
115
|
+
model: "fast"
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
const result = await valyu.deepresearch.wait(task.deepresearch_id);
|
|
@@ -160,6 +160,86 @@ const task = await valyu.deepresearch.create({
|
|
|
160
160
|
});
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
+
### Batch API
|
|
164
|
+
|
|
165
|
+
The `batch` namespace allows you to process multiple DeepResearch tasks efficiently. Perfect for running large-scale research operations.
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
// Create a batch
|
|
169
|
+
const batch = await valyu.batch.create({
|
|
170
|
+
name: "Q4 Research Batch",
|
|
171
|
+
model: "fast", // "fast", "standard", or "heavy"
|
|
172
|
+
outputFormats: ["markdown"]
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Add tasks to the batch
|
|
176
|
+
await valyu.batch.addTasks(batch.batch_id, {
|
|
177
|
+
tasks: [
|
|
178
|
+
{ input: "What are the latest AI developments?" },
|
|
179
|
+
{ input: "Analyze climate change trends" },
|
|
180
|
+
{ input: "Review quantum computing progress" }
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Wait for completion
|
|
185
|
+
const result = await valyu.batch.waitForCompletion(batch.batch_id, {
|
|
186
|
+
pollInterval: 10000, // Check every 10 seconds
|
|
187
|
+
onProgress: (batch) => {
|
|
188
|
+
console.log(`Progress: ${batch.counts.completed}/${batch.counts.total}`);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
console.log('Total cost:', result.usage.total_cost);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Batch Methods
|
|
196
|
+
|
|
197
|
+
| Method | Description |
|
|
198
|
+
|--------|-------------|
|
|
199
|
+
| `create(options?)` | Create a new batch |
|
|
200
|
+
| `status(batchId)` | Get batch status and task counts |
|
|
201
|
+
| `addTasks(batchId, options)` | Add tasks to a batch |
|
|
202
|
+
| `listTasks(batchId)` | List all tasks in a batch |
|
|
203
|
+
| `list()` | List all batches |
|
|
204
|
+
| `cancel(batchId)` | Cancel a batch and all pending tasks |
|
|
205
|
+
| `waitForCompletion(batchId, options?)` | Wait for batch completion with polling |
|
|
206
|
+
|
|
207
|
+
#### Batch Create Options
|
|
208
|
+
|
|
209
|
+
| Parameter | Type | Default | Description |
|
|
210
|
+
|-----------|------|---------|-------------|
|
|
211
|
+
| `name` | `string` | - | Optional batch name |
|
|
212
|
+
| `model` | `"fast" \| "standard" \| "heavy"` | `"standard"` | DeepResearch model for all tasks |
|
|
213
|
+
| `outputFormats` | `("markdown" \| "pdf")[]` | `["markdown"]` | Output formats |
|
|
214
|
+
| `search` | `object` | - | Search configuration for all tasks |
|
|
215
|
+
| `webhookUrl` | `string` | - | HTTPS URL for completion webhook |
|
|
216
|
+
| `metadata` | `object` | - | Custom metadata key-value pairs |
|
|
217
|
+
|
|
218
|
+
#### Batch Status Response
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
{
|
|
222
|
+
success: true,
|
|
223
|
+
batch: {
|
|
224
|
+
batch_id: "batch_xxx",
|
|
225
|
+
status: "processing", // "open", "processing", "completed", "cancelled"
|
|
226
|
+
counts: {
|
|
227
|
+
total: 10,
|
|
228
|
+
queued: 3,
|
|
229
|
+
running: 2,
|
|
230
|
+
completed: 4,
|
|
231
|
+
failed: 1,
|
|
232
|
+
cancelled: 0
|
|
233
|
+
},
|
|
234
|
+
usage: {
|
|
235
|
+
search_cost: 0.05,
|
|
236
|
+
ai_cost: 0.15,
|
|
237
|
+
total_cost: 0.20
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
163
243
|
### Search Method
|
|
164
244
|
|
|
165
245
|
The `search()` method is the core of the Valyu SDK. It accepts a query string as the first parameter, followed by optional configuration parameters.
|
package/dist/index.d.mts
CHANGED
|
@@ -352,6 +352,114 @@ interface ListOptions {
|
|
|
352
352
|
apiKeyId: string;
|
|
353
353
|
limit?: number;
|
|
354
354
|
}
|
|
355
|
+
type BatchStatus = "open" | "processing" | "completed" | "completed_with_errors" | "cancelled";
|
|
356
|
+
interface BatchCounts {
|
|
357
|
+
total: number;
|
|
358
|
+
queued: number;
|
|
359
|
+
running: number;
|
|
360
|
+
completed: number;
|
|
361
|
+
failed: number;
|
|
362
|
+
cancelled: number;
|
|
363
|
+
}
|
|
364
|
+
interface BatchUsage {
|
|
365
|
+
search_cost: number;
|
|
366
|
+
contents_cost: number;
|
|
367
|
+
ai_cost: number;
|
|
368
|
+
total_cost: number;
|
|
369
|
+
}
|
|
370
|
+
interface DeepResearchBatch {
|
|
371
|
+
batch_id: string;
|
|
372
|
+
organisation_id: string;
|
|
373
|
+
api_key_id: string;
|
|
374
|
+
credit_id: string;
|
|
375
|
+
name?: string;
|
|
376
|
+
status: BatchStatus;
|
|
377
|
+
model: DeepResearchMode;
|
|
378
|
+
output_formats?: DeepResearchOutputFormat[];
|
|
379
|
+
search_params?: {
|
|
380
|
+
search_type?: "all" | "web" | "proprietary";
|
|
381
|
+
included_sources?: string[];
|
|
382
|
+
};
|
|
383
|
+
counts: BatchCounts;
|
|
384
|
+
usage: BatchUsage;
|
|
385
|
+
webhook_url?: string;
|
|
386
|
+
webhook_secret?: string;
|
|
387
|
+
created_at: number;
|
|
388
|
+
updated_at: number;
|
|
389
|
+
completed_at?: number;
|
|
390
|
+
metadata?: Record<string, string | number | boolean>;
|
|
391
|
+
}
|
|
392
|
+
interface CreateBatchOptions {
|
|
393
|
+
name?: string;
|
|
394
|
+
model?: DeepResearchMode;
|
|
395
|
+
outputFormats?: DeepResearchOutputFormat[];
|
|
396
|
+
search?: {
|
|
397
|
+
searchType?: "all" | "web" | "proprietary";
|
|
398
|
+
includedSources?: string[];
|
|
399
|
+
};
|
|
400
|
+
webhookUrl?: string;
|
|
401
|
+
metadata?: Record<string, string | number | boolean>;
|
|
402
|
+
}
|
|
403
|
+
interface BatchTaskInput {
|
|
404
|
+
id?: string;
|
|
405
|
+
input: string;
|
|
406
|
+
strategy?: string;
|
|
407
|
+
urls?: string[];
|
|
408
|
+
metadata?: Record<string, string | number | boolean>;
|
|
409
|
+
}
|
|
410
|
+
interface AddBatchTasksOptions {
|
|
411
|
+
tasks: BatchTaskInput[];
|
|
412
|
+
}
|
|
413
|
+
interface CreateBatchResponse {
|
|
414
|
+
success: boolean;
|
|
415
|
+
batch_id?: string;
|
|
416
|
+
status?: BatchStatus;
|
|
417
|
+
webhook_secret?: string;
|
|
418
|
+
error?: string;
|
|
419
|
+
}
|
|
420
|
+
interface BatchStatusResponse {
|
|
421
|
+
success: boolean;
|
|
422
|
+
batch?: DeepResearchBatch;
|
|
423
|
+
error?: string;
|
|
424
|
+
}
|
|
425
|
+
interface AddBatchTasksResponse {
|
|
426
|
+
success: boolean;
|
|
427
|
+
added_count?: number;
|
|
428
|
+
task_ids?: string[];
|
|
429
|
+
error?: string;
|
|
430
|
+
}
|
|
431
|
+
interface BatchTaskListItem {
|
|
432
|
+
deepresearch_id: string;
|
|
433
|
+
batch_id: string;
|
|
434
|
+
batch_task_id?: string;
|
|
435
|
+
query: string;
|
|
436
|
+
status: DeepResearchStatus;
|
|
437
|
+
created_at: number;
|
|
438
|
+
completed_at?: number;
|
|
439
|
+
error?: string;
|
|
440
|
+
}
|
|
441
|
+
interface ListBatchTasksResponse {
|
|
442
|
+
success: boolean;
|
|
443
|
+
tasks?: BatchTaskListItem[];
|
|
444
|
+
total_count?: number;
|
|
445
|
+
error?: string;
|
|
446
|
+
}
|
|
447
|
+
interface CancelBatchResponse {
|
|
448
|
+
success: boolean;
|
|
449
|
+
message?: string;
|
|
450
|
+
batch_id?: string;
|
|
451
|
+
error?: string;
|
|
452
|
+
}
|
|
453
|
+
interface ListBatchesResponse {
|
|
454
|
+
success: boolean;
|
|
455
|
+
batches?: DeepResearchBatch[];
|
|
456
|
+
error?: string;
|
|
457
|
+
}
|
|
458
|
+
interface BatchWaitOptions {
|
|
459
|
+
pollInterval?: number;
|
|
460
|
+
maxWaitTime?: number;
|
|
461
|
+
onProgress?: (batch: DeepResearchBatch) => void;
|
|
462
|
+
}
|
|
355
463
|
|
|
356
464
|
declare class Valyu {
|
|
357
465
|
private baseUrl;
|
|
@@ -367,6 +475,15 @@ declare class Valyu {
|
|
|
367
475
|
delete: (taskId: string) => Promise<DeepResearchDeleteResponse>;
|
|
368
476
|
togglePublic: (taskId: string, isPublic: boolean) => Promise<DeepResearchTogglePublicResponse>;
|
|
369
477
|
};
|
|
478
|
+
batch: {
|
|
479
|
+
create: (options?: CreateBatchOptions) => Promise<CreateBatchResponse>;
|
|
480
|
+
status: (batchId: string) => Promise<BatchStatusResponse>;
|
|
481
|
+
addTasks: (batchId: string, options: AddBatchTasksOptions) => Promise<AddBatchTasksResponse>;
|
|
482
|
+
listTasks: (batchId: string) => Promise<ListBatchTasksResponse>;
|
|
483
|
+
cancel: (batchId: string) => Promise<CancelBatchResponse>;
|
|
484
|
+
list: () => Promise<ListBatchesResponse>;
|
|
485
|
+
waitForCompletion: (batchId: string, options?: BatchWaitOptions) => Promise<DeepResearchBatch>;
|
|
486
|
+
};
|
|
370
487
|
constructor(apiKey?: string, baseUrl?: string);
|
|
371
488
|
/**
|
|
372
489
|
* Validates date format (YYYY-MM-DD)
|
|
@@ -460,6 +577,59 @@ declare class Valyu {
|
|
|
460
577
|
* DeepResearch: Toggle public flag
|
|
461
578
|
*/
|
|
462
579
|
private _deepresearchTogglePublic;
|
|
580
|
+
/**
|
|
581
|
+
* Batch: Create a new batch
|
|
582
|
+
* @param options - Batch configuration options
|
|
583
|
+
* @param options.name - Optional name for the batch
|
|
584
|
+
* @param options.model - DeepResearch mode: "fast", "standard", or "heavy" (default: "standard")
|
|
585
|
+
* @param options.outputFormats - Output formats for tasks (default: ["markdown"])
|
|
586
|
+
* @param options.search - Search configuration for all tasks in batch
|
|
587
|
+
* @param options.webhookUrl - Optional HTTPS URL for completion notification
|
|
588
|
+
* @param options.metadata - Optional metadata key-value pairs
|
|
589
|
+
* @returns Promise resolving to batch creation response with batch_id and webhook_secret
|
|
590
|
+
*/
|
|
591
|
+
private _batchCreate;
|
|
592
|
+
/**
|
|
593
|
+
* Batch: Get batch status
|
|
594
|
+
* @param batchId - The batch ID to query
|
|
595
|
+
* @returns Promise resolving to batch status with counts and usage
|
|
596
|
+
*/
|
|
597
|
+
private _batchStatus;
|
|
598
|
+
/**
|
|
599
|
+
* Batch: Add tasks to a batch
|
|
600
|
+
* @param batchId - The batch ID to add tasks to
|
|
601
|
+
* @param options - Task configuration options
|
|
602
|
+
* @param options.tasks - Array of task inputs
|
|
603
|
+
* @returns Promise resolving to response with added_count and task_ids
|
|
604
|
+
*/
|
|
605
|
+
private _batchAddTasks;
|
|
606
|
+
/**
|
|
607
|
+
* Batch: List all tasks in a batch
|
|
608
|
+
* @param batchId - The batch ID to query
|
|
609
|
+
* @returns Promise resolving to list of tasks with their status
|
|
610
|
+
*/
|
|
611
|
+
private _batchListTasks;
|
|
612
|
+
/**
|
|
613
|
+
* Batch: Cancel a batch and all its pending tasks
|
|
614
|
+
* @param batchId - The batch ID to cancel
|
|
615
|
+
* @returns Promise resolving to cancellation confirmation
|
|
616
|
+
*/
|
|
617
|
+
private _batchCancel;
|
|
618
|
+
/**
|
|
619
|
+
* Batch: List all batches
|
|
620
|
+
* @returns Promise resolving to list of all batches
|
|
621
|
+
*/
|
|
622
|
+
private _batchList;
|
|
623
|
+
/**
|
|
624
|
+
* Batch: Wait for batch completion with polling
|
|
625
|
+
* @param batchId - The batch ID to wait for
|
|
626
|
+
* @param options - Wait configuration options
|
|
627
|
+
* @param options.pollInterval - Polling interval in milliseconds (default: 10000)
|
|
628
|
+
* @param options.maxWaitTime - Maximum wait time in milliseconds (default: 7200000)
|
|
629
|
+
* @param options.onProgress - Callback for progress updates
|
|
630
|
+
* @returns Promise resolving to final batch status
|
|
631
|
+
*/
|
|
632
|
+
private _batchWaitForCompletion;
|
|
463
633
|
/**
|
|
464
634
|
* Get AI-powered answers using the Valyu Answer API
|
|
465
635
|
* @param query - The question or query string
|
|
@@ -500,4 +670,4 @@ declare class Valyu {
|
|
|
500
670
|
private createErrorGenerator;
|
|
501
671
|
}
|
|
502
672
|
|
|
503
|
-
export { type AIUsage, type AnswerErrorResponse, type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamChunkType, type AnswerSuccessResponse, type ChartDataPoint, type ChartDataSeries, type ChartType, type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type Cost, type CountryCode, type DeepResearchCancelResponse, type DeepResearchCreateOptions, type DeepResearchCreateResponse, type DeepResearchDeleteResponse, type DeepResearchListResponse, type DeepResearchMode, type DeepResearchOutputFormat, type DeepResearchSearchConfig, type DeepResearchSource, type DeepResearchStatus, type DeepResearchStatusResponse, type DeepResearchTaskListItem, type DeepResearchTogglePublicResponse, type DeepResearchUpdateResponse, type DeepResearchUsage, type ExtractEffort, type ExtractionMetadata, type FeedbackResponse, type FeedbackSentiment, type FileAttachment, type ImageMetadata, type ImageType, type ListOptions, type MCPServerConfig, type Progress, type ResponseLength, type SearchMetadata, type SearchOptions, type SearchResponse, type SearchResult, type SearchType, type StreamCallback, Valyu, type WaitOptions };
|
|
673
|
+
export { type AIUsage, type AddBatchTasksOptions, type AddBatchTasksResponse, type AnswerErrorResponse, type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamChunkType, type AnswerSuccessResponse, type BatchCounts, type BatchStatus, type BatchStatusResponse, type BatchTaskInput, type BatchTaskListItem, type BatchUsage, type BatchWaitOptions, type CancelBatchResponse, type ChartDataPoint, type ChartDataSeries, type ChartType, type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type Cost, type CountryCode, type CreateBatchOptions, type CreateBatchResponse, type DeepResearchBatch, type DeepResearchCancelResponse, type DeepResearchCreateOptions, type DeepResearchCreateResponse, type DeepResearchDeleteResponse, type DeepResearchListResponse, type DeepResearchMode, type DeepResearchOutputFormat, type DeepResearchSearchConfig, type DeepResearchSource, type DeepResearchStatus, type DeepResearchStatusResponse, type DeepResearchTaskListItem, type DeepResearchTogglePublicResponse, type DeepResearchUpdateResponse, type DeepResearchUsage, type ExtractEffort, type ExtractionMetadata, type FeedbackResponse, type FeedbackSentiment, type FileAttachment, type ImageMetadata, type ImageType, type ListBatchTasksResponse, type ListBatchesResponse, type ListOptions, type MCPServerConfig, type Progress, type ResponseLength, type SearchMetadata, type SearchOptions, type SearchResponse, type SearchResult, type SearchType, type StreamCallback, Valyu, type WaitOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -352,6 +352,114 @@ interface ListOptions {
|
|
|
352
352
|
apiKeyId: string;
|
|
353
353
|
limit?: number;
|
|
354
354
|
}
|
|
355
|
+
type BatchStatus = "open" | "processing" | "completed" | "completed_with_errors" | "cancelled";
|
|
356
|
+
interface BatchCounts {
|
|
357
|
+
total: number;
|
|
358
|
+
queued: number;
|
|
359
|
+
running: number;
|
|
360
|
+
completed: number;
|
|
361
|
+
failed: number;
|
|
362
|
+
cancelled: number;
|
|
363
|
+
}
|
|
364
|
+
interface BatchUsage {
|
|
365
|
+
search_cost: number;
|
|
366
|
+
contents_cost: number;
|
|
367
|
+
ai_cost: number;
|
|
368
|
+
total_cost: number;
|
|
369
|
+
}
|
|
370
|
+
interface DeepResearchBatch {
|
|
371
|
+
batch_id: string;
|
|
372
|
+
organisation_id: string;
|
|
373
|
+
api_key_id: string;
|
|
374
|
+
credit_id: string;
|
|
375
|
+
name?: string;
|
|
376
|
+
status: BatchStatus;
|
|
377
|
+
model: DeepResearchMode;
|
|
378
|
+
output_formats?: DeepResearchOutputFormat[];
|
|
379
|
+
search_params?: {
|
|
380
|
+
search_type?: "all" | "web" | "proprietary";
|
|
381
|
+
included_sources?: string[];
|
|
382
|
+
};
|
|
383
|
+
counts: BatchCounts;
|
|
384
|
+
usage: BatchUsage;
|
|
385
|
+
webhook_url?: string;
|
|
386
|
+
webhook_secret?: string;
|
|
387
|
+
created_at: number;
|
|
388
|
+
updated_at: number;
|
|
389
|
+
completed_at?: number;
|
|
390
|
+
metadata?: Record<string, string | number | boolean>;
|
|
391
|
+
}
|
|
392
|
+
interface CreateBatchOptions {
|
|
393
|
+
name?: string;
|
|
394
|
+
model?: DeepResearchMode;
|
|
395
|
+
outputFormats?: DeepResearchOutputFormat[];
|
|
396
|
+
search?: {
|
|
397
|
+
searchType?: "all" | "web" | "proprietary";
|
|
398
|
+
includedSources?: string[];
|
|
399
|
+
};
|
|
400
|
+
webhookUrl?: string;
|
|
401
|
+
metadata?: Record<string, string | number | boolean>;
|
|
402
|
+
}
|
|
403
|
+
interface BatchTaskInput {
|
|
404
|
+
id?: string;
|
|
405
|
+
input: string;
|
|
406
|
+
strategy?: string;
|
|
407
|
+
urls?: string[];
|
|
408
|
+
metadata?: Record<string, string | number | boolean>;
|
|
409
|
+
}
|
|
410
|
+
interface AddBatchTasksOptions {
|
|
411
|
+
tasks: BatchTaskInput[];
|
|
412
|
+
}
|
|
413
|
+
interface CreateBatchResponse {
|
|
414
|
+
success: boolean;
|
|
415
|
+
batch_id?: string;
|
|
416
|
+
status?: BatchStatus;
|
|
417
|
+
webhook_secret?: string;
|
|
418
|
+
error?: string;
|
|
419
|
+
}
|
|
420
|
+
interface BatchStatusResponse {
|
|
421
|
+
success: boolean;
|
|
422
|
+
batch?: DeepResearchBatch;
|
|
423
|
+
error?: string;
|
|
424
|
+
}
|
|
425
|
+
interface AddBatchTasksResponse {
|
|
426
|
+
success: boolean;
|
|
427
|
+
added_count?: number;
|
|
428
|
+
task_ids?: string[];
|
|
429
|
+
error?: string;
|
|
430
|
+
}
|
|
431
|
+
interface BatchTaskListItem {
|
|
432
|
+
deepresearch_id: string;
|
|
433
|
+
batch_id: string;
|
|
434
|
+
batch_task_id?: string;
|
|
435
|
+
query: string;
|
|
436
|
+
status: DeepResearchStatus;
|
|
437
|
+
created_at: number;
|
|
438
|
+
completed_at?: number;
|
|
439
|
+
error?: string;
|
|
440
|
+
}
|
|
441
|
+
interface ListBatchTasksResponse {
|
|
442
|
+
success: boolean;
|
|
443
|
+
tasks?: BatchTaskListItem[];
|
|
444
|
+
total_count?: number;
|
|
445
|
+
error?: string;
|
|
446
|
+
}
|
|
447
|
+
interface CancelBatchResponse {
|
|
448
|
+
success: boolean;
|
|
449
|
+
message?: string;
|
|
450
|
+
batch_id?: string;
|
|
451
|
+
error?: string;
|
|
452
|
+
}
|
|
453
|
+
interface ListBatchesResponse {
|
|
454
|
+
success: boolean;
|
|
455
|
+
batches?: DeepResearchBatch[];
|
|
456
|
+
error?: string;
|
|
457
|
+
}
|
|
458
|
+
interface BatchWaitOptions {
|
|
459
|
+
pollInterval?: number;
|
|
460
|
+
maxWaitTime?: number;
|
|
461
|
+
onProgress?: (batch: DeepResearchBatch) => void;
|
|
462
|
+
}
|
|
355
463
|
|
|
356
464
|
declare class Valyu {
|
|
357
465
|
private baseUrl;
|
|
@@ -367,6 +475,15 @@ declare class Valyu {
|
|
|
367
475
|
delete: (taskId: string) => Promise<DeepResearchDeleteResponse>;
|
|
368
476
|
togglePublic: (taskId: string, isPublic: boolean) => Promise<DeepResearchTogglePublicResponse>;
|
|
369
477
|
};
|
|
478
|
+
batch: {
|
|
479
|
+
create: (options?: CreateBatchOptions) => Promise<CreateBatchResponse>;
|
|
480
|
+
status: (batchId: string) => Promise<BatchStatusResponse>;
|
|
481
|
+
addTasks: (batchId: string, options: AddBatchTasksOptions) => Promise<AddBatchTasksResponse>;
|
|
482
|
+
listTasks: (batchId: string) => Promise<ListBatchTasksResponse>;
|
|
483
|
+
cancel: (batchId: string) => Promise<CancelBatchResponse>;
|
|
484
|
+
list: () => Promise<ListBatchesResponse>;
|
|
485
|
+
waitForCompletion: (batchId: string, options?: BatchWaitOptions) => Promise<DeepResearchBatch>;
|
|
486
|
+
};
|
|
370
487
|
constructor(apiKey?: string, baseUrl?: string);
|
|
371
488
|
/**
|
|
372
489
|
* Validates date format (YYYY-MM-DD)
|
|
@@ -460,6 +577,59 @@ declare class Valyu {
|
|
|
460
577
|
* DeepResearch: Toggle public flag
|
|
461
578
|
*/
|
|
462
579
|
private _deepresearchTogglePublic;
|
|
580
|
+
/**
|
|
581
|
+
* Batch: Create a new batch
|
|
582
|
+
* @param options - Batch configuration options
|
|
583
|
+
* @param options.name - Optional name for the batch
|
|
584
|
+
* @param options.model - DeepResearch mode: "fast", "standard", or "heavy" (default: "standard")
|
|
585
|
+
* @param options.outputFormats - Output formats for tasks (default: ["markdown"])
|
|
586
|
+
* @param options.search - Search configuration for all tasks in batch
|
|
587
|
+
* @param options.webhookUrl - Optional HTTPS URL for completion notification
|
|
588
|
+
* @param options.metadata - Optional metadata key-value pairs
|
|
589
|
+
* @returns Promise resolving to batch creation response with batch_id and webhook_secret
|
|
590
|
+
*/
|
|
591
|
+
private _batchCreate;
|
|
592
|
+
/**
|
|
593
|
+
* Batch: Get batch status
|
|
594
|
+
* @param batchId - The batch ID to query
|
|
595
|
+
* @returns Promise resolving to batch status with counts and usage
|
|
596
|
+
*/
|
|
597
|
+
private _batchStatus;
|
|
598
|
+
/**
|
|
599
|
+
* Batch: Add tasks to a batch
|
|
600
|
+
* @param batchId - The batch ID to add tasks to
|
|
601
|
+
* @param options - Task configuration options
|
|
602
|
+
* @param options.tasks - Array of task inputs
|
|
603
|
+
* @returns Promise resolving to response with added_count and task_ids
|
|
604
|
+
*/
|
|
605
|
+
private _batchAddTasks;
|
|
606
|
+
/**
|
|
607
|
+
* Batch: List all tasks in a batch
|
|
608
|
+
* @param batchId - The batch ID to query
|
|
609
|
+
* @returns Promise resolving to list of tasks with their status
|
|
610
|
+
*/
|
|
611
|
+
private _batchListTasks;
|
|
612
|
+
/**
|
|
613
|
+
* Batch: Cancel a batch and all its pending tasks
|
|
614
|
+
* @param batchId - The batch ID to cancel
|
|
615
|
+
* @returns Promise resolving to cancellation confirmation
|
|
616
|
+
*/
|
|
617
|
+
private _batchCancel;
|
|
618
|
+
/**
|
|
619
|
+
* Batch: List all batches
|
|
620
|
+
* @returns Promise resolving to list of all batches
|
|
621
|
+
*/
|
|
622
|
+
private _batchList;
|
|
623
|
+
/**
|
|
624
|
+
* Batch: Wait for batch completion with polling
|
|
625
|
+
* @param batchId - The batch ID to wait for
|
|
626
|
+
* @param options - Wait configuration options
|
|
627
|
+
* @param options.pollInterval - Polling interval in milliseconds (default: 10000)
|
|
628
|
+
* @param options.maxWaitTime - Maximum wait time in milliseconds (default: 7200000)
|
|
629
|
+
* @param options.onProgress - Callback for progress updates
|
|
630
|
+
* @returns Promise resolving to final batch status
|
|
631
|
+
*/
|
|
632
|
+
private _batchWaitForCompletion;
|
|
463
633
|
/**
|
|
464
634
|
* Get AI-powered answers using the Valyu Answer API
|
|
465
635
|
* @param query - The question or query string
|
|
@@ -500,4 +670,4 @@ declare class Valyu {
|
|
|
500
670
|
private createErrorGenerator;
|
|
501
671
|
}
|
|
502
672
|
|
|
503
|
-
export { type AIUsage, type AnswerErrorResponse, type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamChunkType, type AnswerSuccessResponse, type ChartDataPoint, type ChartDataSeries, type ChartType, type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type Cost, type CountryCode, type DeepResearchCancelResponse, type DeepResearchCreateOptions, type DeepResearchCreateResponse, type DeepResearchDeleteResponse, type DeepResearchListResponse, type DeepResearchMode, type DeepResearchOutputFormat, type DeepResearchSearchConfig, type DeepResearchSource, type DeepResearchStatus, type DeepResearchStatusResponse, type DeepResearchTaskListItem, type DeepResearchTogglePublicResponse, type DeepResearchUpdateResponse, type DeepResearchUsage, type ExtractEffort, type ExtractionMetadata, type FeedbackResponse, type FeedbackSentiment, type FileAttachment, type ImageMetadata, type ImageType, type ListOptions, type MCPServerConfig, type Progress, type ResponseLength, type SearchMetadata, type SearchOptions, type SearchResponse, type SearchResult, type SearchType, type StreamCallback, Valyu, type WaitOptions };
|
|
673
|
+
export { type AIUsage, type AddBatchTasksOptions, type AddBatchTasksResponse, type AnswerErrorResponse, type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamChunkType, type AnswerSuccessResponse, type BatchCounts, type BatchStatus, type BatchStatusResponse, type BatchTaskInput, type BatchTaskListItem, type BatchUsage, type BatchWaitOptions, type CancelBatchResponse, type ChartDataPoint, type ChartDataSeries, type ChartType, type ContentResponseLength, type ContentResult, type ContentsOptions, type ContentsResponse, type Cost, type CountryCode, type CreateBatchOptions, type CreateBatchResponse, type DeepResearchBatch, type DeepResearchCancelResponse, type DeepResearchCreateOptions, type DeepResearchCreateResponse, type DeepResearchDeleteResponse, type DeepResearchListResponse, type DeepResearchMode, type DeepResearchOutputFormat, type DeepResearchSearchConfig, type DeepResearchSource, type DeepResearchStatus, type DeepResearchStatusResponse, type DeepResearchTaskListItem, type DeepResearchTogglePublicResponse, type DeepResearchUpdateResponse, type DeepResearchUsage, type ExtractEffort, type ExtractionMetadata, type FeedbackResponse, type FeedbackSentiment, type FileAttachment, type ImageMetadata, type ImageType, type ListBatchTasksResponse, type ListBatchesResponse, type ListOptions, type MCPServerConfig, type Progress, type ResponseLength, type SearchMetadata, type SearchOptions, type SearchResponse, type SearchResult, type SearchType, type StreamCallback, Valyu, type WaitOptions };
|