exa-js 2.24.0 → 2.25.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/README.md +8 -0
- package/dist/index.d.mts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.js +29 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fetch2, { Headers } from "cross-fetch";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "exa-js",
|
|
7
|
-
version: "2.
|
|
7
|
+
version: "2.25.0",
|
|
8
8
|
description: "Exa SDK for Node.js and the browser",
|
|
9
9
|
publishConfig: {
|
|
10
10
|
access: "public"
|
|
@@ -2849,30 +2849,27 @@ var Exa2 = class {
|
|
|
2849
2849
|
if (livecrawlTimeout !== void 0)
|
|
2850
2850
|
contentsOptions.livecrawlTimeout = livecrawlTimeout;
|
|
2851
2851
|
if (maxAgeHours !== void 0) contentsOptions.maxAgeHours = maxAgeHours;
|
|
2852
|
-
if (snapshotAsOf !== void 0)
|
|
2853
|
-
contentsOptions.snapshotAsOf = snapshotAsOf;
|
|
2852
|
+
if (snapshotAsOf !== void 0) contentsOptions.snapshotAsOf = snapshotAsOf;
|
|
2854
2853
|
if (context !== void 0) contentsOptions.context = context;
|
|
2855
2854
|
return {
|
|
2856
2855
|
contentsOptions,
|
|
2857
2856
|
restOptions: rest
|
|
2858
2857
|
};
|
|
2859
2858
|
}
|
|
2860
|
-
|
|
2861
|
-
const
|
|
2862
|
-
delete
|
|
2863
|
-
|
|
2859
|
+
mergeSearchRequestBody(body, requestOptions) {
|
|
2860
|
+
const merged = { ...body, ...requestOptions?.body };
|
|
2861
|
+
delete merged.stream;
|
|
2862
|
+
return merged;
|
|
2863
|
+
}
|
|
2864
|
+
buildSearchRequestBody(query, options, requestOptions) {
|
|
2865
|
+
const body = { ...options ?? {} };
|
|
2866
|
+
delete body.betas;
|
|
2864
2867
|
if (options === void 0 || !("contents" in options)) {
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
|
|
2869
|
-
};
|
|
2868
|
+
body.contents = { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } };
|
|
2869
|
+
} else if (options.contents === false || options.contents === null || options.contents === void 0) {
|
|
2870
|
+
delete body.contents;
|
|
2870
2871
|
}
|
|
2871
|
-
|
|
2872
|
-
delete requestOptions.contents;
|
|
2873
|
-
return { query, ...requestOptions };
|
|
2874
|
-
}
|
|
2875
|
-
return { query, ...requestOptions };
|
|
2872
|
+
return this.mergeSearchRequestBody({ query, ...body }, requestOptions);
|
|
2876
2873
|
}
|
|
2877
2874
|
/**
|
|
2878
2875
|
* Makes a request to the Exa API.
|
|
@@ -3007,14 +3004,14 @@ var Exa2 = class {
|
|
|
3007
3004
|
});
|
|
3008
3005
|
return response;
|
|
3009
3006
|
}
|
|
3010
|
-
async search(query, options) {
|
|
3007
|
+
async search(query, options, requestOptions) {
|
|
3011
3008
|
if (options?.stream) {
|
|
3012
3009
|
throw new ExaError(
|
|
3013
3010
|
"For streaming responses, please use streamSearch() instead:\n\nfor await (const chunk of exa.streamSearch(query)) {\n // Handle chunks\n}",
|
|
3014
3011
|
400 /* BadRequest */
|
|
3015
3012
|
);
|
|
3016
3013
|
}
|
|
3017
|
-
const body = this.buildSearchRequestBody(query, options);
|
|
3014
|
+
const body = this.buildSearchRequestBody(query, options, requestOptions);
|
|
3018
3015
|
const betaHeaders = headersForBetas(options?.betas);
|
|
3019
3016
|
return betaHeaders ? await this.request("/search", "POST", body, void 0, betaHeaders) : await this.request("/search", "POST", body);
|
|
3020
3017
|
}
|
|
@@ -3023,10 +3020,11 @@ var Exa2 = class {
|
|
|
3023
3020
|
*
|
|
3024
3021
|
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
3025
3022
|
* Use this if you'd like to read synthesized search output incrementally.
|
|
3023
|
+
* @param {RequestOptions} [requestOptions] - Per-call body overrides.
|
|
3026
3024
|
*/
|
|
3027
|
-
streamSearch(query, options) {
|
|
3025
|
+
streamSearch(query, options, requestOptions) {
|
|
3028
3026
|
return this.streamChatCompletions("/search", {
|
|
3029
|
-
...this.buildSearchRequestBody(query, options),
|
|
3027
|
+
...this.buildSearchRequestBody(query, options, requestOptions),
|
|
3030
3028
|
stream: true
|
|
3031
3029
|
});
|
|
3032
3030
|
}
|
|
@@ -3043,20 +3041,24 @@ var Exa2 = class {
|
|
|
3043
3041
|
*
|
|
3044
3042
|
* @param {string} query - The query string.
|
|
3045
3043
|
* @param {RegularSearchOptions & T} [options] - Additional search + contents options
|
|
3044
|
+
* @param {RequestOptions} [requestOptions] - Per-call body overrides.
|
|
3046
3045
|
* @returns {Promise<SearchResponse<T>>} A list of relevant search results with requested contents.
|
|
3047
3046
|
*/
|
|
3048
|
-
async searchAndContents(query, options) {
|
|
3047
|
+
async searchAndContents(query, options, requestOptions) {
|
|
3049
3048
|
const { contentsOptions, restOptions } = options === void 0 ? {
|
|
3050
3049
|
contentsOptions: {
|
|
3051
3050
|
text: { maxCharacters: DEFAULT_MAX_CHARACTERS }
|
|
3052
3051
|
},
|
|
3053
3052
|
restOptions: {}
|
|
3054
3053
|
} : this.extractContentsOptions(options);
|
|
3055
|
-
return await this.request(
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3054
|
+
return await this.request(
|
|
3055
|
+
"/search",
|
|
3056
|
+
"POST",
|
|
3057
|
+
this.mergeSearchRequestBody(
|
|
3058
|
+
{ query, contents: contentsOptions, ...restOptions },
|
|
3059
|
+
requestOptions
|
|
3060
|
+
)
|
|
3061
|
+
);
|
|
3060
3062
|
}
|
|
3061
3063
|
async findSimilar(url, options) {
|
|
3062
3064
|
if (options === void 0 || !("contents" in options)) {
|