exa-js 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/index.d.mts +107 -64
- package/dist/index.d.ts +107 -64
- package/dist/index.js +161 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,6 +190,34 @@ Each chunk contains:
|
|
|
190
190
|
- `content`: A string containing the next piece of generated text
|
|
191
191
|
- `citations`: An array of citation objects containing source information
|
|
192
192
|
|
|
193
|
+
### `exa.research.createTask(input: object, options?: { schema?: object }): Promise<{id: string}>`
|
|
194
|
+
|
|
195
|
+
Exa's research agent can autonomously gather information and return a structured JSON object that conforms to a schema you provide.
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
import Exa from "exa-js";
|
|
199
|
+
|
|
200
|
+
const exa = new Exa(process.env.EXA_API_KEY);
|
|
201
|
+
|
|
202
|
+
const schema = {
|
|
203
|
+
type: "object",
|
|
204
|
+
required: ["answer"],
|
|
205
|
+
properties: {
|
|
206
|
+
answer: { type: "string" },
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const { id: taskId } = await exa.research.createTask(
|
|
211
|
+
{
|
|
212
|
+
instructions: "In ≤3 sentences, explain quantum computing.",
|
|
213
|
+
},
|
|
214
|
+
{ schema }
|
|
215
|
+
);
|
|
216
|
+
const result = await exa.research.pollTask(taskId);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Use the `status` field to poll long-running tasks if needed (a future `getTask` helper will be added when the async API is released).
|
|
220
|
+
|
|
193
221
|
# Contributing
|
|
194
222
|
|
|
195
223
|
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
|
package/dist/index.d.mts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Type for API query parameters
|
|
7
7
|
*/
|
|
8
|
-
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
8
|
+
type QueryParams$1 = Record<string, string | number | boolean | string[] | undefined>;
|
|
9
9
|
/**
|
|
10
10
|
* Type for API request body
|
|
11
11
|
*/
|
|
12
|
-
interface RequestBody {
|
|
12
|
+
interface RequestBody$1 {
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -44,13 +44,13 @@ declare class WebsetsBaseClient {
|
|
|
44
44
|
* @returns The response JSON
|
|
45
45
|
* @throws ExaError with API error details if the request fails
|
|
46
46
|
*/
|
|
47
|
-
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
47
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody$1, params?: QueryParams$1): Promise<T>;
|
|
48
48
|
/**
|
|
49
49
|
* Helper to build pagination parameters
|
|
50
50
|
* @param pagination The pagination parameters
|
|
51
51
|
* @returns QueryParams object with pagination parameters
|
|
52
52
|
*/
|
|
53
|
-
protected buildPaginationParams(pagination?: PaginationParams): QueryParams;
|
|
53
|
+
protected buildPaginationParams(pagination?: PaginationParams): QueryParams$1;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
interface components {
|
|
@@ -1340,6 +1340,103 @@ declare class WebsetsClient extends WebsetsBaseClient {
|
|
|
1340
1340
|
} | number): Promise<Webset>;
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
+
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
1344
|
+
interface RequestBody {
|
|
1345
|
+
[key: string]: unknown;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Base client class for all Research-related API clients
|
|
1349
|
+
*/
|
|
1350
|
+
declare class ResearchBaseClient {
|
|
1351
|
+
protected client: Exa;
|
|
1352
|
+
/**
|
|
1353
|
+
* Initialize a new Research base client
|
|
1354
|
+
* @param client The Exa client instance
|
|
1355
|
+
*/
|
|
1356
|
+
constructor(client: Exa);
|
|
1357
|
+
/**
|
|
1358
|
+
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1359
|
+
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1360
|
+
* @param method The HTTP method. Defaults to "POST".
|
|
1361
|
+
* @param data Optional request body
|
|
1362
|
+
* @param params Optional query parameters
|
|
1363
|
+
* @returns The parsed JSON response
|
|
1364
|
+
*/
|
|
1365
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Client for interacting with the Research Tasks API.
|
|
1370
|
+
*/
|
|
1371
|
+
declare class ResearchClient extends ResearchBaseClient {
|
|
1372
|
+
constructor(client: Exa);
|
|
1373
|
+
/**
|
|
1374
|
+
* Create a research task.
|
|
1375
|
+
*
|
|
1376
|
+
* Both parameters are required and have fixed shapes:
|
|
1377
|
+
* 1. `input`
|
|
1378
|
+
* `{ instructions: string }`
|
|
1379
|
+
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1380
|
+
* 2. `output`
|
|
1381
|
+
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1382
|
+
* `{ schema: JSONSchema }`.
|
|
1383
|
+
* The agent's response will be validated against this schema.
|
|
1384
|
+
*
|
|
1385
|
+
* @param input Object containing high-level research instructions.
|
|
1386
|
+
* @param output Object containing the expected output schema.
|
|
1387
|
+
* @returns The ResearchTaskResponse returned by the API.
|
|
1388
|
+
*/
|
|
1389
|
+
createTask(input: {
|
|
1390
|
+
instructions: string;
|
|
1391
|
+
}, output: {
|
|
1392
|
+
schema: JSONSchema;
|
|
1393
|
+
}): Promise<{
|
|
1394
|
+
id: string;
|
|
1395
|
+
}>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Retrieve a research task by ID.
|
|
1398
|
+
*/
|
|
1399
|
+
getTask(id: string): Promise<ResearchTask>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Poll a research task until completion or failure.
|
|
1402
|
+
* Polls every 1 second with a maximum timeout of 10 minutes.
|
|
1403
|
+
*/
|
|
1404
|
+
pollTask(id: string): Promise<ResearchTask>;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Enum representing the status of a research task.
|
|
1409
|
+
*/
|
|
1410
|
+
declare enum ResearchStatus {
|
|
1411
|
+
/** The research task is still in progress. */
|
|
1412
|
+
in_progress = "in_progress",
|
|
1413
|
+
/** The research request has finished successfully. */
|
|
1414
|
+
completed = "completed",
|
|
1415
|
+
/** The research task request failed. */
|
|
1416
|
+
failed = "failed"
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Response object returned from the research API.
|
|
1420
|
+
*/
|
|
1421
|
+
type ResearchTask = {
|
|
1422
|
+
/** Unique identifier for the task. */
|
|
1423
|
+
id: string;
|
|
1424
|
+
/** Current status. */
|
|
1425
|
+
status: ResearchStatus;
|
|
1426
|
+
/** The original instructions provided along with the task. */
|
|
1427
|
+
instructions: string;
|
|
1428
|
+
/** The original schema defining the task */
|
|
1429
|
+
schema: Record<string, any>;
|
|
1430
|
+
/** Structured output that follows the user-provided schema (null while running or if failed). */
|
|
1431
|
+
data: Record<string, any> | null;
|
|
1432
|
+
/**
|
|
1433
|
+
* Citations collected while deriving each top-level field in `output`.
|
|
1434
|
+
* The key is the field name, the value is the list of `SearchResult`s that
|
|
1435
|
+
* were used to compute that field.
|
|
1436
|
+
*/
|
|
1437
|
+
citations: Record<string, SearchResult<{}>[]>;
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1343
1440
|
/**
|
|
1344
1441
|
* HTTP status codes
|
|
1345
1442
|
*/
|
|
@@ -1694,29 +1791,6 @@ type AnswerStreamResponse = {
|
|
|
1694
1791
|
answer?: string;
|
|
1695
1792
|
citations?: SearchResult<{}>[];
|
|
1696
1793
|
};
|
|
1697
|
-
/**
|
|
1698
|
-
* Enum representing the status of a research task.
|
|
1699
|
-
*/
|
|
1700
|
-
declare enum ResearchStatus {
|
|
1701
|
-
/** The research request has finished successfully. */
|
|
1702
|
-
completed = "completed",
|
|
1703
|
-
/** The research request failed. */
|
|
1704
|
-
failed = "failed"
|
|
1705
|
-
}
|
|
1706
|
-
/**
|
|
1707
|
-
* @typedef {Object} ResearchTaskResponse
|
|
1708
|
-
* @property {string} id - The unique identifier of the research request.
|
|
1709
|
-
* @property {ResearchStatus | string} status - The current status of the research request.
|
|
1710
|
-
* @property {Record<string, any> | null} output - The structured output, if the research has completed.
|
|
1711
|
-
* @property {SearchResult<{}>[]} citations - References used for the research.
|
|
1712
|
-
*/
|
|
1713
|
-
type ResearchTaskResponse = {
|
|
1714
|
-
id: string;
|
|
1715
|
-
status: ResearchStatus | string;
|
|
1716
|
-
output: Record<string, any> | null;
|
|
1717
|
-
citations: SearchResult<{}>[];
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
1794
|
/**
|
|
1721
1795
|
* The Exa class encapsulates the API's endpoints.
|
|
1722
1796
|
*/
|
|
@@ -1727,6 +1801,10 @@ declare class Exa {
|
|
|
1727
1801
|
* Websets API client
|
|
1728
1802
|
*/
|
|
1729
1803
|
websets: WebsetsClient;
|
|
1804
|
+
/**
|
|
1805
|
+
* Research API client
|
|
1806
|
+
*/
|
|
1807
|
+
research: ResearchClient;
|
|
1730
1808
|
/**
|
|
1731
1809
|
* Helper method to separate out the contents-specific options from the rest.
|
|
1732
1810
|
*/
|
|
@@ -1833,42 +1911,7 @@ declare class Exa {
|
|
|
1833
1911
|
outputSchema?: Record<string, unknown>;
|
|
1834
1912
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
1835
1913
|
private processChunk;
|
|
1836
|
-
|
|
1837
|
-
* Creates and runs a research task in a blocking manner.
|
|
1838
|
-
*
|
|
1839
|
-
* Both parameters are required and have fixed shapes:
|
|
1840
|
-
* 1. `input`
|
|
1841
|
-
* `{ instructions: string }`
|
|
1842
|
-
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1843
|
-
* 2. `output`
|
|
1844
|
-
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1845
|
-
* `{ schema: JSONSchema }`.
|
|
1846
|
-
* The agent’s response will be validated against this schema.
|
|
1847
|
-
*
|
|
1848
|
-
* @param {{ instructions: string }} input The research prompt.
|
|
1849
|
-
* @param {{ schema: JSONSchema }} output The desired output schema.
|
|
1850
|
-
* @returns {Promise<ResearchTaskResponse>} The research response.
|
|
1851
|
-
*
|
|
1852
|
-
* @example
|
|
1853
|
-
* const response = await exa.researchTask(
|
|
1854
|
-
* { instructions: "I need a few key facts about honey pot ants." },
|
|
1855
|
-
* {
|
|
1856
|
-
* schema: {
|
|
1857
|
-
* type: "object",
|
|
1858
|
-
* required: ["scientificName", "primaryRegions"],
|
|
1859
|
-
* properties: {
|
|
1860
|
-
* scientificName: { type: "string" },
|
|
1861
|
-
* primaryRegions: { type: "string" },
|
|
1862
|
-
* },
|
|
1863
|
-
* },
|
|
1864
|
-
* },
|
|
1865
|
-
* );
|
|
1866
|
-
*/
|
|
1867
|
-
researchTask(input: {
|
|
1868
|
-
instructions: string;
|
|
1869
|
-
}, output: {
|
|
1870
|
-
schema: JSONSchema;
|
|
1871
|
-
}): Promise<ResearchTaskResponse>;
|
|
1914
|
+
private parseSSEStream;
|
|
1872
1915
|
}
|
|
1873
1916
|
|
|
1874
|
-
export { type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamResponse, type BaseSearchOptions, type ContentsOptions, type ContentsResultComponent, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, CreateWebsetSearchParametersBehaviour, type Default, type EnrichmentResult, type Event, EventType, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type JSONSchema, type ListEventsResponse, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetsOptions, type ListWebsetsResponse, type LivecrawlOptions, type RegularSearchOptions, ResearchStatus, type
|
|
1917
|
+
export { type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamResponse, type BaseSearchOptions, type ContentsOptions, type ContentsResultComponent, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, CreateWebsetSearchParametersBehaviour, type Default, type EnrichmentResult, type Event, EventType, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type JSONSchema, type ListEventsResponse, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetsOptions, type ListWebsetsResponse, type LivecrawlOptions, type RegularSearchOptions, ResearchClient, ResearchStatus, type ResearchTask, type SearchResponse, type SearchResult, type SubpagesResponse, type SummaryContentsOptions, type SummaryResponse, type TextContentsOptions, type TextResponse, type UpdateWebhookParameters, type UpdateWebsetRequest, type Webhook, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, type WebsetItem, WebsetItemEvaluationSatisfied, WebsetItemSource, WebsetItemsClient, type WebsetSearch, WebsetSearchCanceledReason, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Type for API query parameters
|
|
7
7
|
*/
|
|
8
|
-
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
8
|
+
type QueryParams$1 = Record<string, string | number | boolean | string[] | undefined>;
|
|
9
9
|
/**
|
|
10
10
|
* Type for API request body
|
|
11
11
|
*/
|
|
12
|
-
interface RequestBody {
|
|
12
|
+
interface RequestBody$1 {
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -44,13 +44,13 @@ declare class WebsetsBaseClient {
|
|
|
44
44
|
* @returns The response JSON
|
|
45
45
|
* @throws ExaError with API error details if the request fails
|
|
46
46
|
*/
|
|
47
|
-
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
47
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody$1, params?: QueryParams$1): Promise<T>;
|
|
48
48
|
/**
|
|
49
49
|
* Helper to build pagination parameters
|
|
50
50
|
* @param pagination The pagination parameters
|
|
51
51
|
* @returns QueryParams object with pagination parameters
|
|
52
52
|
*/
|
|
53
|
-
protected buildPaginationParams(pagination?: PaginationParams): QueryParams;
|
|
53
|
+
protected buildPaginationParams(pagination?: PaginationParams): QueryParams$1;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
interface components {
|
|
@@ -1340,6 +1340,103 @@ declare class WebsetsClient extends WebsetsBaseClient {
|
|
|
1340
1340
|
} | number): Promise<Webset>;
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
+
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
1344
|
+
interface RequestBody {
|
|
1345
|
+
[key: string]: unknown;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Base client class for all Research-related API clients
|
|
1349
|
+
*/
|
|
1350
|
+
declare class ResearchBaseClient {
|
|
1351
|
+
protected client: Exa;
|
|
1352
|
+
/**
|
|
1353
|
+
* Initialize a new Research base client
|
|
1354
|
+
* @param client The Exa client instance
|
|
1355
|
+
*/
|
|
1356
|
+
constructor(client: Exa);
|
|
1357
|
+
/**
|
|
1358
|
+
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1359
|
+
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1360
|
+
* @param method The HTTP method. Defaults to "POST".
|
|
1361
|
+
* @param data Optional request body
|
|
1362
|
+
* @param params Optional query parameters
|
|
1363
|
+
* @returns The parsed JSON response
|
|
1364
|
+
*/
|
|
1365
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Client for interacting with the Research Tasks API.
|
|
1370
|
+
*/
|
|
1371
|
+
declare class ResearchClient extends ResearchBaseClient {
|
|
1372
|
+
constructor(client: Exa);
|
|
1373
|
+
/**
|
|
1374
|
+
* Create a research task.
|
|
1375
|
+
*
|
|
1376
|
+
* Both parameters are required and have fixed shapes:
|
|
1377
|
+
* 1. `input`
|
|
1378
|
+
* `{ instructions: string }`
|
|
1379
|
+
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1380
|
+
* 2. `output`
|
|
1381
|
+
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1382
|
+
* `{ schema: JSONSchema }`.
|
|
1383
|
+
* The agent's response will be validated against this schema.
|
|
1384
|
+
*
|
|
1385
|
+
* @param input Object containing high-level research instructions.
|
|
1386
|
+
* @param output Object containing the expected output schema.
|
|
1387
|
+
* @returns The ResearchTaskResponse returned by the API.
|
|
1388
|
+
*/
|
|
1389
|
+
createTask(input: {
|
|
1390
|
+
instructions: string;
|
|
1391
|
+
}, output: {
|
|
1392
|
+
schema: JSONSchema;
|
|
1393
|
+
}): Promise<{
|
|
1394
|
+
id: string;
|
|
1395
|
+
}>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Retrieve a research task by ID.
|
|
1398
|
+
*/
|
|
1399
|
+
getTask(id: string): Promise<ResearchTask>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Poll a research task until completion or failure.
|
|
1402
|
+
* Polls every 1 second with a maximum timeout of 10 minutes.
|
|
1403
|
+
*/
|
|
1404
|
+
pollTask(id: string): Promise<ResearchTask>;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Enum representing the status of a research task.
|
|
1409
|
+
*/
|
|
1410
|
+
declare enum ResearchStatus {
|
|
1411
|
+
/** The research task is still in progress. */
|
|
1412
|
+
in_progress = "in_progress",
|
|
1413
|
+
/** The research request has finished successfully. */
|
|
1414
|
+
completed = "completed",
|
|
1415
|
+
/** The research task request failed. */
|
|
1416
|
+
failed = "failed"
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Response object returned from the research API.
|
|
1420
|
+
*/
|
|
1421
|
+
type ResearchTask = {
|
|
1422
|
+
/** Unique identifier for the task. */
|
|
1423
|
+
id: string;
|
|
1424
|
+
/** Current status. */
|
|
1425
|
+
status: ResearchStatus;
|
|
1426
|
+
/** The original instructions provided along with the task. */
|
|
1427
|
+
instructions: string;
|
|
1428
|
+
/** The original schema defining the task */
|
|
1429
|
+
schema: Record<string, any>;
|
|
1430
|
+
/** Structured output that follows the user-provided schema (null while running or if failed). */
|
|
1431
|
+
data: Record<string, any> | null;
|
|
1432
|
+
/**
|
|
1433
|
+
* Citations collected while deriving each top-level field in `output`.
|
|
1434
|
+
* The key is the field name, the value is the list of `SearchResult`s that
|
|
1435
|
+
* were used to compute that field.
|
|
1436
|
+
*/
|
|
1437
|
+
citations: Record<string, SearchResult<{}>[]>;
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1343
1440
|
/**
|
|
1344
1441
|
* HTTP status codes
|
|
1345
1442
|
*/
|
|
@@ -1694,29 +1791,6 @@ type AnswerStreamResponse = {
|
|
|
1694
1791
|
answer?: string;
|
|
1695
1792
|
citations?: SearchResult<{}>[];
|
|
1696
1793
|
};
|
|
1697
|
-
/**
|
|
1698
|
-
* Enum representing the status of a research task.
|
|
1699
|
-
*/
|
|
1700
|
-
declare enum ResearchStatus {
|
|
1701
|
-
/** The research request has finished successfully. */
|
|
1702
|
-
completed = "completed",
|
|
1703
|
-
/** The research request failed. */
|
|
1704
|
-
failed = "failed"
|
|
1705
|
-
}
|
|
1706
|
-
/**
|
|
1707
|
-
* @typedef {Object} ResearchTaskResponse
|
|
1708
|
-
* @property {string} id - The unique identifier of the research request.
|
|
1709
|
-
* @property {ResearchStatus | string} status - The current status of the research request.
|
|
1710
|
-
* @property {Record<string, any> | null} output - The structured output, if the research has completed.
|
|
1711
|
-
* @property {SearchResult<{}>[]} citations - References used for the research.
|
|
1712
|
-
*/
|
|
1713
|
-
type ResearchTaskResponse = {
|
|
1714
|
-
id: string;
|
|
1715
|
-
status: ResearchStatus | string;
|
|
1716
|
-
output: Record<string, any> | null;
|
|
1717
|
-
citations: SearchResult<{}>[];
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
1794
|
/**
|
|
1721
1795
|
* The Exa class encapsulates the API's endpoints.
|
|
1722
1796
|
*/
|
|
@@ -1727,6 +1801,10 @@ declare class Exa {
|
|
|
1727
1801
|
* Websets API client
|
|
1728
1802
|
*/
|
|
1729
1803
|
websets: WebsetsClient;
|
|
1804
|
+
/**
|
|
1805
|
+
* Research API client
|
|
1806
|
+
*/
|
|
1807
|
+
research: ResearchClient;
|
|
1730
1808
|
/**
|
|
1731
1809
|
* Helper method to separate out the contents-specific options from the rest.
|
|
1732
1810
|
*/
|
|
@@ -1833,42 +1911,7 @@ declare class Exa {
|
|
|
1833
1911
|
outputSchema?: Record<string, unknown>;
|
|
1834
1912
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
1835
1913
|
private processChunk;
|
|
1836
|
-
|
|
1837
|
-
* Creates and runs a research task in a blocking manner.
|
|
1838
|
-
*
|
|
1839
|
-
* Both parameters are required and have fixed shapes:
|
|
1840
|
-
* 1. `input`
|
|
1841
|
-
* `{ instructions: string }`
|
|
1842
|
-
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1843
|
-
* 2. `output`
|
|
1844
|
-
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1845
|
-
* `{ schema: JSONSchema }`.
|
|
1846
|
-
* The agent’s response will be validated against this schema.
|
|
1847
|
-
*
|
|
1848
|
-
* @param {{ instructions: string }} input The research prompt.
|
|
1849
|
-
* @param {{ schema: JSONSchema }} output The desired output schema.
|
|
1850
|
-
* @returns {Promise<ResearchTaskResponse>} The research response.
|
|
1851
|
-
*
|
|
1852
|
-
* @example
|
|
1853
|
-
* const response = await exa.researchTask(
|
|
1854
|
-
* { instructions: "I need a few key facts about honey pot ants." },
|
|
1855
|
-
* {
|
|
1856
|
-
* schema: {
|
|
1857
|
-
* type: "object",
|
|
1858
|
-
* required: ["scientificName", "primaryRegions"],
|
|
1859
|
-
* properties: {
|
|
1860
|
-
* scientificName: { type: "string" },
|
|
1861
|
-
* primaryRegions: { type: "string" },
|
|
1862
|
-
* },
|
|
1863
|
-
* },
|
|
1864
|
-
* },
|
|
1865
|
-
* );
|
|
1866
|
-
*/
|
|
1867
|
-
researchTask(input: {
|
|
1868
|
-
instructions: string;
|
|
1869
|
-
}, output: {
|
|
1870
|
-
schema: JSONSchema;
|
|
1871
|
-
}): Promise<ResearchTaskResponse>;
|
|
1914
|
+
private parseSSEStream;
|
|
1872
1915
|
}
|
|
1873
1916
|
|
|
1874
|
-
export { type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamResponse, type BaseSearchOptions, type ContentsOptions, type ContentsResultComponent, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, CreateWebsetSearchParametersBehaviour, type Default, type EnrichmentResult, type Event, EventType, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type JSONSchema, type ListEventsResponse, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetsOptions, type ListWebsetsResponse, type LivecrawlOptions, type RegularSearchOptions, ResearchStatus, type
|
|
1917
|
+
export { type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamResponse, type BaseSearchOptions, type ContentsOptions, type ContentsResultComponent, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, CreateWebsetSearchParametersBehaviour, type Default, type EnrichmentResult, type Event, EventType, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type JSONSchema, type ListEventsResponse, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetsOptions, type ListWebsetsResponse, type LivecrawlOptions, type RegularSearchOptions, ResearchClient, ResearchStatus, type ResearchTask, type SearchResponse, type SearchResult, type SubpagesResponse, type SummaryContentsOptions, type SummaryResponse, type TextContentsOptions, type TextResponse, type UpdateWebhookParameters, type UpdateWebsetRequest, type Webhook, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, type WebsetItem, WebsetItemEvaluationSatisfied, WebsetItemSource, WebsetItemsClient, type WebsetSearch, WebsetSearchCanceledReason, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|