@llamaindex/llama-cloud 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +10 -8
  3. package/client.d.mts +9 -8
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +9 -8
  6. package/client.d.ts.map +1 -1
  7. package/client.js +16 -12
  8. package/client.js.map +1 -1
  9. package/client.mjs +16 -12
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +0 -23
  12. package/core/pagination.d.mts.map +1 -1
  13. package/core/pagination.d.ts +0 -23
  14. package/core/pagination.d.ts.map +1 -1
  15. package/core/pagination.js +1 -32
  16. package/core/pagination.js.map +1 -1
  17. package/core/pagination.mjs +0 -30
  18. package/core/pagination.mjs.map +1 -1
  19. package/package.json +12 -1
  20. package/resources/beta/batch/batch.d.mts +55 -30
  21. package/resources/beta/batch/batch.d.mts.map +1 -1
  22. package/resources/beta/batch/batch.d.ts +55 -30
  23. package/resources/beta/batch/batch.d.ts.map +1 -1
  24. package/resources/beta/batch/batch.js +14 -11
  25. package/resources/beta/batch/batch.js.map +1 -1
  26. package/resources/beta/batch/batch.mjs +14 -11
  27. package/resources/beta/batch/batch.mjs.map +1 -1
  28. package/resources/beta/batch/job-items.d.mts +36 -13
  29. package/resources/beta/batch/job-items.d.mts.map +1 -1
  30. package/resources/beta/batch/job-items.d.ts +36 -13
  31. package/resources/beta/batch/job-items.d.ts.map +1 -1
  32. package/resources/beta/batch/job-items.js +6 -8
  33. package/resources/beta/batch/job-items.js.map +1 -1
  34. package/resources/beta/batch/job-items.mjs +6 -8
  35. package/resources/beta/batch/job-items.mjs.map +1 -1
  36. package/resources/beta/sheets.d.mts +16 -0
  37. package/resources/beta/sheets.d.mts.map +1 -1
  38. package/resources/beta/sheets.d.ts +16 -0
  39. package/resources/beta/sheets.d.ts.map +1 -1
  40. package/resources/beta/split.d.mts +60 -16
  41. package/resources/beta/split.d.mts.map +1 -1
  42. package/resources/beta/split.d.ts +60 -16
  43. package/resources/beta/split.d.ts.map +1 -1
  44. package/resources/beta/split.js.map +1 -1
  45. package/resources/beta/split.mjs.map +1 -1
  46. package/resources/classifier/jobs.d.mts +20 -3
  47. package/resources/classifier/jobs.d.mts.map +1 -1
  48. package/resources/classifier/jobs.d.ts +20 -3
  49. package/resources/classifier/jobs.d.ts.map +1 -1
  50. package/resources/classifier/jobs.js +8 -0
  51. package/resources/classifier/jobs.js.map +1 -1
  52. package/resources/classifier/jobs.mjs +8 -0
  53. package/resources/classifier/jobs.mjs.map +1 -1
  54. package/resources/classify.d.mts +373 -0
  55. package/resources/classify.d.mts.map +1 -0
  56. package/resources/classify.d.ts +373 -0
  57. package/resources/classify.d.ts.map +1 -0
  58. package/resources/classify.js +54 -0
  59. package/resources/classify.js.map +1 -0
  60. package/resources/classify.mjs +50 -0
  61. package/resources/classify.mjs.map +1 -0
  62. package/resources/extract.d.mts +1588 -0
  63. package/resources/extract.d.mts.map +1 -0
  64. package/resources/extract.d.ts +1588 -0
  65. package/resources/extract.d.ts.map +1 -0
  66. package/resources/extract.js +217 -0
  67. package/resources/extract.js.map +1 -0
  68. package/resources/extract.mjs +213 -0
  69. package/resources/extract.mjs.map +1 -0
  70. package/resources/files.d.mts +52 -38
  71. package/resources/files.d.mts.map +1 -1
  72. package/resources/files.d.ts +52 -38
  73. package/resources/files.d.ts.map +1 -1
  74. package/resources/files.js +10 -9
  75. package/resources/files.js.map +1 -1
  76. package/resources/files.mjs +10 -9
  77. package/resources/files.mjs.map +1 -1
  78. package/resources/index.d.mts +2 -1
  79. package/resources/index.d.mts.map +1 -1
  80. package/resources/index.d.ts +2 -1
  81. package/resources/index.d.ts.map +1 -1
  82. package/resources/index.js +5 -3
  83. package/resources/index.js.map +1 -1
  84. package/resources/index.mjs +2 -1
  85. package/resources/index.mjs.map +1 -1
  86. package/resources/parsing.d.mts +324 -138
  87. package/resources/parsing.d.mts.map +1 -1
  88. package/resources/parsing.d.ts +324 -138
  89. package/resources/parsing.d.ts.map +1 -1
  90. package/resources/parsing.js +30 -4
  91. package/resources/parsing.js.map +1 -1
  92. package/resources/parsing.mjs +30 -4
  93. package/resources/parsing.mjs.map +1 -1
  94. package/resources/pipelines/pipelines.d.mts +59 -13
  95. package/resources/pipelines/pipelines.d.mts.map +1 -1
  96. package/resources/pipelines/pipelines.d.ts +59 -13
  97. package/resources/pipelines/pipelines.d.ts.map +1 -1
  98. package/resources/pipelines/pipelines.js +24 -9
  99. package/resources/pipelines/pipelines.js.map +1 -1
  100. package/resources/pipelines/pipelines.mjs +24 -9
  101. package/resources/pipelines/pipelines.mjs.map +1 -1
  102. package/resources/pipelines/sync.d.mts +5 -3
  103. package/resources/pipelines/sync.d.mts.map +1 -1
  104. package/resources/pipelines/sync.d.ts +5 -3
  105. package/resources/pipelines/sync.d.ts.map +1 -1
  106. package/resources/pipelines/sync.js +5 -3
  107. package/resources/pipelines/sync.js.map +1 -1
  108. package/resources/pipelines/sync.mjs +5 -3
  109. package/resources/pipelines/sync.mjs.map +1 -1
  110. package/src/client.ts +86 -22
  111. package/src/core/pagination.ts +0 -71
  112. package/src/resources/beta/batch/batch.ts +75 -30
  113. package/src/resources/beta/batch/job-items.ts +56 -13
  114. package/src/resources/beta/sheets.ts +20 -0
  115. package/src/resources/beta/split.ts +70 -17
  116. package/src/resources/classifier/jobs.ts +20 -3
  117. package/src/resources/classify.ts +486 -0
  118. package/src/resources/extract.ts +2045 -0
  119. package/src/resources/files.ts +52 -38
  120. package/src/resources/index.ts +35 -1
  121. package/src/resources/parsing.ts +367 -136
  122. package/src/resources/pipelines/pipelines.ts +80 -14
  123. package/src/resources/pipelines/sync.ts +5 -3
  124. package/src/version.ts +1 -1
  125. package/version.d.mts +1 -1
  126. package/version.d.ts +1 -1
  127. package/version.js +1 -1
  128. package/version.mjs +1 -1
  129. package/resources/extraction/extraction-agents/extraction-agents.d.mts +0 -126
  130. package/resources/extraction/extraction-agents/extraction-agents.d.mts.map +0 -1
  131. package/resources/extraction/extraction-agents/extraction-agents.d.ts +0 -126
  132. package/resources/extraction/extraction-agents/extraction-agents.d.ts.map +0 -1
  133. package/resources/extraction/extraction-agents/extraction-agents.js +0 -56
  134. package/resources/extraction/extraction-agents/extraction-agents.js.map +0 -1
  135. package/resources/extraction/extraction-agents/extraction-agents.mjs +0 -51
  136. package/resources/extraction/extraction-agents/extraction-agents.mjs.map +0 -1
  137. package/resources/extraction/extraction-agents/index.d.mts +0 -3
  138. package/resources/extraction/extraction-agents/index.d.mts.map +0 -1
  139. package/resources/extraction/extraction-agents/index.d.ts +0 -3
  140. package/resources/extraction/extraction-agents/index.d.ts.map +0 -1
  141. package/resources/extraction/extraction-agents/index.js +0 -9
  142. package/resources/extraction/extraction-agents/index.js.map +0 -1
  143. package/resources/extraction/extraction-agents/index.mjs +0 -4
  144. package/resources/extraction/extraction-agents/index.mjs.map +0 -1
  145. package/resources/extraction/extraction-agents/schema.d.mts +0 -75
  146. package/resources/extraction/extraction-agents/schema.d.mts.map +0 -1
  147. package/resources/extraction/extraction-agents/schema.d.ts +0 -75
  148. package/resources/extraction/extraction-agents/schema.d.ts.map +0 -1
  149. package/resources/extraction/extraction-agents/schema.js +0 -28
  150. package/resources/extraction/extraction-agents/schema.js.map +0 -1
  151. package/resources/extraction/extraction-agents/schema.mjs +0 -24
  152. package/resources/extraction/extraction-agents/schema.mjs.map +0 -1
  153. package/resources/extraction/extraction-agents.d.mts +0 -2
  154. package/resources/extraction/extraction-agents.d.mts.map +0 -1
  155. package/resources/extraction/extraction-agents.d.ts +0 -2
  156. package/resources/extraction/extraction-agents.d.ts.map +0 -1
  157. package/resources/extraction/extraction-agents.js +0 -6
  158. package/resources/extraction/extraction-agents.js.map +0 -1
  159. package/resources/extraction/extraction-agents.mjs +0 -3
  160. package/resources/extraction/extraction-agents.mjs.map +0 -1
  161. package/resources/extraction/extraction.d.mts +0 -118
  162. package/resources/extraction/extraction.d.mts.map +0 -1
  163. package/resources/extraction/extraction.d.ts +0 -118
  164. package/resources/extraction/extraction.d.ts.map +0 -1
  165. package/resources/extraction/extraction.js +0 -91
  166. package/resources/extraction/extraction.js.map +0 -1
  167. package/resources/extraction/extraction.mjs +0 -86
  168. package/resources/extraction/extraction.mjs.map +0 -1
  169. package/resources/extraction/index.d.mts +0 -5
  170. package/resources/extraction/index.d.mts.map +0 -1
  171. package/resources/extraction/index.d.ts +0 -5
  172. package/resources/extraction/index.d.ts.map +0 -1
  173. package/resources/extraction/index.js +0 -13
  174. package/resources/extraction/index.js.map +0 -1
  175. package/resources/extraction/index.mjs +0 -6
  176. package/resources/extraction/index.mjs.map +0 -1
  177. package/resources/extraction/jobs.d.mts +0 -280
  178. package/resources/extraction/jobs.d.mts.map +0 -1
  179. package/resources/extraction/jobs.d.ts +0 -280
  180. package/resources/extraction/jobs.d.ts.map +0 -1
  181. package/resources/extraction/jobs.js +0 -179
  182. package/resources/extraction/jobs.js.map +0 -1
  183. package/resources/extraction/jobs.mjs +0 -175
  184. package/resources/extraction/jobs.mjs.map +0 -1
  185. package/resources/extraction/runs.d.mts +0 -198
  186. package/resources/extraction/runs.d.mts.map +0 -1
  187. package/resources/extraction/runs.d.ts +0 -198
  188. package/resources/extraction/runs.d.ts.map +0 -1
  189. package/resources/extraction/runs.js +0 -42
  190. package/resources/extraction/runs.js.map +0 -1
  191. package/resources/extraction/runs.mjs +0 -38
  192. package/resources/extraction/runs.mjs.map +0 -1
  193. package/resources/extraction.d.mts +0 -2
  194. package/resources/extraction.d.mts.map +0 -1
  195. package/resources/extraction.d.ts +0 -2
  196. package/resources/extraction.d.ts.map +0 -1
  197. package/resources/extraction.js +0 -6
  198. package/resources/extraction.js.map +0 -1
  199. package/resources/extraction.mjs +0 -3
  200. package/resources/extraction.mjs.map +0 -1
  201. package/src/resources/extraction/extraction-agents/extraction-agents.ts +0 -196
  202. package/src/resources/extraction/extraction-agents/index.ts +0 -18
  203. package/src/resources/extraction/extraction-agents/schema.ts +0 -100
  204. package/src/resources/extraction/extraction-agents.ts +0 -3
  205. package/src/resources/extraction/extraction.ts +0 -224
  206. package/src/resources/extraction/index.ts +0 -34
  207. package/src/resources/extraction/jobs.ts +0 -414
  208. package/src/resources/extraction/runs.ts +0 -315
  209. package/src/resources/extraction.ts +0 -3
@@ -1,196 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { APIResource } from '../../../core/resource';
4
- import * as RunsAPI from '../runs';
5
- import * as SchemaAPI from './schema';
6
- import {
7
- Schema,
8
- SchemaGenerateSchemaParams,
9
- SchemaGenerateSchemaResponse,
10
- SchemaValidateSchemaParams,
11
- SchemaValidateSchemaResponse,
12
- } from './schema';
13
- import { APIPromise } from '../../../core/api-promise';
14
- import { RequestOptions } from '../../../internal/request-options';
15
- import { path } from '../../../internal/utils/path';
16
-
17
- export class ExtractionAgents extends APIResource {
18
- schema: SchemaAPI.Schema = new SchemaAPI.Schema(this._client);
19
-
20
- /**
21
- * Create Extraction Agent
22
- */
23
- create(params: ExtractionAgentCreateParams, options?: RequestOptions): APIPromise<ExtractAgent> {
24
- const { organization_id, project_id, ...body } = params;
25
- return this._client.post('/api/v1/extraction/extraction-agents', {
26
- query: { organization_id, project_id },
27
- body,
28
- ...options,
29
- });
30
- }
31
-
32
- /**
33
- * Update Extraction Agent
34
- */
35
- update(
36
- extractionAgentID: string,
37
- body: ExtractionAgentUpdateParams,
38
- options?: RequestOptions,
39
- ): APIPromise<ExtractAgent> {
40
- return this._client.put(path`/api/v1/extraction/extraction-agents/${extractionAgentID}`, {
41
- body,
42
- ...options,
43
- });
44
- }
45
-
46
- /**
47
- * List Extraction Agents
48
- */
49
- list(
50
- query: ExtractionAgentListParams | null | undefined = {},
51
- options?: RequestOptions,
52
- ): APIPromise<ExtractionAgentListResponse> {
53
- return this._client.get('/api/v1/extraction/extraction-agents', { query, ...options });
54
- }
55
-
56
- /**
57
- * Delete Extraction Agent
58
- */
59
- delete(extractionAgentID: string, options?: RequestOptions): APIPromise<unknown> {
60
- return this._client.delete(path`/api/v1/extraction/extraction-agents/${extractionAgentID}`, options);
61
- }
62
-
63
- /**
64
- * Get Extraction Agent
65
- */
66
- get(extractionAgentID: string, options?: RequestOptions): APIPromise<ExtractAgent> {
67
- return this._client.get(path`/api/v1/extraction/extraction-agents/${extractionAgentID}`, options);
68
- }
69
- }
70
-
71
- /**
72
- * Schema and configuration for an extraction agent.
73
- */
74
- export interface ExtractAgent {
75
- /**
76
- * The id of the extraction agent.
77
- */
78
- id: string;
79
-
80
- /**
81
- * The configuration parameters for the extraction agent.
82
- */
83
- config: RunsAPI.ExtractConfig;
84
-
85
- /**
86
- * The schema of the data.
87
- */
88
- data_schema: {
89
- [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
90
- };
91
-
92
- /**
93
- * The name of the extraction agent.
94
- */
95
- name: string;
96
-
97
- /**
98
- * The ID of the project that the extraction agent belongs to.
99
- */
100
- project_id: string;
101
-
102
- /**
103
- * The creation time of the extraction agent.
104
- */
105
- created_at?: string | null;
106
-
107
- /**
108
- * Custom configuration type for the extraction agent. Currently supports
109
- * 'default'.
110
- */
111
- custom_configuration?: 'default' | null;
112
-
113
- /**
114
- * The last update time of the extraction agent.
115
- */
116
- updated_at?: string | null;
117
- }
118
-
119
- export type ExtractionAgentListResponse = Array<ExtractAgent>;
120
-
121
- export type ExtractionAgentDeleteResponse = unknown;
122
-
123
- export interface ExtractionAgentCreateParams {
124
- /**
125
- * Body param: The configuration parameters for the extraction agent.
126
- */
127
- config: RunsAPI.ExtractConfig;
128
-
129
- /**
130
- * Body param: The schema of the data.
131
- */
132
- data_schema:
133
- | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
134
- | string;
135
-
136
- /**
137
- * Body param: The name of the extraction schema
138
- */
139
- name: string;
140
-
141
- /**
142
- * Query param
143
- */
144
- organization_id?: string | null;
145
-
146
- /**
147
- * Query param
148
- */
149
- project_id?: string | null;
150
- }
151
-
152
- export interface ExtractionAgentUpdateParams {
153
- /**
154
- * The configuration parameters for the extraction agent.
155
- */
156
- config: RunsAPI.ExtractConfig;
157
-
158
- /**
159
- * The schema of the data
160
- */
161
- data_schema:
162
- | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
163
- | string;
164
- }
165
-
166
- export interface ExtractionAgentListParams {
167
- /**
168
- * Whether to include default agents in the results
169
- */
170
- include_default?: boolean;
171
-
172
- organization_id?: string | null;
173
-
174
- project_id?: string | null;
175
- }
176
-
177
- ExtractionAgents.Schema = Schema;
178
-
179
- export declare namespace ExtractionAgents {
180
- export {
181
- type ExtractAgent as ExtractAgent,
182
- type ExtractionAgentListResponse as ExtractionAgentListResponse,
183
- type ExtractionAgentDeleteResponse as ExtractionAgentDeleteResponse,
184
- type ExtractionAgentCreateParams as ExtractionAgentCreateParams,
185
- type ExtractionAgentUpdateParams as ExtractionAgentUpdateParams,
186
- type ExtractionAgentListParams as ExtractionAgentListParams,
187
- };
188
-
189
- export {
190
- Schema as Schema,
191
- type SchemaGenerateSchemaResponse as SchemaGenerateSchemaResponse,
192
- type SchemaValidateSchemaResponse as SchemaValidateSchemaResponse,
193
- type SchemaGenerateSchemaParams as SchemaGenerateSchemaParams,
194
- type SchemaValidateSchemaParams as SchemaValidateSchemaParams,
195
- };
196
- }
@@ -1,18 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- export {
4
- ExtractionAgents,
5
- type ExtractAgent,
6
- type ExtractionAgentListResponse,
7
- type ExtractionAgentDeleteResponse,
8
- type ExtractionAgentCreateParams,
9
- type ExtractionAgentUpdateParams,
10
- type ExtractionAgentListParams,
11
- } from './extraction-agents';
12
- export {
13
- Schema,
14
- type SchemaGenerateSchemaResponse,
15
- type SchemaValidateSchemaResponse,
16
- type SchemaGenerateSchemaParams,
17
- type SchemaValidateSchemaParams,
18
- } from './schema';
@@ -1,100 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { APIResource } from '../../../core/resource';
4
- import { APIPromise } from '../../../core/api-promise';
5
- import { RequestOptions } from '../../../internal/request-options';
6
-
7
- export class Schema extends APIResource {
8
- /**
9
- * Generates or refines an extraction agent's schema definition from a file,
10
- * natural language prompt, or existing schema.
11
- */
12
- generateSchema(
13
- params: SchemaGenerateSchemaParams,
14
- options?: RequestOptions,
15
- ): APIPromise<SchemaGenerateSchemaResponse> {
16
- const { organization_id, project_id, ...body } = params;
17
- return this._client.post('/api/v1/extraction/extraction-agents/schema/generate', {
18
- query: { organization_id, project_id },
19
- body,
20
- ...options,
21
- });
22
- }
23
-
24
- /**
25
- * Validates an extraction agent's schema definition. Returns the normalized and
26
- * validated schema if valid, otherwise raises an HTTP 400.
27
- */
28
- validateSchema(
29
- body: SchemaValidateSchemaParams,
30
- options?: RequestOptions,
31
- ): APIPromise<SchemaValidateSchemaResponse> {
32
- return this._client.post('/api/v1/extraction/extraction-agents/schema/validation', { body, ...options });
33
- }
34
- }
35
-
36
- /**
37
- * Response schema for schema generation.
38
- */
39
- export interface SchemaGenerateSchemaResponse {
40
- /**
41
- * The generated JSON schema
42
- */
43
- data_schema: {
44
- [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
45
- };
46
- }
47
-
48
- /**
49
- * Response schema for schema validation.
50
- */
51
- export interface SchemaValidateSchemaResponse {
52
- data_schema: {
53
- [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null;
54
- };
55
- }
56
-
57
- export interface SchemaGenerateSchemaParams {
58
- /**
59
- * Query param
60
- */
61
- organization_id?: string | null;
62
-
63
- /**
64
- * Query param
65
- */
66
- project_id?: string | null;
67
-
68
- /**
69
- * Body param: Optional schema to validate, refine, or extend during generation
70
- */
71
- data_schema?:
72
- | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
73
- | string
74
- | null;
75
-
76
- /**
77
- * Body param: Optional file ID to analyze for schema generation
78
- */
79
- file_id?: string | null;
80
-
81
- /**
82
- * Body param: Natural language description of the data structure to extract
83
- */
84
- prompt?: string | null;
85
- }
86
-
87
- export interface SchemaValidateSchemaParams {
88
- data_schema:
89
- | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
90
- | string;
91
- }
92
-
93
- export declare namespace Schema {
94
- export {
95
- type SchemaGenerateSchemaResponse as SchemaGenerateSchemaResponse,
96
- type SchemaValidateSchemaResponse as SchemaValidateSchemaResponse,
97
- type SchemaGenerateSchemaParams as SchemaGenerateSchemaParams,
98
- type SchemaValidateSchemaParams as SchemaValidateSchemaParams,
99
- };
100
- }
@@ -1,3 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- export * from './extraction-agents/index';
@@ -1,224 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { APIResource } from '../../core/resource';
4
- import * as JobsAPI from './jobs';
5
- import {
6
- ExtractJob,
7
- JobCreateParams,
8
- JobFileParams,
9
- JobGetResultParams,
10
- JobGetResultResponse,
11
- JobListParams,
12
- JobListResponse,
13
- Jobs,
14
- WebhookConfiguration,
15
- } from './jobs';
16
- import * as RunsAPI from './runs';
17
- import {
18
- ExtractConfig,
19
- ExtractRun,
20
- ExtractRunsPaginatedExtractRuns,
21
- RunDeleteParams,
22
- RunDeleteResponse,
23
- RunGetByJobParams,
24
- RunGetParams,
25
- RunListParams,
26
- Runs,
27
- } from './runs';
28
- import * as ExtractionAgentsAPI from './extraction-agents/extraction-agents';
29
- import {
30
- ExtractAgent,
31
- ExtractionAgentCreateParams,
32
- ExtractionAgentDeleteResponse,
33
- ExtractionAgentListParams,
34
- ExtractionAgentListResponse,
35
- ExtractionAgentUpdateParams,
36
- ExtractionAgents,
37
- } from './extraction-agents/extraction-agents';
38
- import { APIPromise } from '../../core/api-promise';
39
- import { RequestOptions } from '../../internal/request-options';
40
- import { PollingOptions, DEFAULT_TIMEOUT } from '../../core/polling';
41
-
42
- export class Extraction extends APIResource {
43
- jobs: JobsAPI.Jobs = new JobsAPI.Jobs(this._client);
44
- runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
45
- extractionAgents: ExtractionAgentsAPI.ExtractionAgents = new ExtractionAgentsAPI.ExtractionAgents(
46
- this._client,
47
- );
48
-
49
- /**
50
- * Stateless extraction endpoint that uses a default extraction agent in the user's
51
- * default project. Requires data_schema, config, and either file_id, text, or
52
- * base64 encoded file data.
53
- */
54
- run(params: ExtractionRunParams, options?: RequestOptions): APIPromise<JobsAPI.ExtractJob> {
55
- const { organization_id, project_id, ...body } = params;
56
- return this._client.post('/api/v1/extraction/run', {
57
- query: { organization_id, project_id },
58
- body,
59
- ...options,
60
- });
61
- }
62
-
63
- /**
64
- * Run a stateless extraction and wait for it to complete, returning the result.
65
- *
66
- * This is a convenience method that combines run(), waitForCompletion(),
67
- * and getResult() into a single call for the most common end-to-end workflow.
68
- *
69
- * This endpoint uses a default extraction agent in the user's default project.
70
- *
71
- * @param params - Extraction parameters
72
- * @param options - Polling configuration and request options
73
- * @returns The extraction result (JobGetResultResponse)
74
- * @throws {PollingTimeoutError} If the job doesn't complete within the timeout period
75
- * @throws {PollingError} If the job fails or is cancelled
76
- *
77
- * @example
78
- * ```typescript
79
- * import { LlamaCloud } from 'llama-cloud';
80
- *
81
- * const client = new LlamaCloud({ apiKey: '...' });
82
- *
83
- * // One-shot: run stateless extraction, wait for completion, and get result
84
- * const result = await client.extraction.extract({
85
- * config: {
86
- * chunk_mode: 'PAGE',
87
- * cite_sources: true,
88
- * extraction_target: 'PER_DOC',
89
- * extraction_mode: 'BALANCED'
90
- * },
91
- * data_schema: { model_names: { type: 'array', items: { type: 'string' } } },
92
- * file_id: 'file_id'
93
- * }, { verbose: true });
94
- *
95
- * // Result is ready to use immediately
96
- * console.log(result.data);
97
- * ```
98
- */
99
- async extract(
100
- params: ExtractionRunParams,
101
- options?: PollingOptions & RequestOptions,
102
- ): Promise<JobsAPI.JobGetResultResponse> {
103
- const { pollingInterval, maxInterval, timeout, backoff, verbose, ...requestOptions } = options || {};
104
-
105
- // Run the extraction job
106
- const job = await this.run(params, requestOptions);
107
-
108
- // Wait for completion
109
- await this.jobs.waitForCompletion(job.id, {
110
- pollingInterval,
111
- maxInterval,
112
- timeout: timeout || DEFAULT_TIMEOUT,
113
- backoff,
114
- verbose,
115
- ...requestOptions,
116
- });
117
-
118
- // Get and return the result
119
- return await this.jobs.getResult(job.id, {}, requestOptions);
120
- }
121
- }
122
-
123
- export interface ExtractionRunParams {
124
- /**
125
- * Body param: The configuration parameters for the extraction
126
- */
127
- config: RunsAPI.ExtractConfig;
128
-
129
- /**
130
- * Body param: The schema of the data to extract
131
- */
132
- data_schema:
133
- | { [key: string]: { [key: string]: unknown } | Array<unknown> | string | number | boolean | null }
134
- | string;
135
-
136
- /**
137
- * Query param
138
- */
139
- organization_id?: string | null;
140
-
141
- /**
142
- * Query param
143
- */
144
- project_id?: string | null;
145
-
146
- /**
147
- * Body param: Schema for file data with base64 content and MIME type.
148
- */
149
- file?: ExtractionRunParams.File | null;
150
-
151
- /**
152
- * Body param: The ID of the file to extract from
153
- */
154
- file_id?: string | null;
155
-
156
- /**
157
- * Body param: The text content to extract from
158
- */
159
- text?: string | null;
160
-
161
- /**
162
- * Body param: The outbound webhook configurations
163
- */
164
- webhook_configurations?: Array<JobsAPI.WebhookConfiguration> | null;
165
- }
166
-
167
- export namespace ExtractionRunParams {
168
- /**
169
- * Schema for file data with base64 content and MIME type.
170
- */
171
- export interface File {
172
- /**
173
- * The file content as base64-encoded string
174
- */
175
- data: string;
176
-
177
- /**
178
- * The MIME type of the file (e.g., 'application/pdf', 'text/plain')
179
- */
180
- mime_type: string;
181
- }
182
- }
183
-
184
- Extraction.Jobs = Jobs;
185
- Extraction.Runs = Runs;
186
- Extraction.ExtractionAgents = ExtractionAgents;
187
-
188
- export declare namespace Extraction {
189
- export { type ExtractionRunParams as ExtractionRunParams };
190
-
191
- export {
192
- Jobs as Jobs,
193
- type ExtractJob as ExtractJob,
194
- type WebhookConfiguration as WebhookConfiguration,
195
- type JobListResponse as JobListResponse,
196
- type JobGetResultResponse as JobGetResultResponse,
197
- type JobCreateParams as JobCreateParams,
198
- type JobListParams as JobListParams,
199
- type JobFileParams as JobFileParams,
200
- type JobGetResultParams as JobGetResultParams,
201
- };
202
-
203
- export {
204
- Runs as Runs,
205
- type ExtractConfig as ExtractConfig,
206
- type ExtractRun as ExtractRun,
207
- type RunDeleteResponse as RunDeleteResponse,
208
- type ExtractRunsPaginatedExtractRuns as ExtractRunsPaginatedExtractRuns,
209
- type RunListParams as RunListParams,
210
- type RunDeleteParams as RunDeleteParams,
211
- type RunGetParams as RunGetParams,
212
- type RunGetByJobParams as RunGetByJobParams,
213
- };
214
-
215
- export {
216
- ExtractionAgents as ExtractionAgents,
217
- type ExtractAgent as ExtractAgent,
218
- type ExtractionAgentListResponse as ExtractionAgentListResponse,
219
- type ExtractionAgentDeleteResponse as ExtractionAgentDeleteResponse,
220
- type ExtractionAgentCreateParams as ExtractionAgentCreateParams,
221
- type ExtractionAgentUpdateParams as ExtractionAgentUpdateParams,
222
- type ExtractionAgentListParams as ExtractionAgentListParams,
223
- };
224
- }
@@ -1,34 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- export { Extraction, type ExtractionRunParams } from './extraction';
4
- export {
5
- ExtractionAgents,
6
- type ExtractAgent,
7
- type ExtractionAgentListResponse,
8
- type ExtractionAgentDeleteResponse,
9
- type ExtractionAgentCreateParams,
10
- type ExtractionAgentUpdateParams,
11
- type ExtractionAgentListParams,
12
- } from './extraction-agents/index';
13
- export {
14
- Jobs,
15
- type ExtractJob,
16
- type WebhookConfiguration,
17
- type JobListResponse,
18
- type JobGetResultResponse,
19
- type JobCreateParams,
20
- type JobListParams,
21
- type JobFileParams,
22
- type JobGetResultParams,
23
- } from './jobs';
24
- export {
25
- Runs,
26
- type ExtractConfig,
27
- type ExtractRun,
28
- type RunDeleteResponse,
29
- type RunListParams,
30
- type RunDeleteParams,
31
- type RunGetParams,
32
- type RunGetByJobParams,
33
- type ExtractRunsPaginatedExtractRuns,
34
- } from './runs';