sarvamai 1.1.12 → 1.1.13
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/cjs/BaseClient.js +2 -2
- package/dist/cjs/api/resources/docAi/client/Client.d.ts +78 -8
- package/dist/cjs/api/resources/docAi/client/Client.js +233 -12
- package/dist/cjs/api/resources/docAi/client/requests/DocAiClassifyRequest.d.ts +17 -0
- package/dist/cjs/api/resources/docAi/client/requests/DocAiExtractRequest.d.ts +1 -1
- package/dist/cjs/api/resources/docAi/client/requests/DocAiGetResultsRequest.d.ts +8 -0
- package/dist/cjs/api/resources/docAi/client/requests/{DocAiDigitiseRequest.d.ts → DocAiParseRequest.d.ts} +4 -4
- package/dist/cjs/api/resources/docAi/client/requests/{DocAiDigitiseRequest.js → DocAiParseRequest.js} +5 -5
- package/dist/cjs/api/resources/docAi/client/requests/DocAiSplitRequest.d.ts +17 -0
- package/dist/cjs/api/resources/docAi/client/requests/DocAiSplitRequest.js +3 -0
- package/dist/cjs/api/resources/docAi/client/requests/index.d.ts +3 -1
- package/dist/cjs/api/resources/docAi/client/requests/index.js +3 -3
- package/dist/cjs/api/resources/docAi/types/DocAiGetResultsResponse.d.ts +9 -3
- package/dist/cjs/api/resources/documentTranslation/client/requests/CreateDocumentJobRequest.d.ts +1 -1
- package/dist/cjs/api/resources/documentTranslation/client/requests/DocumentTranslationTriggerExportRequest.d.ts +1 -0
- package/dist/cjs/api/types/ChunkMetrics.d.ts +6 -0
- package/dist/cjs/api/types/ChunkMetrics.js +3 -0
- package/dist/cjs/api/types/ConfigureConnection.d.ts +3 -3
- package/dist/cjs/api/types/ConfigureConnection.js +3 -3
- package/dist/cjs/api/types/DocAiBatchDocument.d.ts +10 -0
- package/dist/cjs/api/types/DocAiBatchDocument.js +3 -0
- package/dist/cjs/api/types/DocAiCapabilitiesResponse.d.ts +23 -0
- package/dist/cjs/api/types/DocAiCapabilitiesResponse.js +3 -0
- package/dist/cjs/api/types/DocAiCapabilityLimits.d.ts +12 -0
- package/dist/cjs/api/types/DocAiCapabilityLimits.js +3 -0
- package/dist/cjs/api/types/DocAiClassifyCategory.d.ts +9 -0
- package/dist/cjs/api/types/DocAiClassifyCategory.js +3 -0
- package/dist/cjs/api/types/DocAiClassifyConfig.d.ts +33 -0
- package/dist/cjs/api/types/DocAiClassifyConfig.js +17 -0
- package/dist/cjs/api/types/DocAiClassifyDecision.d.ts +24 -0
- package/dist/cjs/api/types/DocAiClassifyDecision.js +3 -0
- package/dist/cjs/api/types/DocAiClassifyInspection.d.ts +27 -0
- package/dist/cjs/api/types/DocAiClassifyInspection.js +15 -0
- package/dist/cjs/api/types/DocAiClassifyJobRequest.d.ts +24 -0
- package/dist/cjs/api/types/DocAiClassifyJobRequest.js +12 -0
- package/dist/cjs/api/types/DocAiClassifyOutput.d.ts +4 -0
- package/dist/cjs/api/types/DocAiClassifyOutput.js +3 -0
- package/dist/cjs/api/types/DocAiClassifyResult.d.ts +35 -0
- package/dist/cjs/api/types/DocAiClassifyResult.js +11 -0
- package/dist/cjs/api/types/DocAiClassifyResults.d.ts +14 -0
- package/dist/cjs/api/types/DocAiClassifyResults.js +3 -0
- package/dist/cjs/api/types/DocAiEvidence.d.ts +9 -0
- package/dist/cjs/api/types/DocAiEvidence.js +3 -0
- package/dist/cjs/api/types/DocAiJobAcceptedResponse.d.ts +23 -0
- package/dist/cjs/api/types/DocAiJobAcceptedResponse.js +3 -0
- package/dist/cjs/api/types/DocAiJobError.d.ts +23 -0
- package/dist/cjs/api/types/DocAiJobError.js +3 -0
- package/dist/cjs/api/types/DocAiJobStatusResponse.d.ts +16 -2
- package/dist/cjs/api/types/DocAiJobUsage.d.ts +6 -0
- package/dist/cjs/api/types/DocAiJobUsage.js +3 -0
- package/dist/cjs/api/types/DocAiPageRange.d.ts +7 -0
- package/dist/cjs/api/types/DocAiPageRange.js +3 -0
- package/dist/cjs/api/types/{DocAiDigitiseResults.d.ts → DocAiParseResults.d.ts} +4 -4
- package/dist/cjs/api/types/DocAiParseResults.js +3 -0
- package/dist/cjs/api/types/DocAiPresignUploadResponse.d.ts +1 -1
- package/dist/cjs/api/types/DocAiSplitConfig.d.ts +34 -0
- package/dist/cjs/api/types/DocAiSplitConfig.js +18 -0
- package/dist/cjs/api/types/DocAiSplitJobRequest.d.ts +21 -0
- package/dist/cjs/api/types/DocAiSplitJobRequest.js +11 -0
- package/dist/cjs/api/types/DocAiSplitResult.d.ts +21 -0
- package/dist/cjs/api/types/DocAiSplitResult.js +3 -0
- package/dist/cjs/api/types/DocAiSplitResults.d.ts +12 -0
- package/dist/cjs/api/types/DocAiSplitResults.js +3 -0
- package/dist/cjs/api/types/DocAiSplitSegment.d.ts +28 -0
- package/dist/cjs/api/types/DocAiSplitSegment.js +3 -0
- package/dist/cjs/api/types/DocAiSplitTrigger.d.ts +59 -0
- package/dist/cjs/api/types/DocAiSplitTrigger.js +42 -0
- package/dist/cjs/api/types/DocAiSplitTriggerMatch.d.ts +8 -0
- package/dist/cjs/api/types/DocAiSplitTriggerMatch.js +3 -0
- package/dist/cjs/api/types/DocAiSuggestedType.d.ts +8 -0
- package/dist/cjs/api/types/DocAiSuggestedType.js +3 -0
- package/dist/cjs/api/types/DocAiUsage.d.ts +6 -0
- package/dist/cjs/api/types/ExportFormat.d.ts +2 -1
- package/dist/cjs/api/types/ExportFormat.js +2 -1
- package/dist/cjs/api/types/JobLiveStatusResponse.d.ts +2 -0
- package/dist/cjs/api/types/StartJobResponse.d.ts +2 -0
- package/dist/cjs/api/types/TextToSpeechSpeaker.d.ts +3 -3
- package/dist/cjs/api/types/TextToSpeechSpeaker.js +3 -3
- package/dist/cjs/api/types/TranslationStatusItem.d.ts +4 -0
- package/dist/cjs/api/types/index.d.ts +26 -1
- package/dist/cjs/api/types/index.js +26 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/api/resources/docAi/client/Client.d.mts +78 -8
- package/dist/esm/api/resources/docAi/client/Client.mjs +233 -12
- package/dist/esm/api/resources/docAi/client/requests/DocAiClassifyRequest.d.mts +17 -0
- package/dist/esm/api/resources/docAi/client/requests/DocAiExtractRequest.d.mts +1 -1
- package/dist/esm/api/resources/docAi/client/requests/DocAiGetResultsRequest.d.mts +8 -0
- package/dist/esm/api/resources/docAi/client/requests/{DocAiDigitiseRequest.d.mts → DocAiParseRequest.d.mts} +4 -4
- package/dist/esm/api/resources/docAi/client/requests/{DocAiDigitiseRequest.mjs → DocAiParseRequest.mjs} +4 -4
- package/dist/esm/api/resources/docAi/client/requests/DocAiSplitRequest.d.mts +17 -0
- package/dist/esm/api/resources/docAi/client/requests/DocAiSplitRequest.mjs +2 -0
- package/dist/esm/api/resources/docAi/client/requests/index.d.mts +3 -1
- package/dist/esm/api/resources/docAi/client/requests/index.mjs +1 -1
- package/dist/esm/api/resources/docAi/types/DocAiGetResultsResponse.d.mts +9 -3
- package/dist/esm/api/resources/documentTranslation/client/requests/CreateDocumentJobRequest.d.mts +1 -1
- package/dist/esm/api/resources/documentTranslation/client/requests/DocumentTranslationTriggerExportRequest.d.mts +1 -0
- package/dist/esm/api/types/ChunkMetrics.d.mts +6 -0
- package/dist/esm/api/types/ChunkMetrics.mjs +2 -0
- package/dist/esm/api/types/ConfigureConnection.d.mts +3 -3
- package/dist/esm/api/types/ConfigureConnection.mjs +3 -3
- package/dist/esm/api/types/DocAiBatchDocument.d.mts +10 -0
- package/dist/esm/api/types/DocAiBatchDocument.mjs +2 -0
- package/dist/esm/api/types/DocAiCapabilitiesResponse.d.mts +23 -0
- package/dist/esm/api/types/DocAiCapabilitiesResponse.mjs +2 -0
- package/dist/esm/api/types/DocAiCapabilityLimits.d.mts +12 -0
- package/dist/esm/api/types/DocAiCapabilityLimits.mjs +2 -0
- package/dist/esm/api/types/DocAiClassifyCategory.d.mts +9 -0
- package/dist/esm/api/types/DocAiClassifyCategory.mjs +2 -0
- package/dist/esm/api/types/DocAiClassifyConfig.d.mts +33 -0
- package/dist/esm/api/types/DocAiClassifyConfig.mjs +14 -0
- package/dist/esm/api/types/DocAiClassifyDecision.d.mts +24 -0
- package/dist/esm/api/types/DocAiClassifyDecision.mjs +2 -0
- package/dist/esm/api/types/DocAiClassifyInspection.d.mts +27 -0
- package/dist/esm/api/types/DocAiClassifyInspection.mjs +12 -0
- package/dist/esm/api/types/DocAiClassifyJobRequest.d.mts +24 -0
- package/dist/esm/api/types/DocAiClassifyJobRequest.mjs +9 -0
- package/dist/esm/api/types/DocAiClassifyOutput.d.mts +4 -0
- package/dist/esm/api/types/DocAiClassifyOutput.mjs +2 -0
- package/dist/esm/api/types/DocAiClassifyResult.d.mts +35 -0
- package/dist/esm/api/types/DocAiClassifyResult.mjs +8 -0
- package/dist/esm/api/types/DocAiClassifyResults.d.mts +14 -0
- package/dist/esm/api/types/DocAiClassifyResults.mjs +2 -0
- package/dist/esm/api/types/DocAiEvidence.d.mts +9 -0
- package/dist/esm/api/types/DocAiEvidence.mjs +2 -0
- package/dist/esm/api/types/DocAiJobAcceptedResponse.d.mts +23 -0
- package/dist/esm/api/types/DocAiJobAcceptedResponse.mjs +2 -0
- package/dist/esm/api/types/DocAiJobError.d.mts +23 -0
- package/dist/esm/api/types/DocAiJobError.mjs +2 -0
- package/dist/esm/api/types/DocAiJobStatusResponse.d.mts +16 -2
- package/dist/esm/api/types/DocAiJobUsage.d.mts +6 -0
- package/dist/esm/api/types/DocAiJobUsage.mjs +2 -0
- package/dist/esm/api/types/DocAiPageRange.d.mts +7 -0
- package/dist/esm/api/types/DocAiPageRange.mjs +2 -0
- package/dist/esm/api/types/{DocAiDigitiseResults.d.mts → DocAiParseResults.d.mts} +4 -4
- package/dist/esm/api/types/DocAiParseResults.mjs +2 -0
- package/dist/esm/api/types/DocAiPresignUploadResponse.d.mts +1 -1
- package/dist/esm/api/types/DocAiSplitConfig.d.mts +34 -0
- package/dist/esm/api/types/DocAiSplitConfig.mjs +15 -0
- package/dist/esm/api/types/DocAiSplitJobRequest.d.mts +21 -0
- package/dist/esm/api/types/DocAiSplitJobRequest.mjs +8 -0
- package/dist/esm/api/types/DocAiSplitResult.d.mts +21 -0
- package/dist/esm/api/types/DocAiSplitResult.mjs +2 -0
- package/dist/esm/api/types/DocAiSplitResults.d.mts +12 -0
- package/dist/esm/api/types/DocAiSplitResults.mjs +2 -0
- package/dist/esm/api/types/DocAiSplitSegment.d.mts +28 -0
- package/dist/esm/api/types/DocAiSplitSegment.mjs +2 -0
- package/dist/esm/api/types/DocAiSplitTrigger.d.mts +59 -0
- package/dist/esm/api/types/DocAiSplitTrigger.mjs +39 -0
- package/dist/esm/api/types/DocAiSplitTriggerMatch.d.mts +8 -0
- package/dist/esm/api/types/DocAiSplitTriggerMatch.mjs +2 -0
- package/dist/esm/api/types/DocAiSuggestedType.d.mts +8 -0
- package/dist/esm/api/types/DocAiSuggestedType.mjs +2 -0
- package/dist/esm/api/types/DocAiUsage.d.mts +6 -0
- package/dist/esm/api/types/ExportFormat.d.mts +2 -1
- package/dist/esm/api/types/ExportFormat.mjs +2 -1
- package/dist/esm/api/types/JobLiveStatusResponse.d.mts +2 -0
- package/dist/esm/api/types/StartJobResponse.d.mts +2 -0
- package/dist/esm/api/types/TextToSpeechSpeaker.d.mts +3 -3
- package/dist/esm/api/types/TextToSpeechSpeaker.mjs +3 -3
- package/dist/esm/api/types/TranslationStatusItem.d.mts +4 -0
- package/dist/esm/api/types/index.d.mts +26 -1
- package/dist/esm/api/types/index.mjs +26 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +205 -8
- /package/dist/cjs/api/{types/DocAiDigitiseResults.js → resources/docAi/client/requests/DocAiClassifyRequest.js} +0 -0
- /package/dist/esm/api/{types/DocAiDigitiseResults.mjs → resources/docAi/client/requests/DocAiClassifyRequest.mjs} +0 -0
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "sarvamai",
|
|
46
|
-
"X-Fern-SDK-Version": "1.1.
|
|
47
|
-
"User-Agent": "sarvamai/1.1.
|
|
46
|
+
"X-Fern-SDK-Version": "1.1.13",
|
|
47
|
+
"User-Agent": "sarvamai/1.1.13",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -16,7 +16,7 @@ export declare class DocAiClient {
|
|
|
16
16
|
* **Flow:**
|
|
17
17
|
* 1. Call this endpoint with the MIME type you will upload (e.g. `application/pdf`).
|
|
18
18
|
* 2. Upload the file using the returned `method`, `url` and `headers` before `expires_at`.
|
|
19
|
-
* 3. Pass the returned `upload_id` through the `upload_ids` field on a later
|
|
19
|
+
* 3. Pass the returned `upload_id` through the `upload_ids` field on a later parse or extract job request.
|
|
20
20
|
*
|
|
21
21
|
* When `content_type` is set, the upload's `Content-Type` header must match it.
|
|
22
22
|
*
|
|
@@ -35,15 +35,15 @@ export declare class DocAiClient {
|
|
|
35
35
|
createUploadUrl(request?: SarvamAI.DocAiPresignUploadRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiPresignUploadResponse>;
|
|
36
36
|
private __createUploadUrl;
|
|
37
37
|
/**
|
|
38
|
-
* Creates and starts a
|
|
38
|
+
* Creates and starts a parse job from files or pre-uploaded handles. Parse converts documents into structured HTML, Markdown, or JSON while preserving layout.
|
|
39
39
|
*
|
|
40
40
|
* **Input:** Exactly one of `file` and `upload_ids` must be provided. Use `POST /doc-ai/v1/job/upload` to obtain upload IDs.
|
|
41
41
|
*
|
|
42
42
|
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until a terminal status (`completed`, `partially_completed`, `failed`, `rejected`), then fetch output via the results or download-url endpoints.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
44
|
+
* Parse JSON results include blocks with text, tag and bounding box.
|
|
45
45
|
*
|
|
46
|
-
* @param {SarvamAI.
|
|
46
|
+
* @param {SarvamAI.DocAiParseRequest} request
|
|
47
47
|
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
48
48
|
*
|
|
49
49
|
* @throws {@link SarvamAI.BadRequestError}
|
|
@@ -55,10 +55,10 @@ export declare class DocAiClient {
|
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
57
|
* import { createReadStream } from "fs";
|
|
58
|
-
* await client.docAi.
|
|
58
|
+
* await client.docAi.parse({})
|
|
59
59
|
*/
|
|
60
|
-
|
|
61
|
-
private
|
|
60
|
+
parse(request: SarvamAI.DocAiParseRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiStartJobResponse>;
|
|
61
|
+
private __parse;
|
|
62
62
|
/**
|
|
63
63
|
* Creates and starts an extract job from files or pre-uploaded handles. Extract pulls structured fields out of documents according to a schema.
|
|
64
64
|
*
|
|
@@ -89,6 +89,58 @@ export declare class DocAiClient {
|
|
|
89
89
|
*/
|
|
90
90
|
extract(request: SarvamAI.DocAiExtractRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiStartJobResponse>;
|
|
91
91
|
private __extract;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Classify job. Classify labels a document, or each page, against the categories you define, or suggests a document type when you supply none.
|
|
94
|
+
*
|
|
95
|
+
* **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request` with the options below. You can also send a JSON body with `input` set to `{"document_ref": "..."}` to classify a child document returned by Split.
|
|
96
|
+
*
|
|
97
|
+
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. Add `?include=details` to the results for inspected pages, provenance and evidence.
|
|
98
|
+
*
|
|
99
|
+
* **Review:** `review_required` tells you whether a person should check the answer. `confidence` can be `null`; it is a token-based score, not a measured probability.
|
|
100
|
+
*
|
|
101
|
+
* @param {SarvamAI.DocAiClassifyRequest} request
|
|
102
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
103
|
+
*
|
|
104
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
105
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
106
|
+
* @throws {@link SarvamAI.NotFoundError}
|
|
107
|
+
* @throws {@link SarvamAI.ConflictError}
|
|
108
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* import { createReadStream } from "fs";
|
|
112
|
+
* await client.docAi.classify({
|
|
113
|
+
* request: {}
|
|
114
|
+
* })
|
|
115
|
+
*/
|
|
116
|
+
classify(request: SarvamAI.DocAiClassifyRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiJobAcceptedResponse>;
|
|
117
|
+
private __classify;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a Split job. Split divides a bundle of pages into separate child documents, each with its original page numbers and a `document_ref` you can reuse in other requests.
|
|
120
|
+
*
|
|
121
|
+
* **Methods:** `fixed_pages` (equal page groups), `page_ranges` (you give the boundaries), `triggers` (split at QR codes, barcodes, blank pages, text or photos) and `semantic` (the model finds the boundaries).
|
|
122
|
+
*
|
|
123
|
+
* **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request`.
|
|
124
|
+
*
|
|
125
|
+
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. `completed` means processing finished, not that every segment passed review: check each segment's `review.required`.
|
|
126
|
+
*
|
|
127
|
+
* @param {SarvamAI.DocAiSplitRequest} request
|
|
128
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
129
|
+
*
|
|
130
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
131
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
132
|
+
* @throws {@link SarvamAI.NotFoundError}
|
|
133
|
+
* @throws {@link SarvamAI.ConflictError}
|
|
134
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* import { createReadStream } from "fs";
|
|
138
|
+
* await client.docAi.split({
|
|
139
|
+
* request: {}
|
|
140
|
+
* })
|
|
141
|
+
*/
|
|
142
|
+
split(request: SarvamAI.DocAiSplitRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiJobAcceptedResponse>;
|
|
143
|
+
private __split;
|
|
92
144
|
/**
|
|
93
145
|
* Returns a job's status and page-level usage.
|
|
94
146
|
*
|
|
@@ -107,7 +159,7 @@ export declare class DocAiClient {
|
|
|
107
159
|
/**
|
|
108
160
|
* Returns terminal job results. Results are never available while a job is running; requesting them before a terminal status returns `409`.
|
|
109
161
|
*
|
|
110
|
-
* **
|
|
162
|
+
* **Parse results** include `job_id`, `type`, `status`, `usage` and `documents`.
|
|
111
163
|
*
|
|
112
164
|
* **Extract results** include `job_id`, `type`, `status`, `usage`, `result`, `annotations` and `version`. `annotations` mirrors the result shape; every leaf has `confidence` and `sources`.
|
|
113
165
|
*
|
|
@@ -127,6 +179,12 @@ export declare class DocAiClient {
|
|
|
127
179
|
* await client.docAi.getResults("20260707_9f1c2b3a-4d5e-6f70-8a9b-c0d1e2f3a4b5", {
|
|
128
180
|
* format: "json"
|
|
129
181
|
* })
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* await client.docAi.getResults("01a17998-120b-73dc-ad42-5cd66e0fe0ff")
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* await client.docAi.getResults("01a17998-07ef-7040-800d-745a95140cf5")
|
|
130
188
|
*/
|
|
131
189
|
getResults(job_id: string, request?: SarvamAI.DocAiGetResultsRequest, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiGetResultsResponse>;
|
|
132
190
|
private __getResults;
|
|
@@ -146,4 +204,16 @@ export declare class DocAiClient {
|
|
|
146
204
|
*/
|
|
147
205
|
getDownloadUrl(job_id: string, requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiDownloadUrlResponse>;
|
|
148
206
|
private __getDownloadUrl;
|
|
207
|
+
/**
|
|
208
|
+
* Returns the Classify and Split features, input formats, limits and options enabled on this deployment. Check it before using options such as `reasoning_input` image modes or photo triggers.
|
|
209
|
+
*
|
|
210
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
211
|
+
*
|
|
212
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* await client.docAi.getCapabilities()
|
|
216
|
+
*/
|
|
217
|
+
getCapabilities(requestOptions?: DocAiClient.RequestOptions): core.HttpResponsePromise<SarvamAI.DocAiCapabilitiesResponse>;
|
|
218
|
+
private __getCapabilities;
|
|
149
219
|
}
|
|
@@ -47,6 +47,7 @@ exports.DocAiClient = void 0;
|
|
|
47
47
|
const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
48
48
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
49
49
|
const core = __importStar(require("../../../../core/index.js"));
|
|
50
|
+
const json_js_1 = require("../../../../core/json.js");
|
|
50
51
|
const environments = __importStar(require("../../../../environments.js"));
|
|
51
52
|
const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
|
|
52
53
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
@@ -61,7 +62,7 @@ class DocAiClient {
|
|
|
61
62
|
* **Flow:**
|
|
62
63
|
* 1. Call this endpoint with the MIME type you will upload (e.g. `application/pdf`).
|
|
63
64
|
* 2. Upload the file using the returned `method`, `url` and `headers` before `expires_at`.
|
|
64
|
-
* 3. Pass the returned `upload_id` through the `upload_ids` field on a later
|
|
65
|
+
* 3. Pass the returned `upload_id` through the `upload_ids` field on a later parse or extract job request.
|
|
65
66
|
*
|
|
66
67
|
* When `content_type` is set, the upload's `Content-Type` header must match it.
|
|
67
68
|
*
|
|
@@ -126,15 +127,15 @@ class DocAiClient {
|
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
/**
|
|
129
|
-
* Creates and starts a
|
|
130
|
+
* Creates and starts a parse job from files or pre-uploaded handles. Parse converts documents into structured HTML, Markdown, or JSON while preserving layout.
|
|
130
131
|
*
|
|
131
132
|
* **Input:** Exactly one of `file` and `upload_ids` must be provided. Use `POST /doc-ai/v1/job/upload` to obtain upload IDs.
|
|
132
133
|
*
|
|
133
134
|
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until a terminal status (`completed`, `partially_completed`, `failed`, `rejected`), then fetch output via the results or download-url endpoints.
|
|
134
135
|
*
|
|
135
|
-
*
|
|
136
|
+
* Parse JSON results include blocks with text, tag and bounding box.
|
|
136
137
|
*
|
|
137
|
-
* @param {SarvamAI.
|
|
138
|
+
* @param {SarvamAI.DocAiParseRequest} request
|
|
138
139
|
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
139
140
|
*
|
|
140
141
|
* @throws {@link SarvamAI.BadRequestError}
|
|
@@ -146,12 +147,12 @@ class DocAiClient {
|
|
|
146
147
|
*
|
|
147
148
|
* @example
|
|
148
149
|
* import { createReadStream } from "fs";
|
|
149
|
-
* await client.docAi.
|
|
150
|
+
* await client.docAi.parse({})
|
|
150
151
|
*/
|
|
151
|
-
|
|
152
|
-
return core.HttpResponsePromise.fromPromise(this.
|
|
152
|
+
parse(request, requestOptions) {
|
|
153
|
+
return core.HttpResponsePromise.fromPromise(this.__parse(request, requestOptions));
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
__parse(request, requestOptions) {
|
|
155
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
157
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
157
158
|
const _body = yield core.newFormData();
|
|
@@ -176,7 +177,7 @@ class DocAiClient {
|
|
|
176
177
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
177
178
|
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
178
179
|
const _response = yield core.fetcher({
|
|
179
|
-
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "doc-ai/v1/job/
|
|
180
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "doc-ai/v1/job/parse"),
|
|
180
181
|
method: "POST",
|
|
181
182
|
headers: _headers,
|
|
182
183
|
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
@@ -214,7 +215,7 @@ class DocAiClient {
|
|
|
214
215
|
});
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/doc-ai/v1/job/
|
|
218
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/doc-ai/v1/job/parse");
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
/**
|
|
@@ -320,6 +321,172 @@ class DocAiClient {
|
|
|
320
321
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/doc-ai/v1/job/extract");
|
|
321
322
|
});
|
|
322
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Creates a Classify job. Classify labels a document, or each page, against the categories you define, or suggests a document type when you supply none.
|
|
326
|
+
*
|
|
327
|
+
* **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request` with the options below. You can also send a JSON body with `input` set to `{"document_ref": "..."}` to classify a child document returned by Split.
|
|
328
|
+
*
|
|
329
|
+
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. Add `?include=details` to the results for inspected pages, provenance and evidence.
|
|
330
|
+
*
|
|
331
|
+
* **Review:** `review_required` tells you whether a person should check the answer. `confidence` can be `null`; it is a token-based score, not a measured probability.
|
|
332
|
+
*
|
|
333
|
+
* @param {SarvamAI.DocAiClassifyRequest} request
|
|
334
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
335
|
+
*
|
|
336
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
337
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
338
|
+
* @throws {@link SarvamAI.NotFoundError}
|
|
339
|
+
* @throws {@link SarvamAI.ConflictError}
|
|
340
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* import { createReadStream } from "fs";
|
|
344
|
+
* await client.docAi.classify({
|
|
345
|
+
* request: {}
|
|
346
|
+
* })
|
|
347
|
+
*/
|
|
348
|
+
classify(request, requestOptions) {
|
|
349
|
+
return core.HttpResponsePromise.fromPromise(this.__classify(request, requestOptions));
|
|
350
|
+
}
|
|
351
|
+
__classify(request, requestOptions) {
|
|
352
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
354
|
+
const _body = yield core.newFormData();
|
|
355
|
+
if (request.file != null) {
|
|
356
|
+
for (const _file of request.file) {
|
|
357
|
+
yield _body.appendFile("file", _file);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (request.upload_ids != null) {
|
|
361
|
+
_body.append("upload_ids", request.upload_ids);
|
|
362
|
+
}
|
|
363
|
+
_body.append("request", (0, json_js_1.toJson)(request.request));
|
|
364
|
+
const _maybeEncodedRequest = yield _body.getRequest();
|
|
365
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
366
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ "Idempotency-Key": request["Idempotency-Key"] }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
367
|
+
const _response = yield core.fetcher({
|
|
368
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "doc-ai/v1/job/classify"),
|
|
369
|
+
method: "POST",
|
|
370
|
+
headers: _headers,
|
|
371
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
372
|
+
requestType: "file",
|
|
373
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
374
|
+
body: _maybeEncodedRequest.body,
|
|
375
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
376
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
377
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
378
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
379
|
+
logging: this._options.logging,
|
|
380
|
+
});
|
|
381
|
+
if (_response.ok) {
|
|
382
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
383
|
+
}
|
|
384
|
+
if (_response.error.reason === "status-code") {
|
|
385
|
+
switch (_response.error.statusCode) {
|
|
386
|
+
case 400:
|
|
387
|
+
throw new SarvamAI.BadRequestError(_response.error.body, _response.rawResponse);
|
|
388
|
+
case 401:
|
|
389
|
+
throw new SarvamAI.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
390
|
+
case 404:
|
|
391
|
+
throw new SarvamAI.NotFoundError(_response.error.body, _response.rawResponse);
|
|
392
|
+
case 409:
|
|
393
|
+
throw new SarvamAI.ConflictError(_response.error.body, _response.rawResponse);
|
|
394
|
+
case 422:
|
|
395
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
396
|
+
default:
|
|
397
|
+
throw new errors.SarvamAIError({
|
|
398
|
+
statusCode: _response.error.statusCode,
|
|
399
|
+
body: _response.error.body,
|
|
400
|
+
rawResponse: _response.rawResponse,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/doc-ai/v1/job/classify");
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Creates a Split job. Split divides a bundle of pages into separate child documents, each with its original page numbers and a `document_ref` you can reuse in other requests.
|
|
409
|
+
*
|
|
410
|
+
* **Methods:** `fixed_pages` (equal page groups), `page_ranges` (you give the boundaries), `triggers` (split at QR codes, barcodes, blank pages, text or photos) and `semantic` (the model finds the boundaries).
|
|
411
|
+
*
|
|
412
|
+
* **Input:** send `file` (PDF, PNG, JPEG or TIFF; repeat the field for up to 10 documents) or `upload_ids`, plus a JSON `request`.
|
|
413
|
+
*
|
|
414
|
+
* **Processing:** the job runs asynchronously. Poll `GET /doc-ai/v1/job/{job_id}/status` until it is `completed`, then fetch `GET /doc-ai/v1/job/{job_id}/results`. `completed` means processing finished, not that every segment passed review: check each segment's `review.required`.
|
|
415
|
+
*
|
|
416
|
+
* @param {SarvamAI.DocAiSplitRequest} request
|
|
417
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
418
|
+
*
|
|
419
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
420
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
421
|
+
* @throws {@link SarvamAI.NotFoundError}
|
|
422
|
+
* @throws {@link SarvamAI.ConflictError}
|
|
423
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* import { createReadStream } from "fs";
|
|
427
|
+
* await client.docAi.split({
|
|
428
|
+
* request: {}
|
|
429
|
+
* })
|
|
430
|
+
*/
|
|
431
|
+
split(request, requestOptions) {
|
|
432
|
+
return core.HttpResponsePromise.fromPromise(this.__split(request, requestOptions));
|
|
433
|
+
}
|
|
434
|
+
__split(request, requestOptions) {
|
|
435
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
437
|
+
const _body = yield core.newFormData();
|
|
438
|
+
if (request.file != null) {
|
|
439
|
+
for (const _file of request.file) {
|
|
440
|
+
yield _body.appendFile("file", _file);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (request.upload_ids != null) {
|
|
444
|
+
_body.append("upload_ids", request.upload_ids);
|
|
445
|
+
}
|
|
446
|
+
_body.append("request", (0, json_js_1.toJson)(request.request));
|
|
447
|
+
const _maybeEncodedRequest = yield _body.getRequest();
|
|
448
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
449
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ "Idempotency-Key": request["Idempotency-Key"] }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
450
|
+
const _response = yield core.fetcher({
|
|
451
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "doc-ai/v1/job/split"),
|
|
452
|
+
method: "POST",
|
|
453
|
+
headers: _headers,
|
|
454
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
455
|
+
requestType: "file",
|
|
456
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
457
|
+
body: _maybeEncodedRequest.body,
|
|
458
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
459
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
460
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
461
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
462
|
+
logging: this._options.logging,
|
|
463
|
+
});
|
|
464
|
+
if (_response.ok) {
|
|
465
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
466
|
+
}
|
|
467
|
+
if (_response.error.reason === "status-code") {
|
|
468
|
+
switch (_response.error.statusCode) {
|
|
469
|
+
case 400:
|
|
470
|
+
throw new SarvamAI.BadRequestError(_response.error.body, _response.rawResponse);
|
|
471
|
+
case 401:
|
|
472
|
+
throw new SarvamAI.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
473
|
+
case 404:
|
|
474
|
+
throw new SarvamAI.NotFoundError(_response.error.body, _response.rawResponse);
|
|
475
|
+
case 409:
|
|
476
|
+
throw new SarvamAI.ConflictError(_response.error.body, _response.rawResponse);
|
|
477
|
+
case 422:
|
|
478
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
479
|
+
default:
|
|
480
|
+
throw new errors.SarvamAIError({
|
|
481
|
+
statusCode: _response.error.statusCode,
|
|
482
|
+
body: _response.error.body,
|
|
483
|
+
rawResponse: _response.rawResponse,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/doc-ai/v1/job/split");
|
|
488
|
+
});
|
|
489
|
+
}
|
|
323
490
|
/**
|
|
324
491
|
* Returns a job's status and page-level usage.
|
|
325
492
|
*
|
|
@@ -373,7 +540,7 @@ class DocAiClient {
|
|
|
373
540
|
/**
|
|
374
541
|
* Returns terminal job results. Results are never available while a job is running; requesting them before a terminal status returns `409`.
|
|
375
542
|
*
|
|
376
|
-
* **
|
|
543
|
+
* **Parse results** include `job_id`, `type`, `status`, `usage` and `documents`.
|
|
377
544
|
*
|
|
378
545
|
* **Extract results** include `job_id`, `type`, `status`, `usage`, `result`, `annotations` and `version`. `annotations` mirrors the result shape; every leaf has `confidence` and `sources`.
|
|
379
546
|
*
|
|
@@ -393,6 +560,12 @@ class DocAiClient {
|
|
|
393
560
|
* await client.docAi.getResults("20260707_9f1c2b3a-4d5e-6f70-8a9b-c0d1e2f3a4b5", {
|
|
394
561
|
* format: "json"
|
|
395
562
|
* })
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* await client.docAi.getResults("01a17998-120b-73dc-ad42-5cd66e0fe0ff")
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* await client.docAi.getResults("01a17998-07ef-7040-800d-745a95140cf5")
|
|
396
569
|
*/
|
|
397
570
|
getResults(job_id, request = {}, requestOptions) {
|
|
398
571
|
return core.HttpResponsePromise.fromPromise(this.__getResults(job_id, request, requestOptions));
|
|
@@ -400,9 +573,10 @@ class DocAiClient {
|
|
|
400
573
|
__getResults(job_id_1) {
|
|
401
574
|
return __awaiter(this, arguments, void 0, function* (job_id, request = {}, requestOptions) {
|
|
402
575
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
403
|
-
const { format } = request;
|
|
576
|
+
const { format, include } = request;
|
|
404
577
|
const _queryParams = {
|
|
405
578
|
format: format != null ? format : undefined,
|
|
579
|
+
include: include != null ? include : undefined,
|
|
406
580
|
};
|
|
407
581
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
408
582
|
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
@@ -490,5 +664,52 @@ class DocAiClient {
|
|
|
490
664
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/doc-ai/v1/job/{job_id}/download-url");
|
|
491
665
|
});
|
|
492
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Returns the Classify and Split features, input formats, limits and options enabled on this deployment. Check it before using options such as `reasoning_input` image modes or photo triggers.
|
|
669
|
+
*
|
|
670
|
+
* @param {DocAiClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
671
|
+
*
|
|
672
|
+
* @throws {@link SarvamAI.UnauthorizedError}
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* await client.docAi.getCapabilities()
|
|
676
|
+
*/
|
|
677
|
+
getCapabilities(requestOptions) {
|
|
678
|
+
return core.HttpResponsePromise.fromPromise(this.__getCapabilities(requestOptions));
|
|
679
|
+
}
|
|
680
|
+
__getCapabilities(requestOptions) {
|
|
681
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
682
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
683
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
684
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
685
|
+
const _response = yield core.fetcher({
|
|
686
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "doc-ai/v1/capabilities"),
|
|
687
|
+
method: "GET",
|
|
688
|
+
headers: _headers,
|
|
689
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
690
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
691
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
692
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
693
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
694
|
+
logging: this._options.logging,
|
|
695
|
+
});
|
|
696
|
+
if (_response.ok) {
|
|
697
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
698
|
+
}
|
|
699
|
+
if (_response.error.reason === "status-code") {
|
|
700
|
+
switch (_response.error.statusCode) {
|
|
701
|
+
case 401:
|
|
702
|
+
throw new SarvamAI.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
703
|
+
default:
|
|
704
|
+
throw new errors.SarvamAIError({
|
|
705
|
+
statusCode: _response.error.statusCode,
|
|
706
|
+
body: _response.error.body,
|
|
707
|
+
rawResponse: _response.rawResponse,
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/doc-ai/v1/capabilities");
|
|
712
|
+
});
|
|
713
|
+
}
|
|
493
714
|
}
|
|
494
715
|
exports.DocAiClient = DocAiClient;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as core from "../../../../../core/index.js";
|
|
2
|
+
import type * as SarvamAI from "../../../../index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* request: {}
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface DocAiClassifyRequest {
|
|
10
|
+
/** Retry the same submission without creating another job. The same key with the same request returns the original job (`idempotency_replayed: true`); the same key with a changed request returns `409 IDEMPOTENCY_CONFLICT`. */
|
|
11
|
+
"Idempotency-Key"?: string;
|
|
12
|
+
/** Document file(s): PDF, PNG, JPEG or TIFF. Repeat the part for up to 10 documents with the same config. */
|
|
13
|
+
file?: core.file.Uploadable[] | undefined;
|
|
14
|
+
/** Comma-separated upload IDs returned by `POST /doc-ai/v1/job/upload`, with or instead of `file`. */
|
|
15
|
+
upload_ids?: string;
|
|
16
|
+
request: SarvamAI.DocAiClassifyJobRequest;
|
|
17
|
+
}
|
|
@@ -13,7 +13,7 @@ export interface DocAiExtractRequest {
|
|
|
13
13
|
upload_ids?: string;
|
|
14
14
|
/** Inline extraction schema as a JSON string. The root must be `type: "object"` with non-empty `properties`; every field needs a `type` and a non-empty `description`. Supported types: `string`, `number`, `integer`, `boolean`, `object`, `array` (objects need `properties`, arrays need `items`); optional `enum`; maximum nesting depth 4. Exactly one of `schema` and `config_id` is required. */
|
|
15
15
|
schema?: string;
|
|
16
|
-
/** Saved extraction configuration ID. Exactly one of `schema` and `config_id` is required. To get your config_id,
|
|
16
|
+
/** Saved extraction configuration ID. Exactly one of `schema` and `config_id` is required. To get your config_id, see [Reuse a schema](/api/api-guides-tutorials/document-intelligence/how-to/extract#reuse-a-schema). */
|
|
17
17
|
config_id?: string;
|
|
18
18
|
/** Output format of the extraction results. */
|
|
19
19
|
output_format?: DocAiExtractRequest.OutputFormat;
|
|
@@ -9,8 +9,16 @@ import type * as SarvamAI from "../../../../index.js";
|
|
|
9
9
|
* {
|
|
10
10
|
* format: "json"
|
|
11
11
|
* }
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* {}
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* {}
|
|
12
18
|
*/
|
|
13
19
|
export interface DocAiGetResultsRequest {
|
|
14
20
|
/** Output format of the results. Choose `md` for Markdown, `html` for HTML, or `json` for structured JSON. If you omit `format`, the results are returned as `json` by default. */
|
|
15
21
|
format?: SarvamAI.Format;
|
|
22
|
+
/** Set to `details` for Classify and Split jobs to add inspected pages, provenance and boundary details. Supporting evidence also needs `output.include_evidence` on the request. */
|
|
23
|
+
include?: "details";
|
|
16
24
|
}
|
|
@@ -3,19 +3,19 @@ import type * as core from "../../../../../core/index.js";
|
|
|
3
3
|
* @example
|
|
4
4
|
* {}
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
7
|
-
/** Document file(s) to
|
|
6
|
+
export interface DocAiParseRequest {
|
|
7
|
+
/** Document file(s) to parse. Repeatable multipart part. Exactly one of `file` and `upload_ids` must be provided. */
|
|
8
8
|
file?: core.file.Uploadable[] | undefined;
|
|
9
9
|
/** Comma-separated upload IDs returned by `POST /doc-ai/v1/job/upload`. Exactly one of `file` and `upload_ids` must be provided. */
|
|
10
10
|
upload_ids?: string;
|
|
11
11
|
/** Language of the document in BCP-47 format (e.g. `hi-IN`, `en-IN`). Defaults to Indic: when omitted, the document is processed as an Indic-language document. To process an English document, set `language` to `en-IN`. Sarvam Vision supports 22 Indian languages plus English; see the [Sarvam Vision model page](/api/getting-started/models/sarvam-vision) for the full list. */
|
|
12
12
|
language?: string;
|
|
13
13
|
/** Nature of the document content. */
|
|
14
|
-
content_type?:
|
|
14
|
+
content_type?: DocAiParseRequest.ContentType;
|
|
15
15
|
/** Model to use for digitisation. */
|
|
16
16
|
model?: string;
|
|
17
17
|
}
|
|
18
|
-
export declare namespace
|
|
18
|
+
export declare namespace DocAiParseRequest {
|
|
19
19
|
/** Nature of the document content. */
|
|
20
20
|
const ContentType: {
|
|
21
21
|
readonly Printed: "printed";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
var
|
|
6
|
-
(function (
|
|
4
|
+
exports.DocAiParseRequest = void 0;
|
|
5
|
+
var DocAiParseRequest;
|
|
6
|
+
(function (DocAiParseRequest) {
|
|
7
7
|
/** Nature of the document content. */
|
|
8
|
-
|
|
8
|
+
DocAiParseRequest.ContentType = {
|
|
9
9
|
Printed: "printed",
|
|
10
10
|
Handwritten: "handwritten",
|
|
11
11
|
Mixed: "mixed",
|
|
12
12
|
};
|
|
13
|
-
})(
|
|
13
|
+
})(DocAiParseRequest || (exports.DocAiParseRequest = DocAiParseRequest = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as core from "../../../../../core/index.js";
|
|
2
|
+
import type * as SarvamAI from "../../../../index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* request: {}
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface DocAiSplitRequest {
|
|
10
|
+
/** Retry the same submission without creating another job. The same key with the same request returns the original job (`idempotency_replayed: true`); the same key with a changed request returns `409 IDEMPOTENCY_CONFLICT`. */
|
|
11
|
+
"Idempotency-Key"?: string;
|
|
12
|
+
/** Document file(s): PDF, PNG, JPEG or TIFF. Repeat the part for up to 10 documents with the same config. */
|
|
13
|
+
file?: core.file.Uploadable[] | undefined;
|
|
14
|
+
/** Comma-separated upload IDs returned by `POST /doc-ai/v1/job/upload`, with or instead of `file`. */
|
|
15
|
+
upload_ids?: string;
|
|
16
|
+
request: SarvamAI.DocAiSplitJobRequest;
|
|
17
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { DocAiClassifyRequest } from "./DocAiClassifyRequest.js";
|
|
2
2
|
export { DocAiExtractRequest } from "./DocAiExtractRequest.js";
|
|
3
3
|
export type { DocAiGetResultsRequest } from "./DocAiGetResultsRequest.js";
|
|
4
|
+
export { DocAiParseRequest } from "./DocAiParseRequest.js";
|
|
4
5
|
export type { DocAiPresignUploadRequest } from "./DocAiPresignUploadRequest.js";
|
|
6
|
+
export type { DocAiSplitRequest } from "./DocAiSplitRequest.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var DocAiDigitiseRequest_js_1 = require("./DocAiDigitiseRequest.js");
|
|
5
|
-
Object.defineProperty(exports, "DocAiDigitiseRequest", { enumerable: true, get: function () { return DocAiDigitiseRequest_js_1.DocAiDigitiseRequest; } });
|
|
3
|
+
exports.DocAiParseRequest = exports.DocAiExtractRequest = void 0;
|
|
6
4
|
var DocAiExtractRequest_js_1 = require("./DocAiExtractRequest.js");
|
|
7
5
|
Object.defineProperty(exports, "DocAiExtractRequest", { enumerable: true, get: function () { return DocAiExtractRequest_js_1.DocAiExtractRequest; } });
|
|
6
|
+
var DocAiParseRequest_js_1 = require("./DocAiParseRequest.js");
|
|
7
|
+
Object.defineProperty(exports, "DocAiParseRequest", { enumerable: true, get: function () { return DocAiParseRequest_js_1.DocAiParseRequest; } });
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type * as SarvamAI from "../../../index.js";
|
|
2
|
-
export type DocAiGetResultsResponse = SarvamAI.DocAiGetResultsResponse.Extract | SarvamAI.DocAiGetResultsResponse.
|
|
2
|
+
export type DocAiGetResultsResponse = SarvamAI.DocAiGetResultsResponse.Extract | SarvamAI.DocAiGetResultsResponse.Parse | SarvamAI.DocAiGetResultsResponse.Classify | SarvamAI.DocAiGetResultsResponse.Split;
|
|
3
3
|
export declare namespace DocAiGetResultsResponse {
|
|
4
4
|
interface Extract extends SarvamAI.DocAiExtractResults {
|
|
5
5
|
type: "extract";
|
|
6
6
|
}
|
|
7
|
-
interface
|
|
8
|
-
type: "
|
|
7
|
+
interface Parse extends SarvamAI.DocAiParseResults {
|
|
8
|
+
type: "parse";
|
|
9
|
+
}
|
|
10
|
+
interface Classify extends SarvamAI.DocAiClassifyResults {
|
|
11
|
+
type: "classify";
|
|
12
|
+
}
|
|
13
|
+
interface Split extends SarvamAI.DocAiSplitResults {
|
|
14
|
+
type: "split";
|
|
9
15
|
}
|
|
10
16
|
}
|