Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ console.log(response.markdown);

#### V2 Extract

Extract structured data from Markdown using a JSON schema. Provide exactly one of `markdown`, `markdown_ref` (from `client.v2.files.upload`), or `markdown_url`.
Extract structured data from Markdown using a JSON schema. Provide exactly one of `markdown` or `markdown_url`.

```ts
const response = await client.v2.extract({
Expand All @@ -231,16 +231,6 @@ console.log(done.status, done.result);
// client.v2.extractJobs.{create,get,list,wait} mirror the same shape for extract jobs.
```

#### File staging

`client.v2.files.upload` stages bytes on the ADE data plane and returns a `file_ref` you can pass as `markdown_ref` to extract:

<!-- prettier-ignore -->
```ts
const fileRef = await client.v2.files.upload({ file: fs.createReadStream('doc.md') });
const result = await client.v2.extract({ schema: { type: 'object' }, markdown_ref: fileRef });
```

`client.v2.parse` and `client.v2.extract` also accept `saveTo`, with the same auto-naming behavior as the V1 methods above.

#### Workflows (`parse-extract`)
Expand Down
8 changes: 0 additions & 8 deletions src/resources/v2/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export interface V2ExtractParams {
/** Markdown content to extract data from. */
markdown?: string | null;

/** A reference (e.g. from a prior parse or `files.upload`) to markdown content. */
markdown_ref?: string | null;

/** URL to the markdown file to extract data from. */
markdown_url?: string | null;

Expand All @@ -38,9 +35,6 @@ export interface V2ExtractParams {
* prune unsupported fields and continue. Sent as `options.strict`.
*/
strict?: boolean | null;

/** An idempotency key for the request. */
idempotency_key?: string | null;
}

export interface V2ExtractJobCreateParams extends V2ExtractParams {
Expand All @@ -55,10 +49,8 @@ export function buildExtractBody(params: V2ExtractJobCreateParams): Record<strin
const body: Record<string, unknown> = { schema: coerceSchema(params.schema) };
const entries: Array<[string, unknown]> = [
['markdown', params.markdown],
['markdown_ref', params.markdown_ref],
['markdown_url', params.markdown_url],
['model', params.model],
['idempotency_key', params.idempotency_key],
['service_tier', params.service_tier],
];
for (const [key, value] of entries) {
Expand Down
5 changes: 2 additions & 3 deletions src/resources/v2/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export interface FileUploadParams {

export class Files extends V2Resource {
/**
* Stage a file's bytes on the ADE data plane and return a `file_ref` string,
* which can be passed as `markdown_ref` to `client.v2.extract` /
* `client.v2.extractJobs.create`. Served on the ADE host under `/v1/files`.
* Stage a file's bytes on the ADE data plane and return a `file_ref` string.
* Served on the ADE host under `/v1/files`.
*/
async upload(body: FileUploadParams, options?: RequestOptions): Promise<string> {
const response = await this._client.post<V2FileUploadResponse>(
Expand Down
5 changes: 2 additions & 3 deletions src/resources/v2/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export class V2 extends V2Resource {
/**
* Extract structured data from markdown synchronously (`POST /v2/extract`,
* JSON body). `schema` accepts a JSON-Schema object or a JSON-encoded string.
* Provide exactly one of `markdown`, `markdown_ref`, or `markdown_url`.
* Rejects with `V2SyncTimeoutError` on a 504; use `extractJobs` for
* long-running documents.
* Provide exactly one of `markdown` or `markdown_url`. Rejects with
* `V2SyncTimeoutError` on a 504; use `extractJobs` for long-running documents.
*/
async extract(
body: V2ExtractParams & { saveTo?: string },
Expand Down
4 changes: 0 additions & 4 deletions src/resources/v2/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export interface V2WorkflowParams {

/** Optional projection map: response field name → `"$output.<step>.<field>..."`. */
output?: Record<string, string> | null;

idempotency_key?: string | null;
}

export interface V2WorkflowJobCreateParams extends V2WorkflowParams {
Expand Down Expand Up @@ -101,7 +99,6 @@ export function prepareWorkflowRequest(params: V2WorkflowJobCreateParams): Prepa
if (files.length === 0) {
const body: Record<string, unknown> = { inputs: resolvedInputs, steps: params.steps };
if (params.output != null) body['output'] = params.output;
if (params.idempotency_key != null) body['idempotency_key'] = params.idempotency_key;
if (params.service_tier != null) body['service_tier'] = params.service_tier;
return { multipart: false, body };
}
Expand All @@ -112,7 +109,6 @@ export function prepareWorkflowRequest(params: V2WorkflowJobCreateParams): Prepa
steps: JSON.stringify(params.steps),
};
if (params.output != null) form['output'] = JSON.stringify(params.output);
if (params.idempotency_key != null) form['idempotency_key'] = params.idempotency_key;
if (params.service_tier != null) form['service_tier'] = params.service_tier;
for (const [name, file] of files) form[name] = file;
return { multipart: true, body: form };
Expand Down