exa-js 1.7.1 → 1.7.2
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 +27 -0
- package/dist/index.d.mts +97 -64
- package/dist/index.d.ts +97 -64
- package/dist/index.js +142 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,6 +190,33 @@ 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<ResearchTaskResponse>`
|
|
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 response = await exa.research.createTask(
|
|
211
|
+
{
|
|
212
|
+
instructions: "In ≤3 sentences, explain quantum computing.",
|
|
213
|
+
},
|
|
214
|
+
{ schema }
|
|
215
|
+
);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Use the `status` field to poll long-running tasks if needed (a future `getTask` helper will be added when the async API is released).
|
|
219
|
+
|
|
193
220
|
# Contributing
|
|
194
221
|
|
|
195
222
|
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,93 @@ declare class WebsetsClient extends WebsetsBaseClient {
|
|
|
1340
1340
|
} | number): Promise<Webset>;
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
+
/**
|
|
1344
|
+
* Enum representing the status of a research task.
|
|
1345
|
+
*/
|
|
1346
|
+
declare enum ResearchStatus {
|
|
1347
|
+
/** The research request has finished successfully. */
|
|
1348
|
+
completed = "completed",
|
|
1349
|
+
/** The research request failed. */
|
|
1350
|
+
failed = "failed"
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Response object returned from the research API.
|
|
1354
|
+
*/
|
|
1355
|
+
type ResearchTaskResponse = {
|
|
1356
|
+
/** Unique identifier for the task. */
|
|
1357
|
+
id: string;
|
|
1358
|
+
/** Current status (may include future enum values served by the API). */
|
|
1359
|
+
status: ResearchStatus | string;
|
|
1360
|
+
/** Structured output that follows the user-provided schema (null while running). */
|
|
1361
|
+
output: Record<string, any> | null;
|
|
1362
|
+
/**
|
|
1363
|
+
* Citations collected while deriving each top-level field in `output`.
|
|
1364
|
+
* The key is the field name, the value is the list of `SearchResult`s that
|
|
1365
|
+
* were used to compute that field.
|
|
1366
|
+
*/
|
|
1367
|
+
citations: Record<string, SearchResult<{}>[]>;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
1371
|
+
interface RequestBody {
|
|
1372
|
+
[key: string]: unknown;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Base client class for all Research-related API clients
|
|
1376
|
+
*/
|
|
1377
|
+
declare class ResearchBaseClient {
|
|
1378
|
+
protected client: Exa;
|
|
1379
|
+
/**
|
|
1380
|
+
* Initialize a new Research base client
|
|
1381
|
+
* @param client The Exa client instance
|
|
1382
|
+
*/
|
|
1383
|
+
constructor(client: Exa);
|
|
1384
|
+
/**
|
|
1385
|
+
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1386
|
+
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1387
|
+
* @param method The HTTP method. Defaults to "POST".
|
|
1388
|
+
* @param data Optional request body
|
|
1389
|
+
* @param params Optional query parameters
|
|
1390
|
+
* @returns The parsed JSON response
|
|
1391
|
+
*/
|
|
1392
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Client for interacting with the Research Tasks API.
|
|
1397
|
+
*/
|
|
1398
|
+
declare class ResearchClient extends ResearchBaseClient {
|
|
1399
|
+
constructor(client: Exa);
|
|
1400
|
+
/**
|
|
1401
|
+
* Create and run a research task (blocking call).
|
|
1402
|
+
*
|
|
1403
|
+
* Both parameters are required and have fixed shapes:
|
|
1404
|
+
* 1. `input`
|
|
1405
|
+
* `{ instructions: string }`
|
|
1406
|
+
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1407
|
+
* 2. `output`
|
|
1408
|
+
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1409
|
+
* `{ schema: JSONSchema }`.
|
|
1410
|
+
* The agent's response will be validated against this schema.
|
|
1411
|
+
*
|
|
1412
|
+
* @param input Object containing high-level research instructions.
|
|
1413
|
+
* @param output Object containing the expected output schema.
|
|
1414
|
+
* @returns The ResearchTaskResponse returned by the API.
|
|
1415
|
+
*/
|
|
1416
|
+
createTask(input: {
|
|
1417
|
+
instructions: string;
|
|
1418
|
+
}, output: {
|
|
1419
|
+
schema: JSONSchema;
|
|
1420
|
+
}): Promise<ResearchTaskResponse>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Retrieve a research task by ID.
|
|
1423
|
+
*
|
|
1424
|
+
* Not yet implemented server-side. Calling this will throw until the API is
|
|
1425
|
+
* available.
|
|
1426
|
+
*/
|
|
1427
|
+
getTask(): Promise<ResearchTaskResponse>;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1343
1430
|
/**
|
|
1344
1431
|
* HTTP status codes
|
|
1345
1432
|
*/
|
|
@@ -1694,29 +1781,6 @@ type AnswerStreamResponse = {
|
|
|
1694
1781
|
answer?: string;
|
|
1695
1782
|
citations?: SearchResult<{}>[];
|
|
1696
1783
|
};
|
|
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
1784
|
/**
|
|
1721
1785
|
* The Exa class encapsulates the API's endpoints.
|
|
1722
1786
|
*/
|
|
@@ -1727,6 +1791,10 @@ declare class Exa {
|
|
|
1727
1791
|
* Websets API client
|
|
1728
1792
|
*/
|
|
1729
1793
|
websets: WebsetsClient;
|
|
1794
|
+
/**
|
|
1795
|
+
* Research API client
|
|
1796
|
+
*/
|
|
1797
|
+
research: ResearchClient;
|
|
1730
1798
|
/**
|
|
1731
1799
|
* Helper method to separate out the contents-specific options from the rest.
|
|
1732
1800
|
*/
|
|
@@ -1833,42 +1901,7 @@ declare class Exa {
|
|
|
1833
1901
|
outputSchema?: Record<string, unknown>;
|
|
1834
1902
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
1835
1903
|
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>;
|
|
1904
|
+
private parseSSEStream;
|
|
1872
1905
|
}
|
|
1873
1906
|
|
|
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 ResearchTaskResponse, 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 };
|
|
1907
|
+
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 ResearchTaskResponse, 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,93 @@ declare class WebsetsClient extends WebsetsBaseClient {
|
|
|
1340
1340
|
} | number): Promise<Webset>;
|
|
1341
1341
|
}
|
|
1342
1342
|
|
|
1343
|
+
/**
|
|
1344
|
+
* Enum representing the status of a research task.
|
|
1345
|
+
*/
|
|
1346
|
+
declare enum ResearchStatus {
|
|
1347
|
+
/** The research request has finished successfully. */
|
|
1348
|
+
completed = "completed",
|
|
1349
|
+
/** The research request failed. */
|
|
1350
|
+
failed = "failed"
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Response object returned from the research API.
|
|
1354
|
+
*/
|
|
1355
|
+
type ResearchTaskResponse = {
|
|
1356
|
+
/** Unique identifier for the task. */
|
|
1357
|
+
id: string;
|
|
1358
|
+
/** Current status (may include future enum values served by the API). */
|
|
1359
|
+
status: ResearchStatus | string;
|
|
1360
|
+
/** Structured output that follows the user-provided schema (null while running). */
|
|
1361
|
+
output: Record<string, any> | null;
|
|
1362
|
+
/**
|
|
1363
|
+
* Citations collected while deriving each top-level field in `output`.
|
|
1364
|
+
* The key is the field name, the value is the list of `SearchResult`s that
|
|
1365
|
+
* were used to compute that field.
|
|
1366
|
+
*/
|
|
1367
|
+
citations: Record<string, SearchResult<{}>[]>;
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
|
|
1371
|
+
interface RequestBody {
|
|
1372
|
+
[key: string]: unknown;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Base client class for all Research-related API clients
|
|
1376
|
+
*/
|
|
1377
|
+
declare class ResearchBaseClient {
|
|
1378
|
+
protected client: Exa;
|
|
1379
|
+
/**
|
|
1380
|
+
* Initialize a new Research base client
|
|
1381
|
+
* @param client The Exa client instance
|
|
1382
|
+
*/
|
|
1383
|
+
constructor(client: Exa);
|
|
1384
|
+
/**
|
|
1385
|
+
* Make a request to the Research API (prefixes all paths with `/research`).
|
|
1386
|
+
* @param endpoint The endpoint path, beginning with a slash (e.g. "/tasks").
|
|
1387
|
+
* @param method The HTTP method. Defaults to "POST".
|
|
1388
|
+
* @param data Optional request body
|
|
1389
|
+
* @param params Optional query parameters
|
|
1390
|
+
* @returns The parsed JSON response
|
|
1391
|
+
*/
|
|
1392
|
+
protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Client for interacting with the Research Tasks API.
|
|
1397
|
+
*/
|
|
1398
|
+
declare class ResearchClient extends ResearchBaseClient {
|
|
1399
|
+
constructor(client: Exa);
|
|
1400
|
+
/**
|
|
1401
|
+
* Create and run a research task (blocking call).
|
|
1402
|
+
*
|
|
1403
|
+
* Both parameters are required and have fixed shapes:
|
|
1404
|
+
* 1. `input`
|
|
1405
|
+
* `{ instructions: string }`
|
|
1406
|
+
* • `instructions` – High-level guidance that tells the research agent what to do.
|
|
1407
|
+
* 2. `output`
|
|
1408
|
+
* defines the exact structure you expect back, and guides the research conducted by the agent.
|
|
1409
|
+
* `{ schema: JSONSchema }`.
|
|
1410
|
+
* The agent's response will be validated against this schema.
|
|
1411
|
+
*
|
|
1412
|
+
* @param input Object containing high-level research instructions.
|
|
1413
|
+
* @param output Object containing the expected output schema.
|
|
1414
|
+
* @returns The ResearchTaskResponse returned by the API.
|
|
1415
|
+
*/
|
|
1416
|
+
createTask(input: {
|
|
1417
|
+
instructions: string;
|
|
1418
|
+
}, output: {
|
|
1419
|
+
schema: JSONSchema;
|
|
1420
|
+
}): Promise<ResearchTaskResponse>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Retrieve a research task by ID.
|
|
1423
|
+
*
|
|
1424
|
+
* Not yet implemented server-side. Calling this will throw until the API is
|
|
1425
|
+
* available.
|
|
1426
|
+
*/
|
|
1427
|
+
getTask(): Promise<ResearchTaskResponse>;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1343
1430
|
/**
|
|
1344
1431
|
* HTTP status codes
|
|
1345
1432
|
*/
|
|
@@ -1694,29 +1781,6 @@ type AnswerStreamResponse = {
|
|
|
1694
1781
|
answer?: string;
|
|
1695
1782
|
citations?: SearchResult<{}>[];
|
|
1696
1783
|
};
|
|
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
1784
|
/**
|
|
1721
1785
|
* The Exa class encapsulates the API's endpoints.
|
|
1722
1786
|
*/
|
|
@@ -1727,6 +1791,10 @@ declare class Exa {
|
|
|
1727
1791
|
* Websets API client
|
|
1728
1792
|
*/
|
|
1729
1793
|
websets: WebsetsClient;
|
|
1794
|
+
/**
|
|
1795
|
+
* Research API client
|
|
1796
|
+
*/
|
|
1797
|
+
research: ResearchClient;
|
|
1730
1798
|
/**
|
|
1731
1799
|
* Helper method to separate out the contents-specific options from the rest.
|
|
1732
1800
|
*/
|
|
@@ -1833,42 +1901,7 @@ declare class Exa {
|
|
|
1833
1901
|
outputSchema?: Record<string, unknown>;
|
|
1834
1902
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
1835
1903
|
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>;
|
|
1904
|
+
private parseSSEStream;
|
|
1872
1905
|
}
|
|
1873
1906
|
|
|
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 ResearchTaskResponse, 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 };
|
|
1907
|
+
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 ResearchTaskResponse, 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 };
|