valyu-js 2.7.10 → 2.7.12
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/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +30 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,12 @@ interface SearchResult {
|
|
|
19
19
|
id?: string;
|
|
20
20
|
image_url?: Record<string, string>;
|
|
21
21
|
abstract?: string;
|
|
22
|
+
doi?: string;
|
|
23
|
+
citation?: string;
|
|
24
|
+
citation_count?: number;
|
|
25
|
+
authors?: string[];
|
|
26
|
+
references?: string;
|
|
27
|
+
metadata?: Record<string, any>;
|
|
22
28
|
}
|
|
23
29
|
interface SearchOptions {
|
|
24
30
|
searchType?: SearchType;
|
|
@@ -703,6 +709,7 @@ declare function verifyContentsWebhookSignature(payload: string, signature: stri
|
|
|
703
709
|
declare class Valyu {
|
|
704
710
|
private baseUrl;
|
|
705
711
|
private headers;
|
|
712
|
+
private client;
|
|
706
713
|
deepresearch: {
|
|
707
714
|
create: (options: DeepResearchCreateOptions) => Promise<DeepResearchCreateResponse>;
|
|
708
715
|
status: (taskId: string) => Promise<DeepResearchStatusResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ interface SearchResult {
|
|
|
19
19
|
id?: string;
|
|
20
20
|
image_url?: Record<string, string>;
|
|
21
21
|
abstract?: string;
|
|
22
|
+
doi?: string;
|
|
23
|
+
citation?: string;
|
|
24
|
+
citation_count?: number;
|
|
25
|
+
authors?: string[];
|
|
26
|
+
references?: string;
|
|
27
|
+
metadata?: Record<string, any>;
|
|
22
28
|
}
|
|
23
29
|
interface SearchOptions {
|
|
24
30
|
searchType?: SearchType;
|
|
@@ -703,6 +709,7 @@ declare function verifyContentsWebhookSignature(payload: string, signature: stri
|
|
|
703
709
|
declare class Valyu {
|
|
704
710
|
private baseUrl;
|
|
705
711
|
private headers;
|
|
712
|
+
private client;
|
|
706
713
|
deepresearch: {
|
|
707
714
|
create: (options: DeepResearchCreateOptions) => Promise<DeepResearchCreateResponse>;
|
|
708
715
|
status: (taskId: string) => Promise<DeepResearchStatusResponse>;
|
package/dist/index.js
CHANGED
|
@@ -35,8 +35,10 @@ __export(index_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
var import_crypto = require("crypto");
|
|
38
|
+
var import_http = __toESM(require("http"));
|
|
39
|
+
var import_https = __toESM(require("https"));
|
|
38
40
|
var import_axios = __toESM(require("axios"));
|
|
39
|
-
var SDK_VERSION = "2.7.
|
|
41
|
+
var SDK_VERSION = "2.7.12";
|
|
40
42
|
function normalizeContentsJobResponse(api) {
|
|
41
43
|
return {
|
|
42
44
|
success: api.success ?? true,
|
|
@@ -91,6 +93,12 @@ var Valyu = class {
|
|
|
91
93
|
"X-Valyu-SDK": "valyu-js",
|
|
92
94
|
"X-Valyu-SDK-Version": SDK_VERSION
|
|
93
95
|
};
|
|
96
|
+
this.client = import_axios.default.create({
|
|
97
|
+
baseURL: this.baseUrl,
|
|
98
|
+
headers: this.headers,
|
|
99
|
+
httpAgent: new import_http.default.Agent({ keepAlive: true }),
|
|
100
|
+
httpsAgent: new import_https.default.Agent({ keepAlive: true })
|
|
101
|
+
});
|
|
94
102
|
this.deepresearch = {
|
|
95
103
|
create: this._deepresearchCreate.bind(this),
|
|
96
104
|
status: this._deepresearchStatus.bind(this),
|
|
@@ -346,7 +354,7 @@ var Valyu = class {
|
|
|
346
354
|
payload.included_sources = options.includedSources;
|
|
347
355
|
}
|
|
348
356
|
if (options.excludeSources !== void 0) {
|
|
349
|
-
payload.
|
|
357
|
+
payload.excluded_sources = options.excludeSources;
|
|
350
358
|
}
|
|
351
359
|
if (options.sourceBiases !== void 0) {
|
|
352
360
|
payload.source_biases = options.sourceBiases;
|
|
@@ -375,7 +383,7 @@ var Valyu = class {
|
|
|
375
383
|
if (options.instructions !== void 0) {
|
|
376
384
|
payload.instructions = options.instructions;
|
|
377
385
|
}
|
|
378
|
-
const response = await
|
|
386
|
+
const response = await this.client.post(`${this.baseUrl}/search`, payload, {
|
|
379
387
|
headers: this.headers
|
|
380
388
|
});
|
|
381
389
|
if (!response.status || response.status < 200 || response.status >= 300) {
|
|
@@ -531,7 +539,7 @@ var Valyu = class {
|
|
|
531
539
|
if (options.webhookUrl !== void 0) {
|
|
532
540
|
payload.webhook_url = options.webhookUrl;
|
|
533
541
|
}
|
|
534
|
-
const response = await
|
|
542
|
+
const response = await this.client.post(`${this.baseUrl}/contents`, payload, {
|
|
535
543
|
headers: this.headers
|
|
536
544
|
});
|
|
537
545
|
if (!response.status || response.status < 200 || response.status >= 300) {
|
|
@@ -570,7 +578,7 @@ var Valyu = class {
|
|
|
570
578
|
*/
|
|
571
579
|
async getContentsJob(jobId) {
|
|
572
580
|
try {
|
|
573
|
-
const response = await
|
|
581
|
+
const response = await this.client.get(
|
|
574
582
|
`${this.baseUrl}/contents/jobs/${jobId}`,
|
|
575
583
|
{ headers: this.headers }
|
|
576
584
|
);
|
|
@@ -735,7 +743,7 @@ var Valyu = class {
|
|
|
735
743
|
if (options.hitl.outlineReview !== void 0)
|
|
736
744
|
payload.hitl.outline_review = options.hitl.outlineReview;
|
|
737
745
|
}
|
|
738
|
-
const response = await
|
|
746
|
+
const response = await this.client.post(
|
|
739
747
|
`${this.baseUrl}/deepresearch/tasks`,
|
|
740
748
|
payload,
|
|
741
749
|
{ headers: this.headers }
|
|
@@ -753,7 +761,7 @@ var Valyu = class {
|
|
|
753
761
|
*/
|
|
754
762
|
async _deepresearchStatus(taskId) {
|
|
755
763
|
try {
|
|
756
|
-
const response = await
|
|
764
|
+
const response = await this.client.get(
|
|
757
765
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/status`,
|
|
758
766
|
{ headers: this.headers }
|
|
759
767
|
);
|
|
@@ -858,7 +866,7 @@ var Valyu = class {
|
|
|
858
866
|
async _deepresearchList(options) {
|
|
859
867
|
try {
|
|
860
868
|
const limit = options?.limit || 10;
|
|
861
|
-
const response = await
|
|
869
|
+
const response = await this.client.get(
|
|
862
870
|
`${this.baseUrl}/deepresearch/list?limit=${limit}`,
|
|
863
871
|
{ headers: this.headers }
|
|
864
872
|
);
|
|
@@ -881,7 +889,7 @@ var Valyu = class {
|
|
|
881
889
|
error: "instruction is required and cannot be empty"
|
|
882
890
|
};
|
|
883
891
|
}
|
|
884
|
-
const response = await
|
|
892
|
+
const response = await this.client.post(
|
|
885
893
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/update`,
|
|
886
894
|
{ instruction },
|
|
887
895
|
{ headers: this.headers }
|
|
@@ -902,7 +910,7 @@ var Valyu = class {
|
|
|
902
910
|
*/
|
|
903
911
|
async _deepresearchRespond(taskId, interactionId, response) {
|
|
904
912
|
try {
|
|
905
|
-
const resp = await
|
|
913
|
+
const resp = await this.client.post(
|
|
906
914
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/respond`,
|
|
907
915
|
{
|
|
908
916
|
interaction_id: interactionId,
|
|
@@ -962,7 +970,7 @@ var Valyu = class {
|
|
|
962
970
|
*/
|
|
963
971
|
async _deepresearchCancel(taskId) {
|
|
964
972
|
try {
|
|
965
|
-
const response = await
|
|
973
|
+
const response = await this.client.post(
|
|
966
974
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/cancel`,
|
|
967
975
|
{},
|
|
968
976
|
{ headers: this.headers }
|
|
@@ -980,7 +988,7 @@ var Valyu = class {
|
|
|
980
988
|
*/
|
|
981
989
|
async _deepresearchDelete(taskId) {
|
|
982
990
|
try {
|
|
983
|
-
const response = await
|
|
991
|
+
const response = await this.client.delete(
|
|
984
992
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/delete`,
|
|
985
993
|
{ headers: this.headers }
|
|
986
994
|
);
|
|
@@ -997,7 +1005,7 @@ var Valyu = class {
|
|
|
997
1005
|
*/
|
|
998
1006
|
async _deepresearchTogglePublic(taskId, isPublic) {
|
|
999
1007
|
try {
|
|
1000
|
-
const response = await
|
|
1008
|
+
const response = await this.client.post(
|
|
1001
1009
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/public`,
|
|
1002
1010
|
{ public: isPublic },
|
|
1003
1011
|
{ headers: this.headers }
|
|
@@ -1028,7 +1036,7 @@ var Valyu = class {
|
|
|
1028
1036
|
headers["x-api-key"] = this.headers["x-api-key"];
|
|
1029
1037
|
}
|
|
1030
1038
|
const url = `${this.baseUrl}/deepresearch/tasks/${taskId}/assets/${assetId}${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1031
|
-
const response = await
|
|
1039
|
+
const response = await this.client.get(url, {
|
|
1032
1040
|
headers,
|
|
1033
1041
|
responseType: "arraybuffer"
|
|
1034
1042
|
// For binary data
|
|
@@ -1095,7 +1103,7 @@ var Valyu = class {
|
|
|
1095
1103
|
}
|
|
1096
1104
|
if (options.webhookUrl) payload.webhook_url = options.webhookUrl;
|
|
1097
1105
|
if (options.metadata) payload.metadata = options.metadata;
|
|
1098
|
-
const response = await
|
|
1106
|
+
const response = await this.client.post(
|
|
1099
1107
|
`${this.baseUrl}/deepresearch/batches`,
|
|
1100
1108
|
payload,
|
|
1101
1109
|
{ headers: this.headers }
|
|
@@ -1115,7 +1123,7 @@ var Valyu = class {
|
|
|
1115
1123
|
*/
|
|
1116
1124
|
async _batchStatus(batchId) {
|
|
1117
1125
|
try {
|
|
1118
|
-
const response = await
|
|
1126
|
+
const response = await this.client.get(
|
|
1119
1127
|
`${this.baseUrl}/deepresearch/batches/${batchId}`,
|
|
1120
1128
|
{ headers: this.headers }
|
|
1121
1129
|
);
|
|
@@ -1178,7 +1186,7 @@ var Valyu = class {
|
|
|
1178
1186
|
if (task.metadata) taskPayload.metadata = task.metadata;
|
|
1179
1187
|
return taskPayload;
|
|
1180
1188
|
});
|
|
1181
|
-
const response = await
|
|
1189
|
+
const response = await this.client.post(
|
|
1182
1190
|
`${this.baseUrl}/deepresearch/batches/${batchId}/tasks`,
|
|
1183
1191
|
{ tasks: tasksPayload },
|
|
1184
1192
|
{ headers: this.headers }
|
|
@@ -1216,7 +1224,7 @@ var Valyu = class {
|
|
|
1216
1224
|
params.append("include_output", options.includeOutput.toString());
|
|
1217
1225
|
}
|
|
1218
1226
|
const url = `${this.baseUrl}/deepresearch/batches/${batchId}/tasks${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1219
|
-
const response = await
|
|
1227
|
+
const response = await this.client.get(url, { headers: this.headers });
|
|
1220
1228
|
return { success: true, ...response.data };
|
|
1221
1229
|
} catch (e) {
|
|
1222
1230
|
return {
|
|
@@ -1232,7 +1240,7 @@ var Valyu = class {
|
|
|
1232
1240
|
*/
|
|
1233
1241
|
async _batchCancel(batchId) {
|
|
1234
1242
|
try {
|
|
1235
|
-
const response = await
|
|
1243
|
+
const response = await this.client.post(
|
|
1236
1244
|
`${this.baseUrl}/deepresearch/batches/${batchId}/cancel`,
|
|
1237
1245
|
{},
|
|
1238
1246
|
{ headers: this.headers }
|
|
@@ -1258,7 +1266,7 @@ var Valyu = class {
|
|
|
1258
1266
|
params.append("limit", options.limit.toString());
|
|
1259
1267
|
}
|
|
1260
1268
|
const url = `${this.baseUrl}/deepresearch/batches${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1261
|
-
const response = await
|
|
1269
|
+
const response = await this.client.get(url, {
|
|
1262
1270
|
headers: this.headers
|
|
1263
1271
|
});
|
|
1264
1272
|
return { success: true, batches: response.data };
|
|
@@ -1616,7 +1624,7 @@ var Valyu = class {
|
|
|
1616
1624
|
params.append("category", options.category);
|
|
1617
1625
|
}
|
|
1618
1626
|
const url = `${this.baseUrl}/datasources${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1619
|
-
const response = await
|
|
1627
|
+
const response = await this.client.get(url, { headers: this.headers });
|
|
1620
1628
|
return { success: true, datasources: response.data.datasources };
|
|
1621
1629
|
} catch (e) {
|
|
1622
1630
|
return {
|
|
@@ -1631,7 +1639,7 @@ var Valyu = class {
|
|
|
1631
1639
|
*/
|
|
1632
1640
|
async _datasourcesCategories() {
|
|
1633
1641
|
try {
|
|
1634
|
-
const response = await
|
|
1642
|
+
const response = await this.client.get(`${this.baseUrl}/datasources/categories`, {
|
|
1635
1643
|
headers: this.headers
|
|
1636
1644
|
});
|
|
1637
1645
|
return { success: true, categories: response.data.categories };
|