exa-js 1.3.2 → 1.3.4
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.ts +25 -26
- package/dist/index.js +26 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,11 +9,10 @@ declare const isBeta = false;
|
|
|
9
9
|
* @property {string} [endCrawlDate] - End date for results based on crawl date.
|
|
10
10
|
* @property {string} [startPublishedDate] - Start date for results based on published date.
|
|
11
11
|
* @property {string} [endPublishedDate] - End date for results based on published date.
|
|
12
|
-
* @property {boolean} [useAutoprompt] - If true, converts query to a Metaphor query.
|
|
13
|
-
* @property {string} [type] - Type of search, 'keyword' or 'neural'.
|
|
14
12
|
* @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.
|
|
15
13
|
* @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.
|
|
16
14
|
* @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.
|
|
15
|
+
* @property {string[]} [flags] - Experimental flags
|
|
17
16
|
*/
|
|
18
17
|
type BaseSearchOptions = {
|
|
19
18
|
numResults?: number;
|
|
@@ -26,6 +25,7 @@ type BaseSearchOptions = {
|
|
|
26
25
|
category?: string;
|
|
27
26
|
includeText?: string[];
|
|
28
27
|
excludeText?: string[];
|
|
28
|
+
flags?: string[];
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Search options for performing a search query.
|
|
@@ -38,23 +38,14 @@ type RegularSearchOptions = BaseSearchOptions & {
|
|
|
38
38
|
/**
|
|
39
39
|
* Options for finding similar links.
|
|
40
40
|
* @typedef {Object} FindSimilarOptions
|
|
41
|
-
* @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.
|
|
42
|
-
* @property {string[]} [includeDomains] - List of domains to include in the search.
|
|
43
|
-
* @property {string[]} [excludeDomains] - List of domains to exclude from the search.
|
|
44
|
-
* @property {string} [startCrawlDate] - Start date for results based on crawl date.
|
|
45
|
-
* @property {string} [endCrawlDate] - End date for results based on crawl date.
|
|
46
|
-
* @property {string} [startPublishedDate] - Start date for results based on published date.
|
|
47
|
-
* @property {string} [endPublishedDate] - End date for results based on published date.
|
|
48
41
|
* @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.
|
|
49
|
-
* @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.
|
|
50
|
-
* @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.
|
|
51
|
-
* @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.
|
|
52
42
|
*/
|
|
53
43
|
type FindSimilarOptions = BaseSearchOptions & {
|
|
54
44
|
excludeSourceDomain?: boolean;
|
|
55
45
|
};
|
|
56
46
|
type ExtrasOptions = {
|
|
57
|
-
links
|
|
47
|
+
links?: number;
|
|
48
|
+
imageLinks?: number;
|
|
58
49
|
};
|
|
59
50
|
/**
|
|
60
51
|
* Search options for performing a search query.
|
|
@@ -67,7 +58,7 @@ type ExtrasOptions = {
|
|
|
67
58
|
* @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.
|
|
68
59
|
* @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.
|
|
69
60
|
* @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use "about" to get *about* page for websites. Note that this is a fuzzy matcher.
|
|
70
|
-
* @property {ExtrasOptions} [extras] - Miscelleneous data for derived from
|
|
61
|
+
* @property {ExtrasOptions} [extras] - Miscelleneous data for derived from results
|
|
71
62
|
*/
|
|
72
63
|
type ContentsOptions = {
|
|
73
64
|
text?: TextContentsOptions | true;
|
|
@@ -84,7 +75,7 @@ type ContentsOptions = {
|
|
|
84
75
|
* Options for livecrawling contents
|
|
85
76
|
* @typedef {string} LivecrawlOptions
|
|
86
77
|
*/
|
|
87
|
-
type LivecrawlOptions = "never" | "fallback" | "always";
|
|
78
|
+
type LivecrawlOptions = "never" | "fallback" | "always" | "auto";
|
|
88
79
|
/**
|
|
89
80
|
* Options for retrieving text from page.
|
|
90
81
|
* @typedef {Object} TextContentsOptions
|
|
@@ -141,10 +132,12 @@ type SummaryResponse = {
|
|
|
141
132
|
/**
|
|
142
133
|
* @typedef {Object} ExtrasResponse
|
|
143
134
|
* @property {string[]} links - The links on the page of a result
|
|
135
|
+
* @property {string[]} imageLinks - The image links on the page of a result
|
|
144
136
|
*/
|
|
145
137
|
type ExtrasResponse = {
|
|
146
138
|
extras: {
|
|
147
|
-
links
|
|
139
|
+
links?: string[];
|
|
140
|
+
imageLinks?: string[];
|
|
148
141
|
};
|
|
149
142
|
};
|
|
150
143
|
/**
|
|
@@ -180,6 +173,7 @@ type SearchResult<T extends ContentsOptions> = {
|
|
|
180
173
|
score?: number;
|
|
181
174
|
id: string;
|
|
182
175
|
image?: string;
|
|
176
|
+
favicon?: string;
|
|
183
177
|
} & ContentsResultComponent<T>;
|
|
184
178
|
/**
|
|
185
179
|
* Represents a search response object.
|
|
@@ -217,33 +211,38 @@ declare class Exa {
|
|
|
217
211
|
*/
|
|
218
212
|
private request;
|
|
219
213
|
/**
|
|
220
|
-
* Performs a search with
|
|
214
|
+
* Performs a search with an Exa prompt-engineered query.
|
|
221
215
|
* @param {string} query - The query string.
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {Promise<SearchResponse
|
|
216
|
+
* @param {RegularSearchOptions} [options] - Additional search options.
|
|
217
|
+
* @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
|
|
224
218
|
*/
|
|
225
219
|
search(query: string, options?: RegularSearchOptions): Promise<SearchResponse<{}>>;
|
|
226
220
|
/**
|
|
227
|
-
* Performs a search with
|
|
221
|
+
* Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
|
|
228
222
|
* @param {string} query - The query string.
|
|
229
|
-
* @param {
|
|
230
|
-
* @returns {Promise<SearchResponse
|
|
223
|
+
* @param {RegularSearchOptions & T} [options] - Additional search + contents options.
|
|
224
|
+
* @returns {Promise<SearchResponse<T>>} A list of relevant search results.
|
|
231
225
|
*/
|
|
232
226
|
searchAndContents<T extends ContentsOptions>(query: string, options?: RegularSearchOptions & T): Promise<SearchResponse<T>>;
|
|
233
227
|
/**
|
|
234
228
|
* Finds similar links to the provided URL.
|
|
235
229
|
* @param {string} url - The URL for which to find similar links.
|
|
236
230
|
* @param {FindSimilarOptions} [options] - Additional options for finding similar links.
|
|
237
|
-
* @returns {Promise<SearchResponse
|
|
231
|
+
* @returns {Promise<SearchResponse<{}>>} A list of similar search results.
|
|
238
232
|
*/
|
|
239
233
|
findSimilar(url: string, options?: FindSimilarOptions): Promise<SearchResponse<{}>>;
|
|
240
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Finds similar links to the provided URL and returns the contents of the documents.
|
|
236
|
+
* @param {string} url - The URL for which to find similar links.
|
|
237
|
+
* @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
|
|
238
|
+
* @returns {Promise<SearchResponse<T>>} A list of similar search results.
|
|
239
|
+
*/
|
|
241
240
|
findSimilarAndContents<T extends ContentsOptions>(url: string, options?: FindSimilarOptions & T): Promise<SearchResponse<T>>;
|
|
242
241
|
/**
|
|
243
242
|
* Retrieves contents of documents based on a list of document IDs.
|
|
244
|
-
* @param {string | string[] | SearchResult[]} ids - An array of document IDs.
|
|
243
|
+
* @param {string | string[] | SearchResult[]} ids - An array of document IDs (or `SearchResult` objects).
|
|
245
244
|
* @param {ContentsOptions} [options] - Additional options for retrieving document contents.
|
|
246
|
-
* @returns {Promise<
|
|
245
|
+
* @returns {Promise<SearchResponse<T>>} A list of document contents.
|
|
247
246
|
*/
|
|
248
247
|
getContents<T extends ContentsOptions>(ids: string | string[] | SearchResult<T>[], options?: T): Promise<SearchResponse<T>>;
|
|
249
248
|
}
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,17 @@ module.exports = __toCommonJS(src_exports);
|
|
|
36
36
|
var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
37
37
|
var Exa = class {
|
|
38
38
|
extractContentsOptions(options) {
|
|
39
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
text,
|
|
41
|
+
highlights,
|
|
42
|
+
summary,
|
|
43
|
+
subpages,
|
|
44
|
+
subpageTarget,
|
|
45
|
+
extras,
|
|
46
|
+
livecrawl,
|
|
47
|
+
livecrawlTimeout,
|
|
48
|
+
...rest
|
|
49
|
+
} = options;
|
|
40
50
|
const contentsOptions = {};
|
|
41
51
|
if (text === void 0 && summary === void 0 && highlights === void 0 && extras === void 0)
|
|
42
52
|
contentsOptions.text = true;
|
|
@@ -104,19 +114,19 @@ var Exa = class {
|
|
|
104
114
|
return await response.json();
|
|
105
115
|
}
|
|
106
116
|
/**
|
|
107
|
-
* Performs a search with
|
|
117
|
+
* Performs a search with an Exa prompt-engineered query.
|
|
108
118
|
* @param {string} query - The query string.
|
|
109
|
-
* @param {
|
|
110
|
-
* @returns {Promise<SearchResponse
|
|
119
|
+
* @param {RegularSearchOptions} [options] - Additional search options.
|
|
120
|
+
* @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
|
|
111
121
|
*/
|
|
112
122
|
async search(query, options) {
|
|
113
123
|
return await this.request("/search", "POST", { query, ...options });
|
|
114
124
|
}
|
|
115
125
|
/**
|
|
116
|
-
* Performs a search with
|
|
126
|
+
* Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
|
|
117
127
|
* @param {string} query - The query string.
|
|
118
|
-
* @param {
|
|
119
|
-
* @returns {Promise<SearchResponse
|
|
128
|
+
* @param {RegularSearchOptions & T} [options] - Additional search + contents options.
|
|
129
|
+
* @returns {Promise<SearchResponse<T>>} A list of relevant search results.
|
|
120
130
|
*/
|
|
121
131
|
async searchAndContents(query, options) {
|
|
122
132
|
const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
|
|
@@ -130,12 +140,17 @@ var Exa = class {
|
|
|
130
140
|
* Finds similar links to the provided URL.
|
|
131
141
|
* @param {string} url - The URL for which to find similar links.
|
|
132
142
|
* @param {FindSimilarOptions} [options] - Additional options for finding similar links.
|
|
133
|
-
* @returns {Promise<SearchResponse
|
|
143
|
+
* @returns {Promise<SearchResponse<{}>>} A list of similar search results.
|
|
134
144
|
*/
|
|
135
145
|
async findSimilar(url, options) {
|
|
136
146
|
return await this.request("/findSimilar", "POST", { url, ...options });
|
|
137
147
|
}
|
|
138
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Finds similar links to the provided URL and returns the contents of the documents.
|
|
150
|
+
* @param {string} url - The URL for which to find similar links.
|
|
151
|
+
* @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
|
|
152
|
+
* @returns {Promise<SearchResponse<T>>} A list of similar search results.
|
|
153
|
+
*/
|
|
139
154
|
async findSimilarAndContents(url, options) {
|
|
140
155
|
const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
|
|
141
156
|
return await this.request("/findSimilar", "POST", {
|
|
@@ -146,9 +161,9 @@ var Exa = class {
|
|
|
146
161
|
}
|
|
147
162
|
/**
|
|
148
163
|
* Retrieves contents of documents based on a list of document IDs.
|
|
149
|
-
* @param {string | string[] | SearchResult[]} ids - An array of document IDs.
|
|
164
|
+
* @param {string | string[] | SearchResult[]} ids - An array of document IDs (or `SearchResult` objects).
|
|
150
165
|
* @param {ContentsOptions} [options] - Additional options for retrieving document contents.
|
|
151
|
-
* @returns {Promise<
|
|
166
|
+
* @returns {Promise<SearchResponse<T>>} A list of document contents.
|
|
152
167
|
*/
|
|
153
168
|
async getContents(ids, options) {
|
|
154
169
|
if (ids.length === 0) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fetch, { Headers } from \"cross-fetch\";\n\nconst isBeta = false;\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} SearchOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude in the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {boolean} [useAutoprompt] - If true, converts query to a Metaphor query.\n * @property {string} [type] - Type of search, 'keyword' or 'neural'.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n */\nexport type BaseSearchOptions = {\n numResults?: number;\n includeDomains?: string[];\n excludeDomains?: string[];\n startCrawlDate?: string;\n endCrawlDate?: string;\n startPublishedDate?: string;\n endPublishedDate?: string;\n category?: string;\n includeText?: string[];\n excludeText?: string[];\n};\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} RegularSearchOptions\n */\nexport type RegularSearchOptions = BaseSearchOptions & {\n useAutoprompt?: boolean;\n type?: string;\n};\n\n/**\n * Options for finding similar links.\n * @typedef {Object} FindSimilarOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude from the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n */\nexport type FindSimilarOptions = BaseSearchOptions & {\n excludeSourceDomain?: boolean;\n};\n\nexport type ExtrasOptions = {links: number}\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} ContentsOptions\n * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.\n * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights.\n * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.\n * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is \"never\" for neural/auto search, \"fallback\" for keyword search.\n * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.\n * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.\n * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.\n * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use \"about\" to get *about* page for websites. Note that this is a fuzzy matcher.\n * @property {ExtrasOptions} [extras] - Miscelleneous data for derived from resutls\n */\nexport type ContentsOptions = {\n text?: TextContentsOptions | true; \n highlights?: HighlightsContentsOptions | true;\n summary?: SummaryContentsOptions | true;\n livecrawl?: LivecrawlOptions;\n livecrawlTimeout?: number;\n filterEmptyResults?: boolean;\n subpages?: number\n subpageTarget?: string | string[]\n extras?: ExtrasOptions\n} & (typeof isBeta extends true ? {} : {}); // FOR BETA OPTIONS\n\n\n/**\n * Options for livecrawling contents\n * @typedef {string} LivecrawlOptions\n */\nexport type LivecrawlOptions = \"never\" | \"fallback\" | \"always\";\n\n/**\n * Options for retrieving text from page.\n * @typedef {Object} TextContentsOptions\n * @property {number} [maxCharacters] - The maximum number of characters to return.\n * @property {boolean} [includeHtmlTags] - If true, includes HTML tags in the returned text. Default: false\n */\nexport type TextContentsOptions = {\n maxCharacters?: number;\n includeHtmlTags?: boolean;\n};\n\n/**\n * Options for retrieving highlights from page.\n * @typedef {Object} HighlightsContentsOptions\n * @property {string} [query] - The query string to use for highlights search.\n * @property {number} [numSentences] - The number of sentences to return for each highlight.\n * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.\n */\nexport type HighlightsContentsOptions = {\n query?: string;\n numSentences?: number;\n highlightsPerUrl?: number;\n};\n\n/**\n * Options for retrieving summary from page.\n * @typedef {Object} SummaryContentsOptions\n * @property {string} [query] - The query string to use for summary generation.\n */\nexport type SummaryContentsOptions = {\n query?: string;\n};\n\n/**\n * @typedef {Object} TextResponse\n * @property {string} text - Text from page\n */\nexport type TextResponse = { text: string };\n\n/**\n * @typedef {Object} HighlightsResponse\n * @property {string[]} highlights - The highlights as an array of strings.\n * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1\n */\nexport type HighlightsResponse = {\n highlights: string[];\n highlightScores: number[];\n};\n\n/**\n * @typedef {Object} SummaryResponse\n * @property {string} summary - The generated summary of the page content.\n */\nexport type SummaryResponse = { summary: string };\n\n/**\n * @typedef {Object} ExtrasResponse\n * @property {string[]} links - The links on the page of a result\n */\nexport type ExtrasResponse = { extras: { links: string[] } };\n\n/**\n * @typedef {Object} SubpagesResponse\n * @property {ContentsResultComponent<T extends ContentsOptions>} subpages - The links on the page of a result\n */\nexport type SubpagesResponse<T extends ContentsOptions> = {subpages: ContentsResultComponent<T>[]}\n\n\n\nexport type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;\n\n/**\n * @typedef {Object} ContentsResultComponent\n * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.\n *\n * @template T - A type extending from 'ContentsOptions'.\n */\nexport type ContentsResultComponent<T extends ContentsOptions> = Default< \n (T[\"text\"] extends object | true ? TextResponse : {}) &\n (T[\"highlights\"] extends object | true ? HighlightsResponse : {}) &\n (T[\"summary\"] extends object | true ? SummaryResponse : {}) &\n (T[\"subpages\"] extends number ? SubpagesResponse<T> : {}) &\n (T[\"extras\"] extends object ? ExtrasResponse : {} ),\n TextResponse\n>;\n\n/**\n * Represents a search result object.\n * @typedef {Object} SearchResult\n * @property {string} title - The title of the search result.\n * @property {string} url - The URL of the search result.\n * @property {string} [publishedDate] - The estimated creation date of the content.\n * @property {string} [author] - The author of the content, if available.\n * @property {number} [score] - Similarity score between the query/url and the result.\n * @property {string} id - The temporary ID for the document.\n */\nexport type SearchResult<T extends ContentsOptions> = {\n title: string | null;\n url: string;\n publishedDate?: string;\n author?: string;\n score?: number;\n id: string;\n image?: string;\n} & ContentsResultComponent<T>;\n\n/**\n * Represents a search response object.\n * @typedef {Object} SearchResponse\n * @property {Result[]} results - The list of search results.\n * @property {string} [autopromptString] - The autoprompt string, if applicable.\n * @property {string} [autoDate] - The autoprompt date, if applicable.\n * @property {string} requestId - The request ID for the search.\n */\nexport type SearchResponse<T extends ContentsOptions> = {\n results: SearchResult<T>[];\n autopromptString?: string;\n autoDate?: string;\n requestId: string;\n};\n\n/**\n * The Exa class encapsulates the API's endpoints.\n */\nclass Exa {\n private baseURL: string;\n private headers: Headers;\n\n private extractContentsOptions<T extends ContentsOptions>(options: T): {\n contentsOptions: ContentsOptions;\n restOptions: Omit<T, keyof ContentsOptions>;\n } {\n\n const { text, highlights, summary, subpages, subpageTarget, extras, livecrawl, livecrawlTimeout, ...rest } = options;\n\n const contentsOptions: ContentsOptions = {};\n // don't send text if it's explicitly false\n if (text === undefined && summary === undefined && highlights === undefined && extras === undefined) contentsOptions.text = true\n if (text !== undefined) contentsOptions.text = text\n\n if (summary !== undefined) contentsOptions.summary = summary;\n if (highlights !== undefined) contentsOptions.highlights = highlights;\n\n if (subpages !== undefined) contentsOptions.subpages = subpages;\n if (subpageTarget !== undefined) contentsOptions.subpageTarget = subpageTarget;\n\n if (extras !== undefined) contentsOptions.extras = extras;\n if (livecrawl !== undefined) contentsOptions.livecrawl = livecrawl;\n if (livecrawlTimeout !== undefined) contentsOptions.livecrawlTimeout = livecrawlTimeout;\n\n return {\n contentsOptions: contentsOptions,\n restOptions: rest as Omit<T, keyof ContentsOptions>\n };\n }\n\n /**\n * Constructs the Exa API client.\n * @param {string} apiKey - The API key for authentication.\n * @param {string} [baseURL] - The base URL of the Exa API.\n */\n constructor(apiKey?: string, baseURL: string = \"https://api.exa.ai\") {\n this.baseURL = baseURL;\n if (!apiKey) {\n apiKey = process.env.EXASEARCH_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)\",\n );\n }\n }\n this.headers = new Headers({\n \"x-api-key\": apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"exa-node 1.3.2\",\n });\n }\n\n /**\n * Makes a request to the Exa API.\n * @param {string} endpoint - The API endpoint to call.\n * @param {string} method - The HTTP method to use.\n * @param {any} [body] - The request body for POST requests.\n * @returns {Promise<any>} The response from the API.\n */\n private async request(\n endpoint: string,\n method: string,\n body?: any,\n ): Promise<any> {\n const response = await fetch(this.baseURL + endpoint, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const message = (await response.json()).error;\n throw new Error(\n `Request failed with status ${response.status}. ${message}`,\n );\n }\n\n return await response.json();\n }\n\n\n /**\n * Performs a search with a Exa prompt-engineered query.\n * @param {string} query - The query string.\n * @param {SearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse>} A list of relevant search results.\n */\n async search(\n query: string,\n options?: RegularSearchOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/search\", \"POST\", { query, ...options });\n }\n\n /**\n * Performs a search with a Exa prompt-engineered query and returns the contents of the documents.\n * @param {string} query - The query string.\n * @param {SearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse>} A list of relevant search results.\n */\n async searchAndContents<T extends ContentsOptions>(\n query: string,\n options?: RegularSearchOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } = options === undefined ? \n { contentsOptions: { text: true }, restOptions: {}} :\n this.extractContentsOptions(options);\n\n return await this.request(\"/search\", \"POST\", {\n query,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Finds similar links to the provided URL.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions} [options] - Additional options for finding similar links.\n * @returns {Promise<SearchResponse>} A list of similar search results.\n */\n async findSimilar(\n url: string,\n options?: FindSimilarOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/findSimilar\", \"POST\", { url, ...options });\n }\n\n /** Finds similar links to the provided URL and returns the contents of the documents. @param {string} url - The URL for which to find similar links. @param {FindSimilarOptions} [options] - Additional options for finding similar links. @returns {Promise<SearchResponse>} A list of similar search results. */ \n async findSimilarAndContents<T extends ContentsOptions>(\n url: string,\n options?: FindSimilarOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } = options === undefined ?\n {contentsOptions: {text: true}, restOptions: {}} :\n this.extractContentsOptions(options);\n \n return await this.request(\"/findSimilar\", \"POST\", {\n url,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Retrieves contents of documents based on a list of document IDs.\n * @param {string | string[] | SearchResult[]} ids - An array of document IDs.\n * @param {ContentsOptions} [options] - Additional options for retrieving document contents.\n * @returns {Promise<GetContentsResponse>} A list of document contents.\n */\n async getContents<T extends ContentsOptions>(\n ids: string | string[] | SearchResult<T>[],\n options?: T,\n ): Promise<SearchResponse<T>> {\n if (ids.length === 0) {\n throw new Error(\"Must provide at least one ID\");\n }\n let requestIds: string[];\n if (typeof ids === \"string\") {\n requestIds = [ids];\n } else if (typeof ids[0] === \"string\") {\n requestIds = ids as string[];\n } else {\n requestIds = (ids as SearchResult<T>[]).map((result) => result.id);\n }\n return await this.request(`/contents`, \"POST\", {\n ids: requestIds,\n ...options,\n });\n }\n}\n\nexport default Exa;\n"],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AAA,EAQA,MAAM,YACJ,KACA,SAC4B;AAC5B,QAAI,IAAI,WAAW,GAAG;AACpB,YAAM,IAAI,MAAM,8BAA8B;AAAA,IAChD;AACA,QAAI;AACJ,QAAI,OAAO,QAAQ,UAAU;AAC3B,mBAAa,CAAC,GAAG;AAAA,IACnB,WAAW,OAAO,IAAI,CAAC,MAAM,UAAU;AACrC,mBAAa;AAAA,IACf,OAAO;AACL,mBAAc,IAA0B,IAAI,CAAC,WAAW,OAAO,EAAE;AAAA,IACnE;AACA,WAAO,MAAM,KAAK,QAAQ,aAAa,QAAQ;AAAA,MAC7C,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAEA,IAAO,cAAQ;","names":["fetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fetch, { Headers } from \"cross-fetch\";\n\nconst isBeta = false;\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} SearchOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude in the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [flags] - Experimental flags\n */\nexport type BaseSearchOptions = {\n numResults?: number;\n includeDomains?: string[];\n excludeDomains?: string[];\n startCrawlDate?: string;\n endCrawlDate?: string;\n startPublishedDate?: string;\n endPublishedDate?: string;\n category?: string;\n includeText?: string[];\n excludeText?: string[];\n flags?: string[];\n};\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} RegularSearchOptions\n */\nexport type RegularSearchOptions = BaseSearchOptions & {\n useAutoprompt?: boolean;\n type?: string;\n};\n\n/**\n * Options for finding similar links.\n * @typedef {Object} FindSimilarOptions\n * @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.\n */\nexport type FindSimilarOptions = BaseSearchOptions & {\n excludeSourceDomain?: boolean;\n};\n\nexport type ExtrasOptions = { links?: number; imageLinks?: number };\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} ContentsOptions\n * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.\n * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights.\n * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.\n * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is \"never\" for neural/auto search, \"fallback\" for keyword search.\n * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.\n * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.\n * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.\n * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use \"about\" to get *about* page for websites. Note that this is a fuzzy matcher.\n * @property {ExtrasOptions} [extras] - Miscelleneous data for derived from results\n */\nexport type ContentsOptions = {\n text?: TextContentsOptions | true;\n highlights?: HighlightsContentsOptions | true;\n summary?: SummaryContentsOptions | true;\n livecrawl?: LivecrawlOptions;\n livecrawlTimeout?: number;\n filterEmptyResults?: boolean;\n subpages?: number;\n subpageTarget?: string | string[];\n extras?: ExtrasOptions;\n} & (typeof isBeta extends true ? {} : {});\n\n/**\n * Options for livecrawling contents\n * @typedef {string} LivecrawlOptions\n */\nexport type LivecrawlOptions = \"never\" | \"fallback\" | \"always\" | \"auto\";\n\n/**\n * Options for retrieving text from page.\n * @typedef {Object} TextContentsOptions\n * @property {number} [maxCharacters] - The maximum number of characters to return.\n * @property {boolean} [includeHtmlTags] - If true, includes HTML tags in the returned text. Default: false\n */\nexport type TextContentsOptions = {\n maxCharacters?: number;\n includeHtmlTags?: boolean;\n};\n\n/**\n * Options for retrieving highlights from page.\n * @typedef {Object} HighlightsContentsOptions\n * @property {string} [query] - The query string to use for highlights search.\n * @property {number} [numSentences] - The number of sentences to return for each highlight.\n * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.\n */\nexport type HighlightsContentsOptions = {\n query?: string;\n numSentences?: number;\n highlightsPerUrl?: number;\n};\n\n/**\n * Options for retrieving summary from page.\n * @typedef {Object} SummaryContentsOptions\n * @property {string} [query] - The query string to use for summary generation.\n */\nexport type SummaryContentsOptions = {\n query?: string;\n};\n\n/**\n * @typedef {Object} TextResponse\n * @property {string} text - Text from page\n */\nexport type TextResponse = { text: string };\n\n/**\n * @typedef {Object} HighlightsResponse\n * @property {string[]} highlights - The highlights as an array of strings.\n * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1\n */\nexport type HighlightsResponse = {\n highlights: string[];\n highlightScores: number[];\n};\n\n/**\n * @typedef {Object} SummaryResponse\n * @property {string} summary - The generated summary of the page content.\n */\nexport type SummaryResponse = { summary: string };\n\n/**\n * @typedef {Object} ExtrasResponse\n * @property {string[]} links - The links on the page of a result\n * @property {string[]} imageLinks - The image links on the page of a result\n */\nexport type ExtrasResponse = { extras: { links?: string[]; imageLinks?: string[] } };\n\n/**\n * @typedef {Object} SubpagesResponse\n * @property {ContentsResultComponent<T extends ContentsOptions>} subpages - The links on the page of a result\n */\nexport type SubpagesResponse<T extends ContentsOptions> = {\n subpages: ContentsResultComponent<T>[];\n};\n\nexport type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;\n\n/**\n * @typedef {Object} ContentsResultComponent\n * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.\n *\n * @template T - A type extending from 'ContentsOptions'.\n */\nexport type ContentsResultComponent<T extends ContentsOptions> = Default<\n (T[\"text\"] extends object | true ? TextResponse : {}) &\n (T[\"highlights\"] extends object | true ? HighlightsResponse : {}) &\n (T[\"summary\"] extends object | true ? SummaryResponse : {}) &\n (T[\"subpages\"] extends number ? SubpagesResponse<T> : {}) &\n (T[\"extras\"] extends object ? ExtrasResponse : {}),\n TextResponse\n>;\n\n/**\n * Represents a search result object.\n * @typedef {Object} SearchResult\n * @property {string} title - The title of the search result.\n * @property {string} url - The URL of the search result.\n * @property {string} [publishedDate] - The estimated creation date of the content.\n * @property {string} [author] - The author of the content, if available.\n * @property {number} [score] - Similarity score between the query/url and the result.\n * @property {string} id - The temporary ID for the document.\n */\nexport type SearchResult<T extends ContentsOptions> = {\n title: string | null;\n url: string;\n publishedDate?: string;\n author?: string;\n score?: number;\n id: string;\n image?: string;\n favicon?: string;\n} & ContentsResultComponent<T>;\n\n/**\n * Represents a search response object.\n * @typedef {Object} SearchResponse\n * @property {Result[]} results - The list of search results.\n * @property {string} [autopromptString] - The autoprompt string, if applicable.\n * @property {string} [autoDate] - The autoprompt date, if applicable.\n * @property {string} requestId - The request ID for the search.\n */\nexport type SearchResponse<T extends ContentsOptions> = {\n results: SearchResult<T>[];\n autopromptString?: string;\n autoDate?: string;\n requestId: string;\n};\n\n/**\n * The Exa class encapsulates the API's endpoints.\n */\nclass Exa {\n private baseURL: string;\n private headers: Headers;\n\n private extractContentsOptions<T extends ContentsOptions>(options: T): {\n contentsOptions: ContentsOptions;\n restOptions: Omit<T, keyof ContentsOptions>;\n } {\n const {\n text,\n highlights,\n summary,\n subpages,\n subpageTarget,\n extras,\n livecrawl,\n livecrawlTimeout,\n ...rest\n } = options;\n\n const contentsOptions: ContentsOptions = {};\n // don't send text if it's explicitly false\n if (\n text === undefined &&\n summary === undefined &&\n highlights === undefined &&\n extras === undefined\n )\n contentsOptions.text = true;\n if (text !== undefined) contentsOptions.text = text;\n\n if (summary !== undefined) contentsOptions.summary = summary;\n if (highlights !== undefined) contentsOptions.highlights = highlights;\n\n if (subpages !== undefined) contentsOptions.subpages = subpages;\n if (subpageTarget !== undefined)\n contentsOptions.subpageTarget = subpageTarget;\n\n if (extras !== undefined) contentsOptions.extras = extras;\n if (livecrawl !== undefined) contentsOptions.livecrawl = livecrawl;\n if (livecrawlTimeout !== undefined)\n contentsOptions.livecrawlTimeout = livecrawlTimeout;\n\n return {\n contentsOptions: contentsOptions,\n restOptions: rest as Omit<T, keyof ContentsOptions>,\n };\n }\n\n /**\n * Constructs the Exa API client.\n * @param {string} apiKey - The API key for authentication.\n * @param {string} [baseURL] - The base URL of the Exa API.\n */\n constructor(apiKey?: string, baseURL: string = \"https://api.exa.ai\") {\n this.baseURL = baseURL;\n if (!apiKey) {\n apiKey = process.env.EXASEARCH_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)\",\n );\n }\n }\n this.headers = new Headers({\n \"x-api-key\": apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"exa-node 1.3.2\",\n });\n }\n\n /**\n * Makes a request to the Exa API.\n * @param {string} endpoint - The API endpoint to call.\n * @param {string} method - The HTTP method to use.\n * @param {any} [body] - The request body for POST requests.\n * @returns {Promise<any>} The response from the API.\n */\n private async request(\n endpoint: string,\n method: string,\n body?: any,\n ): Promise<any> {\n const response = await fetch(this.baseURL + endpoint, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const message = (await response.json()).error;\n throw new Error(\n `Request failed with status ${response.status}. ${message}`,\n );\n }\n\n return await response.json();\n }\n\n /**\n * Performs a search with an Exa prompt-engineered query.\n * @param {string} query - The query string.\n * @param {RegularSearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse<{}>>} A list of relevant search results.\n */\n async search(\n query: string,\n options?: RegularSearchOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/search\", \"POST\", { query, ...options });\n }\n\n /**\n * Performs a search with an Exa prompt-engineered query and returns the contents of the documents.\n * @param {string} query - The query string.\n * @param {RegularSearchOptions & T} [options] - Additional search + contents options.\n * @returns {Promise<SearchResponse<T>>} A list of relevant search results.\n */\n async searchAndContents<T extends ContentsOptions>(\n query: string,\n options?: RegularSearchOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } =\n options === undefined\n ? { contentsOptions: { text: true }, restOptions: {} }\n : this.extractContentsOptions(options);\n\n return await this.request(\"/search\", \"POST\", {\n query,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Finds similar links to the provided URL.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions} [options] - Additional options for finding similar links.\n * @returns {Promise<SearchResponse<{}>>} A list of similar search results.\n */\n async findSimilar(\n url: string,\n options?: FindSimilarOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/findSimilar\", \"POST\", { url, ...options });\n }\n\n /**\n * Finds similar links to the provided URL and returns the contents of the documents.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.\n * @returns {Promise<SearchResponse<T>>} A list of similar search results.\n */\n async findSimilarAndContents<T extends ContentsOptions>(\n url: string,\n options?: FindSimilarOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } =\n options === undefined\n ? { contentsOptions: { text: true }, restOptions: {} }\n : this.extractContentsOptions(options);\n\n return await this.request(\"/findSimilar\", \"POST\", {\n url,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Retrieves contents of documents based on a list of document IDs.\n * @param {string | string[] | SearchResult[]} ids - An array of document IDs (or `SearchResult` objects).\n * @param {ContentsOptions} [options] - Additional options for retrieving document contents.\n * @returns {Promise<SearchResponse<T>>} A list of document contents.\n */\n async getContents<T extends ContentsOptions>(\n ids: string | string[] | SearchResult<T>[],\n options?: T,\n ): Promise<SearchResponse<T>> {\n if (ids.length === 0) {\n throw new Error(\"Must provide at least one ID\");\n }\n let requestIds: string[];\n if (typeof ids === \"string\") {\n requestIds = [ids];\n } else if (typeof ids[0] === \"string\") {\n requestIds = ids as string[];\n } else {\n requestIds = (ids as SearchResult<T>[]).map((result) => result.id);\n }\n return await this.request(`/contents`, \"POST\", {\n ids: requestIds,\n ...options,\n });\n }\n}\n\nexport default Exa;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA+B;AAkN/B,IAAM,MAAN,MAAU;AAAA,EAIA,uBAAkD,SAGxD;AACA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,kBAAmC,CAAC;AAE1C,QACE,SAAS,UACT,YAAY,UACZ,eAAe,UACf,WAAW;AAEX,sBAAgB,OAAO;AACzB,QAAI,SAAS;AAAW,sBAAgB,OAAO;AAE/C,QAAI,YAAY;AAAW,sBAAgB,UAAU;AACrD,QAAI,eAAe;AAAW,sBAAgB,aAAa;AAE3D,QAAI,aAAa;AAAW,sBAAgB,WAAW;AACvD,QAAI,kBAAkB;AACpB,sBAAgB,gBAAgB;AAElC,QAAI,WAAW;AAAW,sBAAgB,SAAS;AACnD,QAAI,cAAc;AAAW,sBAAgB,YAAY;AACzD,QAAI,qBAAqB;AACvB,sBAAgB,mBAAmB;AAErC,WAAO;AAAA,MACL;AAAA,MACA,aAAa;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,QAAiB,UAAkB,sBAAsB;AACnE,SAAK,UAAU;AACf,QAAI,CAAC,QAAQ;AACX,eAAS,QAAQ,IAAI;AACrB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,SAAK,UAAU,IAAI,2BAAQ;AAAA,MACzB,aAAa;AAAA,MACb,gBAAgB;AAAA,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,SACR,EAAE,iBAAiB,EAAE,MAAM,KAAK,GAAG,aAAa,CAAC,EAAE,IACnD,KAAK,uBAAuB,OAAO;AAEzC,WAAO,MAAM,KAAK,QAAQ,gBAAgB,QAAQ;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YACJ,KACA,SAC4B;AAC5B,QAAI,IAAI,WAAW,GAAG;AACpB,YAAM,IAAI,MAAM,8BAA8B;AAAA,IAChD;AACA,QAAI;AACJ,QAAI,OAAO,QAAQ,UAAU;AAC3B,mBAAa,CAAC,GAAG;AAAA,IACnB,WAAW,OAAO,IAAI,CAAC,MAAM,UAAU;AACrC,mBAAa;AAAA,IACf,OAAO;AACL,mBAAc,IAA0B,IAAI,CAAC,WAAW,OAAO,EAAE;AAAA,IACnE;AACA,WAAO,MAAM,KAAK,QAAQ,aAAa,QAAQ;AAAA,MAC7C,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAEA,IAAO,cAAQ;","names":["fetch"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
import fetch, { Headers } from "cross-fetch";
|
|
3
3
|
var Exa = class {
|
|
4
4
|
extractContentsOptions(options) {
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
text,
|
|
7
|
+
highlights,
|
|
8
|
+
summary,
|
|
9
|
+
subpages,
|
|
10
|
+
subpageTarget,
|
|
11
|
+
extras,
|
|
12
|
+
livecrawl,
|
|
13
|
+
livecrawlTimeout,
|
|
14
|
+
...rest
|
|
15
|
+
} = options;
|
|
6
16
|
const contentsOptions = {};
|
|
7
17
|
if (text === void 0 && summary === void 0 && highlights === void 0 && extras === void 0)
|
|
8
18
|
contentsOptions.text = true;
|
|
@@ -70,19 +80,19 @@ var Exa = class {
|
|
|
70
80
|
return await response.json();
|
|
71
81
|
}
|
|
72
82
|
/**
|
|
73
|
-
* Performs a search with
|
|
83
|
+
* Performs a search with an Exa prompt-engineered query.
|
|
74
84
|
* @param {string} query - The query string.
|
|
75
|
-
* @param {
|
|
76
|
-
* @returns {Promise<SearchResponse
|
|
85
|
+
* @param {RegularSearchOptions} [options] - Additional search options.
|
|
86
|
+
* @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
|
|
77
87
|
*/
|
|
78
88
|
async search(query, options) {
|
|
79
89
|
return await this.request("/search", "POST", { query, ...options });
|
|
80
90
|
}
|
|
81
91
|
/**
|
|
82
|
-
* Performs a search with
|
|
92
|
+
* Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
|
|
83
93
|
* @param {string} query - The query string.
|
|
84
|
-
* @param {
|
|
85
|
-
* @returns {Promise<SearchResponse
|
|
94
|
+
* @param {RegularSearchOptions & T} [options] - Additional search + contents options.
|
|
95
|
+
* @returns {Promise<SearchResponse<T>>} A list of relevant search results.
|
|
86
96
|
*/
|
|
87
97
|
async searchAndContents(query, options) {
|
|
88
98
|
const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
|
|
@@ -96,12 +106,17 @@ var Exa = class {
|
|
|
96
106
|
* Finds similar links to the provided URL.
|
|
97
107
|
* @param {string} url - The URL for which to find similar links.
|
|
98
108
|
* @param {FindSimilarOptions} [options] - Additional options for finding similar links.
|
|
99
|
-
* @returns {Promise<SearchResponse
|
|
109
|
+
* @returns {Promise<SearchResponse<{}>>} A list of similar search results.
|
|
100
110
|
*/
|
|
101
111
|
async findSimilar(url, options) {
|
|
102
112
|
return await this.request("/findSimilar", "POST", { url, ...options });
|
|
103
113
|
}
|
|
104
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Finds similar links to the provided URL and returns the contents of the documents.
|
|
116
|
+
* @param {string} url - The URL for which to find similar links.
|
|
117
|
+
* @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
|
|
118
|
+
* @returns {Promise<SearchResponse<T>>} A list of similar search results.
|
|
119
|
+
*/
|
|
105
120
|
async findSimilarAndContents(url, options) {
|
|
106
121
|
const { contentsOptions, restOptions } = options === void 0 ? { contentsOptions: { text: true }, restOptions: {} } : this.extractContentsOptions(options);
|
|
107
122
|
return await this.request("/findSimilar", "POST", {
|
|
@@ -112,9 +127,9 @@ var Exa = class {
|
|
|
112
127
|
}
|
|
113
128
|
/**
|
|
114
129
|
* Retrieves contents of documents based on a list of document IDs.
|
|
115
|
-
* @param {string | string[] | SearchResult[]} ids - An array of document IDs.
|
|
130
|
+
* @param {string | string[] | SearchResult[]} ids - An array of document IDs (or `SearchResult` objects).
|
|
116
131
|
* @param {ContentsOptions} [options] - Additional options for retrieving document contents.
|
|
117
|
-
* @returns {Promise<
|
|
132
|
+
* @returns {Promise<SearchResponse<T>>} A list of document contents.
|
|
118
133
|
*/
|
|
119
134
|
async getContents(ids, options) {
|
|
120
135
|
if (ids.length === 0) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fetch, { Headers } from \"cross-fetch\";\n\nconst isBeta = false;\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} SearchOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude in the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {boolean} [useAutoprompt] - If true, converts query to a Metaphor query.\n * @property {string} [type] - Type of search, 'keyword' or 'neural'.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n */\nexport type BaseSearchOptions = {\n numResults?: number;\n includeDomains?: string[];\n excludeDomains?: string[];\n startCrawlDate?: string;\n endCrawlDate?: string;\n startPublishedDate?: string;\n endPublishedDate?: string;\n category?: string;\n includeText?: string[];\n excludeText?: string[];\n};\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} RegularSearchOptions\n */\nexport type RegularSearchOptions = BaseSearchOptions & {\n useAutoprompt?: boolean;\n type?: string;\n};\n\n/**\n * Options for finding similar links.\n * @typedef {Object} FindSimilarOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude from the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n */\nexport type FindSimilarOptions = BaseSearchOptions & {\n excludeSourceDomain?: boolean;\n};\n\nexport type ExtrasOptions = {links: number}\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} ContentsOptions\n * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.\n * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights.\n * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.\n * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is \"never\" for neural/auto search, \"fallback\" for keyword search.\n * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.\n * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.\n * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.\n * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use \"about\" to get *about* page for websites. Note that this is a fuzzy matcher.\n * @property {ExtrasOptions} [extras] - Miscelleneous data for derived from resutls\n */\nexport type ContentsOptions = {\n text?: TextContentsOptions | true; \n highlights?: HighlightsContentsOptions | true;\n summary?: SummaryContentsOptions | true;\n livecrawl?: LivecrawlOptions;\n livecrawlTimeout?: number;\n filterEmptyResults?: boolean;\n subpages?: number\n subpageTarget?: string | string[]\n extras?: ExtrasOptions\n} & (typeof isBeta extends true ? {} : {}); // FOR BETA OPTIONS\n\n\n/**\n * Options for livecrawling contents\n * @typedef {string} LivecrawlOptions\n */\nexport type LivecrawlOptions = \"never\" | \"fallback\" | \"always\";\n\n/**\n * Options for retrieving text from page.\n * @typedef {Object} TextContentsOptions\n * @property {number} [maxCharacters] - The maximum number of characters to return.\n * @property {boolean} [includeHtmlTags] - If true, includes HTML tags in the returned text. Default: false\n */\nexport type TextContentsOptions = {\n maxCharacters?: number;\n includeHtmlTags?: boolean;\n};\n\n/**\n * Options for retrieving highlights from page.\n * @typedef {Object} HighlightsContentsOptions\n * @property {string} [query] - The query string to use for highlights search.\n * @property {number} [numSentences] - The number of sentences to return for each highlight.\n * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.\n */\nexport type HighlightsContentsOptions = {\n query?: string;\n numSentences?: number;\n highlightsPerUrl?: number;\n};\n\n/**\n * Options for retrieving summary from page.\n * @typedef {Object} SummaryContentsOptions\n * @property {string} [query] - The query string to use for summary generation.\n */\nexport type SummaryContentsOptions = {\n query?: string;\n};\n\n/**\n * @typedef {Object} TextResponse\n * @property {string} text - Text from page\n */\nexport type TextResponse = { text: string };\n\n/**\n * @typedef {Object} HighlightsResponse\n * @property {string[]} highlights - The highlights as an array of strings.\n * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1\n */\nexport type HighlightsResponse = {\n highlights: string[];\n highlightScores: number[];\n};\n\n/**\n * @typedef {Object} SummaryResponse\n * @property {string} summary - The generated summary of the page content.\n */\nexport type SummaryResponse = { summary: string };\n\n/**\n * @typedef {Object} ExtrasResponse\n * @property {string[]} links - The links on the page of a result\n */\nexport type ExtrasResponse = { extras: { links: string[] } };\n\n/**\n * @typedef {Object} SubpagesResponse\n * @property {ContentsResultComponent<T extends ContentsOptions>} subpages - The links on the page of a result\n */\nexport type SubpagesResponse<T extends ContentsOptions> = {subpages: ContentsResultComponent<T>[]}\n\n\n\nexport type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;\n\n/**\n * @typedef {Object} ContentsResultComponent\n * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.\n *\n * @template T - A type extending from 'ContentsOptions'.\n */\nexport type ContentsResultComponent<T extends ContentsOptions> = Default< \n (T[\"text\"] extends object | true ? TextResponse : {}) &\n (T[\"highlights\"] extends object | true ? HighlightsResponse : {}) &\n (T[\"summary\"] extends object | true ? SummaryResponse : {}) &\n (T[\"subpages\"] extends number ? SubpagesResponse<T> : {}) &\n (T[\"extras\"] extends object ? ExtrasResponse : {} ),\n TextResponse\n>;\n\n/**\n * Represents a search result object.\n * @typedef {Object} SearchResult\n * @property {string} title - The title of the search result.\n * @property {string} url - The URL of the search result.\n * @property {string} [publishedDate] - The estimated creation date of the content.\n * @property {string} [author] - The author of the content, if available.\n * @property {number} [score] - Similarity score between the query/url and the result.\n * @property {string} id - The temporary ID for the document.\n */\nexport type SearchResult<T extends ContentsOptions> = {\n title: string | null;\n url: string;\n publishedDate?: string;\n author?: string;\n score?: number;\n id: string;\n image?: string;\n} & ContentsResultComponent<T>;\n\n/**\n * Represents a search response object.\n * @typedef {Object} SearchResponse\n * @property {Result[]} results - The list of search results.\n * @property {string} [autopromptString] - The autoprompt string, if applicable.\n * @property {string} [autoDate] - The autoprompt date, if applicable.\n * @property {string} requestId - The request ID for the search.\n */\nexport type SearchResponse<T extends ContentsOptions> = {\n results: SearchResult<T>[];\n autopromptString?: string;\n autoDate?: string;\n requestId: string;\n};\n\n/**\n * The Exa class encapsulates the API's endpoints.\n */\nclass Exa {\n private baseURL: string;\n private headers: Headers;\n\n private extractContentsOptions<T extends ContentsOptions>(options: T): {\n contentsOptions: ContentsOptions;\n restOptions: Omit<T, keyof ContentsOptions>;\n } {\n\n const { text, highlights, summary, subpages, subpageTarget, extras, livecrawl, livecrawlTimeout, ...rest } = options;\n\n const contentsOptions: ContentsOptions = {};\n // don't send text if it's explicitly false\n if (text === undefined && summary === undefined && highlights === undefined && extras === undefined) contentsOptions.text = true\n if (text !== undefined) contentsOptions.text = text\n\n if (summary !== undefined) contentsOptions.summary = summary;\n if (highlights !== undefined) contentsOptions.highlights = highlights;\n\n if (subpages !== undefined) contentsOptions.subpages = subpages;\n if (subpageTarget !== undefined) contentsOptions.subpageTarget = subpageTarget;\n\n if (extras !== undefined) contentsOptions.extras = extras;\n if (livecrawl !== undefined) contentsOptions.livecrawl = livecrawl;\n if (livecrawlTimeout !== undefined) contentsOptions.livecrawlTimeout = livecrawlTimeout;\n\n return {\n contentsOptions: contentsOptions,\n restOptions: rest as Omit<T, keyof ContentsOptions>\n };\n }\n\n /**\n * Constructs the Exa API client.\n * @param {string} apiKey - The API key for authentication.\n * @param {string} [baseURL] - The base URL of the Exa API.\n */\n constructor(apiKey?: string, baseURL: string = \"https://api.exa.ai\") {\n this.baseURL = baseURL;\n if (!apiKey) {\n apiKey = process.env.EXASEARCH_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)\",\n );\n }\n }\n this.headers = new Headers({\n \"x-api-key\": apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"exa-node 1.3.2\",\n });\n }\n\n /**\n * Makes a request to the Exa API.\n * @param {string} endpoint - The API endpoint to call.\n * @param {string} method - The HTTP method to use.\n * @param {any} [body] - The request body for POST requests.\n * @returns {Promise<any>} The response from the API.\n */\n private async request(\n endpoint: string,\n method: string,\n body?: any,\n ): Promise<any> {\n const response = await fetch(this.baseURL + endpoint, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const message = (await response.json()).error;\n throw new Error(\n `Request failed with status ${response.status}. ${message}`,\n );\n }\n\n return await response.json();\n }\n\n\n /**\n * Performs a search with a Exa prompt-engineered query.\n * @param {string} query - The query string.\n * @param {SearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse>} A list of relevant search results.\n */\n async search(\n query: string,\n options?: RegularSearchOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/search\", \"POST\", { query, ...options });\n }\n\n /**\n * Performs a search with a Exa prompt-engineered query and returns the contents of the documents.\n * @param {string} query - The query string.\n * @param {SearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse>} A list of relevant search results.\n */\n async searchAndContents<T extends ContentsOptions>(\n query: string,\n options?: RegularSearchOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } = options === undefined ? \n { contentsOptions: { text: true }, restOptions: {}} :\n this.extractContentsOptions(options);\n\n return await this.request(\"/search\", \"POST\", {\n query,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Finds similar links to the provided URL.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions} [options] - Additional options for finding similar links.\n * @returns {Promise<SearchResponse>} A list of similar search results.\n */\n async findSimilar(\n url: string,\n options?: FindSimilarOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/findSimilar\", \"POST\", { url, ...options });\n }\n\n /** Finds similar links to the provided URL and returns the contents of the documents. @param {string} url - The URL for which to find similar links. @param {FindSimilarOptions} [options] - Additional options for finding similar links. @returns {Promise<SearchResponse>} A list of similar search results. */ \n async findSimilarAndContents<T extends ContentsOptions>(\n url: string,\n options?: FindSimilarOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } = options === undefined ?\n {contentsOptions: {text: true}, restOptions: {}} :\n this.extractContentsOptions(options);\n \n return await this.request(\"/findSimilar\", \"POST\", {\n url,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Retrieves contents of documents based on a list of document IDs.\n * @param {string | string[] | SearchResult[]} ids - An array of document IDs.\n * @param {ContentsOptions} [options] - Additional options for retrieving document contents.\n * @returns {Promise<GetContentsResponse>} A list of document contents.\n */\n async getContents<T extends ContentsOptions>(\n ids: string | string[] | SearchResult<T>[],\n options?: T,\n ): Promise<SearchResponse<T>> {\n if (ids.length === 0) {\n throw new Error(\"Must provide at least one ID\");\n }\n let requestIds: string[];\n if (typeof ids === \"string\") {\n requestIds = [ids];\n } else if (typeof ids[0] === \"string\") {\n requestIds = ids as string[];\n } else {\n requestIds = (ids as SearchResult<T>[]).map((result) => result.id);\n }\n return await this.request(`/contents`, \"POST\", {\n ids: requestIds,\n ...options,\n });\n }\n}\n\nexport default Exa;\n"],"mappings":";AAAA,OAAO,SAAS,eAAe;AA2N/B,IAAM,MAAN,MAAU;AAAA,EAIA,uBAAkD,SAGxD;AAEA,UAAM,EAAE,MAAM,YAAY,SAAS,UAAU,eAAe,QAAQ,WAAW,kBAAkB,GAAG,KAAK,IAAI;AAE7G,UAAM,kBAAmC,CAAC;AAE1C,QAAI,SAAS,UAAa,YAAY,UAAa,eAAe,UAAa,WAAW;AAAW,sBAAgB,OAAO;AAC5H,QAAI,SAAS;AAAW,sBAAgB,OAAO;AAE/C,QAAI,YAAY;AAAW,sBAAgB,UAAU;AACrD,QAAI,eAAe;AAAW,sBAAgB,aAAa;AAE3D,QAAI,aAAa;AAAW,sBAAgB,WAAW;AACvD,QAAI,kBAAkB;AAAW,sBAAgB,gBAAgB;AAEjE,QAAI,WAAW;AAAW,sBAAgB,SAAS;AACnD,QAAI,cAAc;AAAW,sBAAgB,YAAY;AACzD,Q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M,KAAK,QAAQ,WAAW,QAAQ;AAAA,MAC3C;AAAA,MACA,UAAU;AAAA,MACV,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YACJ,KACA,SAC6B;AAC7B,WAAO,MAAM,KAAK,QAAQ,gBAAgB,QAAQ,EAAE,KAAK,GAAG,QAAQ,CAAC;AAAA,EACvE;AAAA;AAAA,EAGA,MAAM,uBACJ,KACA,SAC4B;AAC5B,UAAM,EAAE,iBAAiB,YAAY,IAAI,YAAY,SACnD,EAAC,iBAAiB,EAAC,MAAM,KAAI,GAAG,aAAa,CAAC,EAAC,IAC/C,KAAK,uBAAuB,OAAO;AAErC,WAAO,MAAM,KAAK,QAAQ,gBAAgB,QAAQ;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YACJ,KACA,SAC4B;AAC5B,QAAI,IAAI,WAAW,GAAG;AACpB,YAAM,IAAI,MAAM,8BAA8B;AAAA,IAChD;AACA,QAAI;AACJ,QAAI,OAAO,QAAQ,UAAU;AAC3B,mBAAa,CAAC,GAAG;AAAA,IACnB,WAAW,OAAO,IAAI,CAAC,MAAM,UAAU;AACrC,mBAAa;AAAA,IACf,OAAO;AACL,mBAAc,IAA0B,IAAI,CAAC,WAAW,OAAO,EAAE;AAAA,IACnE;AACA,WAAO,MAAM,KAAK,QAAQ,aAAa,QAAQ;AAAA,MAC7C,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAEA,IAAO,cAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fetch, { Headers } from \"cross-fetch\";\n\nconst isBeta = false;\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} SearchOptions\n * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.\n * @property {string[]} [includeDomains] - List of domains to include in the search.\n * @property {string[]} [excludeDomains] - List of domains to exclude in the search.\n * @property {string} [startCrawlDate] - Start date for results based on crawl date.\n * @property {string} [endCrawlDate] - End date for results based on crawl date.\n * @property {string} [startPublishedDate] - Start date for results based on published date.\n * @property {string} [endPublishedDate] - End date for results based on published date.\n * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.\n * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.\n * @property {string[]} [flags] - Experimental flags\n */\nexport type BaseSearchOptions = {\n numResults?: number;\n includeDomains?: string[];\n excludeDomains?: string[];\n startCrawlDate?: string;\n endCrawlDate?: string;\n startPublishedDate?: string;\n endPublishedDate?: string;\n category?: string;\n includeText?: string[];\n excludeText?: string[];\n flags?: string[];\n};\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} RegularSearchOptions\n */\nexport type RegularSearchOptions = BaseSearchOptions & {\n useAutoprompt?: boolean;\n type?: string;\n};\n\n/**\n * Options for finding similar links.\n * @typedef {Object} FindSimilarOptions\n * @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.\n */\nexport type FindSimilarOptions = BaseSearchOptions & {\n excludeSourceDomain?: boolean;\n};\n\nexport type ExtrasOptions = { links?: number; imageLinks?: number };\n\n/**\n * Search options for performing a search query.\n * @typedef {Object} ContentsOptions\n * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.\n * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights.\n * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.\n * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is \"never\" for neural/auto search, \"fallback\" for keyword search.\n * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.\n * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.\n * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.\n * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use \"about\" to get *about* page for websites. Note that this is a fuzzy matcher.\n * @property {ExtrasOptions} [extras] - Miscelleneous data for derived from results\n */\nexport type ContentsOptions = {\n text?: TextContentsOptions | true;\n highlights?: HighlightsContentsOptions | true;\n summary?: SummaryContentsOptions | true;\n livecrawl?: LivecrawlOptions;\n livecrawlTimeout?: number;\n filterEmptyResults?: boolean;\n subpages?: number;\n subpageTarget?: string | string[];\n extras?: ExtrasOptions;\n} & (typeof isBeta extends true ? {} : {});\n\n/**\n * Options for livecrawling contents\n * @typedef {string} LivecrawlOptions\n */\nexport type LivecrawlOptions = \"never\" | \"fallback\" | \"always\" | \"auto\";\n\n/**\n * Options for retrieving text from page.\n * @typedef {Object} TextContentsOptions\n * @property {number} [maxCharacters] - The maximum number of characters to return.\n * @property {boolean} [includeHtmlTags] - If true, includes HTML tags in the returned text. Default: false\n */\nexport type TextContentsOptions = {\n maxCharacters?: number;\n includeHtmlTags?: boolean;\n};\n\n/**\n * Options for retrieving highlights from page.\n * @typedef {Object} HighlightsContentsOptions\n * @property {string} [query] - The query string to use for highlights search.\n * @property {number} [numSentences] - The number of sentences to return for each highlight.\n * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.\n */\nexport type HighlightsContentsOptions = {\n query?: string;\n numSentences?: number;\n highlightsPerUrl?: number;\n};\n\n/**\n * Options for retrieving summary from page.\n * @typedef {Object} SummaryContentsOptions\n * @property {string} [query] - The query string to use for summary generation.\n */\nexport type SummaryContentsOptions = {\n query?: string;\n};\n\n/**\n * @typedef {Object} TextResponse\n * @property {string} text - Text from page\n */\nexport type TextResponse = { text: string };\n\n/**\n * @typedef {Object} HighlightsResponse\n * @property {string[]} highlights - The highlights as an array of strings.\n * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1\n */\nexport type HighlightsResponse = {\n highlights: string[];\n highlightScores: number[];\n};\n\n/**\n * @typedef {Object} SummaryResponse\n * @property {string} summary - The generated summary of the page content.\n */\nexport type SummaryResponse = { summary: string };\n\n/**\n * @typedef {Object} ExtrasResponse\n * @property {string[]} links - The links on the page of a result\n * @property {string[]} imageLinks - The image links on the page of a result\n */\nexport type ExtrasResponse = { extras: { links?: string[]; imageLinks?: string[] } };\n\n/**\n * @typedef {Object} SubpagesResponse\n * @property {ContentsResultComponent<T extends ContentsOptions>} subpages - The links on the page of a result\n */\nexport type SubpagesResponse<T extends ContentsOptions> = {\n subpages: ContentsResultComponent<T>[];\n};\n\nexport type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;\n\n/**\n * @typedef {Object} ContentsResultComponent\n * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.\n *\n * @template T - A type extending from 'ContentsOptions'.\n */\nexport type ContentsResultComponent<T extends ContentsOptions> = Default<\n (T[\"text\"] extends object | true ? TextResponse : {}) &\n (T[\"highlights\"] extends object | true ? HighlightsResponse : {}) &\n (T[\"summary\"] extends object | true ? SummaryResponse : {}) &\n (T[\"subpages\"] extends number ? SubpagesResponse<T> : {}) &\n (T[\"extras\"] extends object ? ExtrasResponse : {}),\n TextResponse\n>;\n\n/**\n * Represents a search result object.\n * @typedef {Object} SearchResult\n * @property {string} title - The title of the search result.\n * @property {string} url - The URL of the search result.\n * @property {string} [publishedDate] - The estimated creation date of the content.\n * @property {string} [author] - The author of the content, if available.\n * @property {number} [score] - Similarity score between the query/url and the result.\n * @property {string} id - The temporary ID for the document.\n */\nexport type SearchResult<T extends ContentsOptions> = {\n title: string | null;\n url: string;\n publishedDate?: string;\n author?: string;\n score?: number;\n id: string;\n image?: string;\n favicon?: string;\n} & ContentsResultComponent<T>;\n\n/**\n * Represents a search response object.\n * @typedef {Object} SearchResponse\n * @property {Result[]} results - The list of search results.\n * @property {string} [autopromptString] - The autoprompt string, if applicable.\n * @property {string} [autoDate] - The autoprompt date, if applicable.\n * @property {string} requestId - The request ID for the search.\n */\nexport type SearchResponse<T extends ContentsOptions> = {\n results: SearchResult<T>[];\n autopromptString?: string;\n autoDate?: string;\n requestId: string;\n};\n\n/**\n * The Exa class encapsulates the API's endpoints.\n */\nclass Exa {\n private baseURL: string;\n private headers: Headers;\n\n private extractContentsOptions<T extends ContentsOptions>(options: T): {\n contentsOptions: ContentsOptions;\n restOptions: Omit<T, keyof ContentsOptions>;\n } {\n const {\n text,\n highlights,\n summary,\n subpages,\n subpageTarget,\n extras,\n livecrawl,\n livecrawlTimeout,\n ...rest\n } = options;\n\n const contentsOptions: ContentsOptions = {};\n // don't send text if it's explicitly false\n if (\n text === undefined &&\n summary === undefined &&\n highlights === undefined &&\n extras === undefined\n )\n contentsOptions.text = true;\n if (text !== undefined) contentsOptions.text = text;\n\n if (summary !== undefined) contentsOptions.summary = summary;\n if (highlights !== undefined) contentsOptions.highlights = highlights;\n\n if (subpages !== undefined) contentsOptions.subpages = subpages;\n if (subpageTarget !== undefined)\n contentsOptions.subpageTarget = subpageTarget;\n\n if (extras !== undefined) contentsOptions.extras = extras;\n if (livecrawl !== undefined) contentsOptions.livecrawl = livecrawl;\n if (livecrawlTimeout !== undefined)\n contentsOptions.livecrawlTimeout = livecrawlTimeout;\n\n return {\n contentsOptions: contentsOptions,\n restOptions: rest as Omit<T, keyof ContentsOptions>,\n };\n }\n\n /**\n * Constructs the Exa API client.\n * @param {string} apiKey - The API key for authentication.\n * @param {string} [baseURL] - The base URL of the Exa API.\n */\n constructor(apiKey?: string, baseURL: string = \"https://api.exa.ai\") {\n this.baseURL = baseURL;\n if (!apiKey) {\n apiKey = process.env.EXASEARCH_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"API key must be provided as an argument or as an environment variable (EXASEARCH_API_KEY)\",\n );\n }\n }\n this.headers = new Headers({\n \"x-api-key\": apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"exa-node 1.3.2\",\n });\n }\n\n /**\n * Makes a request to the Exa API.\n * @param {string} endpoint - The API endpoint to call.\n * @param {string} method - The HTTP method to use.\n * @param {any} [body] - The request body for POST requests.\n * @returns {Promise<any>} The response from the API.\n */\n private async request(\n endpoint: string,\n method: string,\n body?: any,\n ): Promise<any> {\n const response = await fetch(this.baseURL + endpoint, {\n method,\n headers: this.headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const message = (await response.json()).error;\n throw new Error(\n `Request failed with status ${response.status}. ${message}`,\n );\n }\n\n return await response.json();\n }\n\n /**\n * Performs a search with an Exa prompt-engineered query.\n * @param {string} query - The query string.\n * @param {RegularSearchOptions} [options] - Additional search options.\n * @returns {Promise<SearchResponse<{}>>} A list of relevant search results.\n */\n async search(\n query: string,\n options?: RegularSearchOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/search\", \"POST\", { query, ...options });\n }\n\n /**\n * Performs a search with an Exa prompt-engineered query and returns the contents of the documents.\n * @param {string} query - The query string.\n * @param {RegularSearchOptions & T} [options] - Additional search + contents options.\n * @returns {Promise<SearchResponse<T>>} A list of relevant search results.\n */\n async searchAndContents<T extends ContentsOptions>(\n query: string,\n options?: RegularSearchOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } =\n options === undefined\n ? { contentsOptions: { text: true }, restOptions: {} }\n : this.extractContentsOptions(options);\n\n return await this.request(\"/search\", \"POST\", {\n query,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Finds similar links to the provided URL.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions} [options] - Additional options for finding similar links.\n * @returns {Promise<SearchResponse<{}>>} A list of similar search results.\n */\n async findSimilar(\n url: string,\n options?: FindSimilarOptions,\n ): Promise<SearchResponse<{}>> {\n return await this.request(\"/findSimilar\", \"POST\", { url, ...options });\n }\n\n /**\n * Finds similar links to the provided URL and returns the contents of the documents.\n * @param {string} url - The URL for which to find similar links.\n * @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.\n * @returns {Promise<SearchResponse<T>>} A list of similar search results.\n */\n async findSimilarAndContents<T extends ContentsOptions>(\n url: string,\n options?: FindSimilarOptions & T,\n ): Promise<SearchResponse<T>> {\n const { contentsOptions, restOptions } =\n options === undefined\n ? { contentsOptions: { text: true }, restOptions: {} }\n : this.extractContentsOptions(options);\n\n return await this.request(\"/findSimilar\", \"POST\", {\n url,\n contents: contentsOptions,\n ...restOptions,\n });\n }\n\n /**\n * Retrieves contents of documents based on a list of document IDs.\n * @param {string | string[] | SearchResult[]} ids - An array of document IDs (or `SearchResult` objects).\n * @param {ContentsOptions} [options] - Additional options for retrieving document contents.\n * @returns {Promise<SearchResponse<T>>} A list of document contents.\n */\n async getContents<T extends ContentsOptions>(\n ids: string | string[] | SearchResult<T>[],\n options?: T,\n ): Promise<SearchResponse<T>> {\n if (ids.length === 0) {\n throw new Error(\"Must provide at least one ID\");\n }\n let requestIds: string[];\n if (typeof ids === \"string\") {\n requestIds = [ids];\n } else if (typeof ids[0] === \"string\") {\n requestIds = ids as string[];\n } else {\n requestIds = (ids as SearchResult<T>[]).map((result) => result.id);\n }\n return await this.request(`/contents`, \"POST\", {\n ids: requestIds,\n ...options,\n });\n }\n}\n\nexport default Exa;\n"],"mappings":";AAAA,OAAO,SAAS,eAAe;AAkN/B,IAAM,MAAN,MAAU;AAAA,EAIA,uBAAkD,SAGxD;AACA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,kBAAmC,CAAC;AAE1C,QACE,SAAS,UACT,YAAY,UACZ,eAAe,UACf,WAAW;AAEX,sBAAgB,OAAO;AACzB,QAAI,SAAS;AAAW,sBAAgB,OAAO;AAE/C,QAAI,YAAY;AAAW,sBAAgB,UAAU;AACrD,QAAI,eAAe;AAAW,sBAAgB,aAAa;AAE3D,QAAI,aAAa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