@pdfvector/client 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +12 -1
- package/dist/contract.cjs +18 -3
- package/dist/contract.d.cts +162 -0
- package/dist/contract.d.mts +162 -0
- package/dist/contract.mjs +8 -4
- package/dist/index.cjs +12 -1
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @pdfvector/client
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#564](https://github.com/phuctm97/pdfvector/pull/564) [`6dcf020`](https://github.com/phuctm97/pdfvector/commit/6dcf0205899627e57b7824d7d7a2837f4537e336) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Failed requests are never charged and our own failures are no longer reported as the caller's.
|
|
8
|
+
|
|
9
|
+
- Billing: a request that ends in an error (any class) is billed 0 credits; provider calls it made stay in provider usage as our cost (before: an error after a successful provider call, such as the nano/mini text validator or the image text pre-check, was charged).
|
|
10
|
+
- Classification: user_error only for explicit caller faults (`data.userError`: input validation, size/page limits, unreadable uploads), contract validation and rate limits; an untagged BAD_REQUEST is a system error and reaches Sentry. "Retry with a higher model" is recorded as user_error with the usage code `HIGHER_MODEL_REQUIRED` so its rate stays visible. Ask/extract keep a system parse failure (e.g. `DOCUMENT_PROCESSING_FAILED`) instead of wrapping it in "try a higher model"; mini/pro OCR outages are system errors instead of "try a higher model"; a provider page limit within the tier's own limit is a processing failure, not a user BAD_REQUEST; when one engine failed on our side and another called the input bad, the system error wins; auto PDFs over Document AI's default page cap get a chunked Document AI pass before "no text" and report a system error if an engine was skipped.
|
|
11
|
+
- URL input: browser-like headers, 90 s timeout, a streaming size cap at the tier's file limit, a retry of 403/408/429/5xx and network errors through the residential proxy (redirect hops re-checked against private addresses). A site that still refuses is `UPSTREAM_FETCH_FAILED` (BAD_REQUEST, `statusCode`, `host`; not a user error, tracked instead of sent to Sentry); 401/404/410, unresolvable hosts, private share links and expired signed links stay user errors.
|
|
12
|
+
- academic.parse tries up to three open-access copies (OpenAlex locations, arXiv, Europe PMC) and the proxy; when none downloads, `PDF_NOT_FETCHABLE` keeps NOT_FOUND but is a system error with every attempt in `data.attempts`, and each download is a `other/document_fetch` provider-health event.
|
|
13
|
+
- Input validation: uploads and URL bodies are sniffed; a different supported format is processed as such, a mismatch (an HTML page sent as PDF) is `CONTENT_TYPE_MISMATCH`. ZIP uploads and ZIP-based Office/ODF/EPUB files are bounded (20,000 entries, 1 GB expanded, 200x past 100 MB: `ARCHIVE_TOO_LARGE`). A DOCX whose text is only in headers, footers or notes is no longer rejected as empty.
|
|
14
|
+
- Sentry events are rate limited per error key (10 per hour).
|
|
15
|
+
- SDK: `UPSTREAM_FETCH_FAILED` and `PDF_NOT_FETCHABLE` are system-origin, retryable errors with their own suggestions; `CONTENT_TYPE_MISMATCH` and `ARCHIVE_TOO_LARGE` get suggestions. The README lists the reason codes.
|
|
16
|
+
- Updated dependencies [[`6dcf020`](https://github.com/phuctm97/pdfvector/commit/6dcf0205899627e57b7824d7d7a2837f4537e336)]:
|
|
17
|
+
- @pdfvector/instance-client@0.1.2
|
|
18
|
+
|
|
19
|
+
## 0.1.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#551](https://github.com/phuctm97/pdfvector/pull/551) [`913a258`](https://github.com/phuctm97/pdfvector/commit/913a2585885f8787bc4cd27ae84d2586dab75378) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Export the retained-input and diagnostics schemas from `@pdfvector/client/contract` (they stay off the main entry).
|
|
24
|
+
|
|
3
25
|
## 0.1.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -637,6 +637,17 @@ All API errors are thrown as `PDFVectorError` instances. The SDK maps server err
|
|
|
637
637
|
|
|
638
638
|
For `INTERNAL_SERVER_ERROR`, the API returns a safe message and keeps the original provider failure in server diagnostics. Use `requestId` when contacting support. For document processing failures, check `reasonCode` and `retryableWithHigherModel` instead of parsing the message; `EXTRACTION_FAILED` identifies unusable structured output even if message wording changes. `DOCUMENT_PROCESSING_FAILED` identifies a processing rejection that was not confirmed to be a caller-input error, so the SDK suggests retrying or contacting support rather than changing the document. Error responses do not include raw AI output.
|
|
639
639
|
|
|
640
|
+
Reason codes (`reasonCode`, from the response's `data.code`) for document input:
|
|
641
|
+
|
|
642
|
+
| `reasonCode` | Status | Meaning |
|
|
643
|
+
| --- | --- | --- |
|
|
644
|
+
| `UPSTREAM_FETCH_FAILED` | 400 (`URLFetchError`) | The website behind `url` blocked, rate limited, failed or timed out the download, even through a retry from another network. Not a caller fault: `userError` is `false`, `retryable` is `true`; `statusCode` and `data.host` say what the site answered. Download the file and send it as `file`/`base64`, or retry later. A 401/404/410, a private share link or an expired signed link stays a user error. |
|
|
645
|
+
| `PDF_NOT_FETCHABLE` | 404 (`academic.parse`) | No open-access copy of the paper could be downloaded (each copy tried is in `data.attempts`). Retryable, not a caller fault. |
|
|
646
|
+
| `CONTENT_TYPE_MISMATCH` | 400 | The uploaded bytes are not the declared format (for example an HTML page sent as a PDF). A file whose real format differs but is supported is processed as its real format instead. |
|
|
647
|
+
| `ARCHIVE_TOO_LARGE` | 400 | A ZIP upload or ZIP-based Office/EPUB/ODF file has more than 20,000 entries or expands beyond 1 GB (or 200x its size past 100 MB). |
|
|
648
|
+
|
|
649
|
+
A request that ends in an error is never charged credits.
|
|
650
|
+
|
|
640
651
|
```typescript
|
|
641
652
|
import {
|
|
642
653
|
PDFVectorError,
|
|
@@ -788,7 +799,7 @@ PDFVectorError
|
|
|
788
799
|
│ ├── PageLimitExceededError — pageCount, pageLimit, model
|
|
789
800
|
│ ├── PasswordProtectedError
|
|
790
801
|
│ ├── UnsupportedFormatError — format, supportedFormats
|
|
791
|
-
│ ├── URLFetchError — url, statusCode, statusText
|
|
802
|
+
│ ├── URLFetchError — url, statusCode, statusText (reasonCode UPSTREAM_FETCH_FAILED: the site refused)
|
|
792
803
|
│ ├── InvalidDocumentURLError
|
|
793
804
|
│ ├── InvalidBase64Error
|
|
794
805
|
│ ├── TierNotSupportedError — documentType, model, allowedTypes
|
package/dist/contract.cjs
CHANGED
|
@@ -444,6 +444,7 @@ const allTierFormats = [
|
|
|
444
444
|
"Word (.docx)",
|
|
445
445
|
"Excel (.xlsx)",
|
|
446
446
|
"PowerPoint (.pptx)",
|
|
447
|
+
"Word, Excel and PowerPoint 97-2003 (.doc, .xls, .ppt)",
|
|
447
448
|
"CSV",
|
|
448
449
|
"Text (.txt, .md, .tsv, .xml)",
|
|
449
450
|
"HTML",
|
|
@@ -455,9 +456,9 @@ const allTierFormats = [
|
|
|
455
456
|
/** Formats added by the pro/max/auto tiers. */
|
|
456
457
|
const proTierAdditionalFormats = ["Image (PNG, JPG, TIFF, BMP, HEIF)"];
|
|
457
458
|
/** Short human-readable summary of all supported formats. */
|
|
458
|
-
const allSupportedFormatsShort = "PDF, DOCX, XLSX, PPTX, CSV, PNG, JPG, TIFF, BMP, HEIF, TXT, MD, TSV, XML, RTF, HTML, ODT, ODS, ODP, EPUB, BIB, RIS, NBIB, ENW";
|
|
459
|
+
const allSupportedFormatsShort = "PDF, DOCX, XLSX, PPTX, DOC, XLS, PPT, CSV, PNG, JPG, TIFF, BMP, HEIF, TXT, MD, TSV, XML, RTF, HTML, ODT, ODS, ODP, EPUB, BIB, RIS, NBIB, ENW";
|
|
459
460
|
/** Long human-readable summary of all supported formats. */
|
|
460
|
-
const allSupportedFormatsLong = "PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), CSV, Image (.png, .jpg, .tiff, .bmp, .heif), Plain Text (.txt, .md, .tsv, .xml), RTF, HTML, OpenDocument (.odt, .ods, .odp), EPUB, and Bibliography (.bib, .ris, .nbib, .enw) files";
|
|
461
|
+
const allSupportedFormatsLong = "PDF, Word (.docx, .doc), Excel (.xlsx, .xls), PowerPoint (.pptx, .ppt), CSV, Image (.png, .jpg, .tiff, .bmp, .heif), Plain Text (.txt, .md, .tsv, .xml), RTF, HTML, OpenDocument (.odt, .ods, .odp), EPUB, and Bibliography (.bib, .ris, .nbib, .enw) files";
|
|
461
462
|
/** Image dimension limits enforced by the underlying OCR engine (Azure Document Intelligence).
|
|
462
463
|
* Images outside this range are rejected with HTTP 400 before processing begins. */
|
|
463
464
|
const imageDimensionLimits = {
|
|
@@ -466,7 +467,7 @@ const imageDimensionLimits = {
|
|
|
466
467
|
};
|
|
467
468
|
/** Pre-built format note for API descriptions (used in contract model descriptions). */
|
|
468
469
|
const formatsByTierDescription = `Supported formats by tier:
|
|
469
|
-
- All tiers: ${allTierFormats.join(", ")}.\n- Pro/Max/Auto adds: ${proTierAdditionalFormats.join(", ")}. Image dimensions must be between ${imageDimensionLimits.minPixels}×${imageDimensionLimits.minPixels} and ${imageDimensionLimits.maxPixels}×${imageDimensionLimits.maxPixels} pixels.`;
|
|
470
|
+
- All tiers: ${allTierFormats.join(", ")}.\n- Pro/Max/Auto adds: ${proTierAdditionalFormats.join(", ")}. Image dimensions must be between ${imageDimensionLimits.minPixels}×${imageDimensionLimits.minPixels} and ${imageDimensionLimits.maxPixels}×${imageDimensionLimits.maxPixels} pixels.\nHow pages are counted: PDF and TIFF pages as they are; Word (.docx, .doc), Excel (.xlsx, .xls), RTF, OpenDocument text and spreadsheets, HTML and EPUB: every 3,000 characters of text is one page; PowerPoint (.pptx, .ppt) and OpenDocument presentations: one page per slide; images: one page per image; CSV and plain text: every 3,000 characters is one page; bibliographies: every 10 entries is one page. Credits follow the requested tier, whichever engine reads the file. Auto bills the tier it selects for the document, but at most mini when a local engine reads it without OCR (text PDFs, CSV, spreadsheets, Office and text files); scans, images and provider parses bill the tier that ran.`;
|
|
470
471
|
/** Academic/grant API: fixed credits per request */
|
|
471
472
|
const academicCreditCosts = {
|
|
472
473
|
academicSearch: 2,
|
|
@@ -2191,6 +2192,9 @@ const supportedFileMimes = [
|
|
|
2191
2192
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
2192
2193
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2193
2194
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
2195
|
+
"application/msword",
|
|
2196
|
+
"application/vnd.ms-excel",
|
|
2197
|
+
"application/vnd.ms-powerpoint",
|
|
2194
2198
|
"text/csv",
|
|
2195
2199
|
"application/csv",
|
|
2196
2200
|
"image/png",
|
|
@@ -4108,4 +4112,15 @@ Object.defineProperty(exports, "contract", {
|
|
|
4108
4112
|
return router_exports;
|
|
4109
4113
|
}
|
|
4110
4114
|
});
|
|
4115
|
+
exports.inputDiagnosticsSchema = inputDiagnosticsSchema;
|
|
4111
4116
|
exports.pdfvectorModelSchema = pdfvectorModelSchema;
|
|
4117
|
+
exports.providerChainEntrySchema = providerChainEntrySchema;
|
|
4118
|
+
exports.retainedInputActorSchema = retainedInputActorSchema;
|
|
4119
|
+
exports.retainedInputActorTypes = retainedInputActorTypes;
|
|
4120
|
+
exports.retainedInputAuditEntrySchema = retainedInputAuditEntrySchema;
|
|
4121
|
+
exports.retainedInputFileStatuses = retainedInputFileStatuses;
|
|
4122
|
+
exports.retainedInputReasons = retainedInputReasons;
|
|
4123
|
+
exports.retainedInputRecordSchema = retainedInputRecordSchema;
|
|
4124
|
+
exports.retainedInputSkipReasons = retainedInputSkipReasons;
|
|
4125
|
+
exports.retainedInputUsageKindSchema = retainedInputUsageKindSchema;
|
|
4126
|
+
exports.retainedInputUsageKinds = retainedInputUsageKinds;
|
package/dist/contract.d.cts
CHANGED
|
@@ -2223,6 +2223,168 @@ export declare const pdfvectorModelSchema: z.ZodEnum<{
|
|
|
2223
2223
|
pro: "pro";
|
|
2224
2224
|
}>;
|
|
2225
2225
|
type PDFVectorModel = z.infer<typeof pdfvectorModelSchema>;
|
|
2226
|
+
export declare const retainedInputUsageKinds: readonly ["api", "free"];
|
|
2227
|
+
export declare const retainedInputReasons: readonly ["system_error", "user_error", "fallback_success"];
|
|
2228
|
+
export declare const retainedInputFileStatuses: readonly ["kept", "skipped", "deleted", "expired", "evicted"];
|
|
2229
|
+
export declare const retainedInputSkipReasons: readonly ["input_not_read", "password_protected", "too_large", "not_eligible", "storage_full", "storage_error"];
|
|
2230
|
+
export declare const retainedInputActorTypes: readonly ["admin", "workspace_owner", "account_deletion"];
|
|
2231
|
+
export declare const retainedInputUsageKindSchema: z.ZodEnum<{
|
|
2232
|
+
api: "api";
|
|
2233
|
+
free: "free";
|
|
2234
|
+
}>;
|
|
2235
|
+
export declare const retainedInputActorSchema: z.ZodObject<{
|
|
2236
|
+
type: z.ZodEnum<{
|
|
2237
|
+
account_deletion: "account_deletion";
|
|
2238
|
+
admin: "admin";
|
|
2239
|
+
workspace_owner: "workspace_owner";
|
|
2240
|
+
}>;
|
|
2241
|
+
userId: z.ZodString;
|
|
2242
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2243
|
+
}, z.core.$strip>;
|
|
2244
|
+
export declare const providerChainEntrySchema: z.ZodObject<{
|
|
2245
|
+
provider: z.ZodString;
|
|
2246
|
+
service: z.ZodString;
|
|
2247
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2248
|
+
status: z.ZodString;
|
|
2249
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2250
|
+
}, z.core.$strip>;
|
|
2251
|
+
export declare const inputDiagnosticsSchema: z.ZodObject<{
|
|
2252
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
2253
|
+
errorStage: z.ZodNullable<z.ZodString>;
|
|
2254
|
+
errorStatus: z.ZodNullable<z.ZodString>;
|
|
2255
|
+
providerChain: z.ZodArray<z.ZodObject<{
|
|
2256
|
+
provider: z.ZodString;
|
|
2257
|
+
service: z.ZodString;
|
|
2258
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2259
|
+
status: z.ZodString;
|
|
2260
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2261
|
+
}, z.core.$strip>>;
|
|
2262
|
+
inputSource: z.ZodNullable<z.ZodString>;
|
|
2263
|
+
declaredMime: z.ZodNullable<z.ZodString>;
|
|
2264
|
+
detectedMime: z.ZodNullable<z.ZodString>;
|
|
2265
|
+
detectedExtension: z.ZodNullable<z.ZodString>;
|
|
2266
|
+
extension: z.ZodNullable<z.ZodString>;
|
|
2267
|
+
documentType: z.ZodNullable<z.ZodString>;
|
|
2268
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
2269
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
2270
|
+
pageCount: z.ZodNullable<z.ZodNumber>;
|
|
2271
|
+
pdf: z.ZodNullable<z.ZodObject<{
|
|
2272
|
+
version: z.ZodNullable<z.ZodString>;
|
|
2273
|
+
producer: z.ZodNullable<z.ZodString>;
|
|
2274
|
+
creator: z.ZodNullable<z.ZodString>;
|
|
2275
|
+
encrypted: z.ZodBoolean;
|
|
2276
|
+
hasForms: z.ZodNullable<z.ZodBoolean>;
|
|
2277
|
+
hasAttachments: z.ZodNullable<z.ZodBoolean>;
|
|
2278
|
+
pagesSampled: z.ZodNumber;
|
|
2279
|
+
pagesWithoutText: z.ZodNumber;
|
|
2280
|
+
scannedRatio: z.ZodNullable<z.ZodNumber>;
|
|
2281
|
+
openError: z.ZodNullable<z.ZodString>;
|
|
2282
|
+
}, z.core.$strip>>;
|
|
2283
|
+
image: z.ZodNullable<z.ZodObject<{
|
|
2284
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
2285
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
2286
|
+
type: z.ZodNullable<z.ZodString>;
|
|
2287
|
+
}, z.core.$strip>>;
|
|
2288
|
+
}, z.core.$strip>;
|
|
2289
|
+
export declare const retainedInputAuditEntrySchema: z.ZodObject<{
|
|
2290
|
+
action: z.ZodEnum<{
|
|
2291
|
+
delete: "delete";
|
|
2292
|
+
download: "download";
|
|
2293
|
+
}>;
|
|
2294
|
+
actorType: z.ZodEnum<{
|
|
2295
|
+
account_deletion: "account_deletion";
|
|
2296
|
+
admin: "admin";
|
|
2297
|
+
workspace_owner: "workspace_owner";
|
|
2298
|
+
}>;
|
|
2299
|
+
actorId: z.ZodString;
|
|
2300
|
+
actorEmail: z.ZodNullable<z.ZodString>;
|
|
2301
|
+
createdAt: z.ZodNumber;
|
|
2302
|
+
}, z.core.$strip>;
|
|
2303
|
+
export declare const retainedInputRecordSchema: z.ZodObject<{
|
|
2304
|
+
usageKind: z.ZodEnum<{
|
|
2305
|
+
api: "api";
|
|
2306
|
+
free: "free";
|
|
2307
|
+
}>;
|
|
2308
|
+
usageId: z.ZodNumber;
|
|
2309
|
+
workspaceId: z.ZodNullable<z.ZodNumber>;
|
|
2310
|
+
operation: z.ZodString;
|
|
2311
|
+
reason: z.ZodEnum<{
|
|
2312
|
+
fallback_success: "fallback_success";
|
|
2313
|
+
system_error: "system_error";
|
|
2314
|
+
user_error: "user_error";
|
|
2315
|
+
}>;
|
|
2316
|
+
fileStatus: z.ZodEnum<{
|
|
2317
|
+
deleted: "deleted";
|
|
2318
|
+
evicted: "evicted";
|
|
2319
|
+
expired: "expired";
|
|
2320
|
+
kept: "kept";
|
|
2321
|
+
skipped: "skipped";
|
|
2322
|
+
}>;
|
|
2323
|
+
skipReason: z.ZodNullable<z.ZodEnum<{
|
|
2324
|
+
input_not_read: "input_not_read";
|
|
2325
|
+
not_eligible: "not_eligible";
|
|
2326
|
+
password_protected: "password_protected";
|
|
2327
|
+
storage_error: "storage_error";
|
|
2328
|
+
storage_full: "storage_full";
|
|
2329
|
+
too_large: "too_large";
|
|
2330
|
+
}>>;
|
|
2331
|
+
inputBytes: z.ZodNullable<z.ZodNumber>;
|
|
2332
|
+
expiresAt: z.ZodNullable<z.ZodNumber>;
|
|
2333
|
+
deletedAt: z.ZodNullable<z.ZodNumber>;
|
|
2334
|
+
diagnostics: z.ZodObject<{
|
|
2335
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
2336
|
+
errorStage: z.ZodNullable<z.ZodString>;
|
|
2337
|
+
errorStatus: z.ZodNullable<z.ZodString>;
|
|
2338
|
+
providerChain: z.ZodArray<z.ZodObject<{
|
|
2339
|
+
provider: z.ZodString;
|
|
2340
|
+
service: z.ZodString;
|
|
2341
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2342
|
+
status: z.ZodString;
|
|
2343
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2344
|
+
}, z.core.$strip>>;
|
|
2345
|
+
inputSource: z.ZodNullable<z.ZodString>;
|
|
2346
|
+
declaredMime: z.ZodNullable<z.ZodString>;
|
|
2347
|
+
detectedMime: z.ZodNullable<z.ZodString>;
|
|
2348
|
+
detectedExtension: z.ZodNullable<z.ZodString>;
|
|
2349
|
+
extension: z.ZodNullable<z.ZodString>;
|
|
2350
|
+
documentType: z.ZodNullable<z.ZodString>;
|
|
2351
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
2352
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
2353
|
+
pageCount: z.ZodNullable<z.ZodNumber>;
|
|
2354
|
+
pdf: z.ZodNullable<z.ZodObject<{
|
|
2355
|
+
version: z.ZodNullable<z.ZodString>;
|
|
2356
|
+
producer: z.ZodNullable<z.ZodString>;
|
|
2357
|
+
creator: z.ZodNullable<z.ZodString>;
|
|
2358
|
+
encrypted: z.ZodBoolean;
|
|
2359
|
+
hasForms: z.ZodNullable<z.ZodBoolean>;
|
|
2360
|
+
hasAttachments: z.ZodNullable<z.ZodBoolean>;
|
|
2361
|
+
pagesSampled: z.ZodNumber;
|
|
2362
|
+
pagesWithoutText: z.ZodNumber;
|
|
2363
|
+
scannedRatio: z.ZodNullable<z.ZodNumber>;
|
|
2364
|
+
openError: z.ZodNullable<z.ZodString>;
|
|
2365
|
+
}, z.core.$strip>>;
|
|
2366
|
+
image: z.ZodNullable<z.ZodObject<{
|
|
2367
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
2368
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
2369
|
+
type: z.ZodNullable<z.ZodString>;
|
|
2370
|
+
}, z.core.$strip>>;
|
|
2371
|
+
}, z.core.$strip>;
|
|
2372
|
+
audit: z.ZodArray<z.ZodObject<{
|
|
2373
|
+
action: z.ZodEnum<{
|
|
2374
|
+
delete: "delete";
|
|
2375
|
+
download: "download";
|
|
2376
|
+
}>;
|
|
2377
|
+
actorType: z.ZodEnum<{
|
|
2378
|
+
account_deletion: "account_deletion";
|
|
2379
|
+
admin: "admin";
|
|
2380
|
+
workspace_owner: "workspace_owner";
|
|
2381
|
+
}>;
|
|
2382
|
+
actorId: z.ZodString;
|
|
2383
|
+
actorEmail: z.ZodNullable<z.ZodString>;
|
|
2384
|
+
createdAt: z.ZodNumber;
|
|
2385
|
+
}, z.core.$strip>>;
|
|
2386
|
+
createdAt: z.ZodNumber;
|
|
2387
|
+
}, z.core.$strip>;
|
|
2226
2388
|
type ContractInputs = InferContractRouterInputs<typeof index_d_exports>;
|
|
2227
2389
|
type ContractOutputs = InferContractRouterOutputs<typeof index_d_exports>;
|
|
2228
2390
|
export { type ContractInputs, type ContractOutputs, type ContractRouterClient, type PDFVectorModel, index_d_exports as contract };
|
package/dist/contract.d.mts
CHANGED
|
@@ -2223,6 +2223,168 @@ export declare const pdfvectorModelSchema: z.ZodEnum<{
|
|
|
2223
2223
|
pro: "pro";
|
|
2224
2224
|
}>;
|
|
2225
2225
|
type PDFVectorModel = z.infer<typeof pdfvectorModelSchema>;
|
|
2226
|
+
export declare const retainedInputUsageKinds: readonly ["api", "free"];
|
|
2227
|
+
export declare const retainedInputReasons: readonly ["system_error", "user_error", "fallback_success"];
|
|
2228
|
+
export declare const retainedInputFileStatuses: readonly ["kept", "skipped", "deleted", "expired", "evicted"];
|
|
2229
|
+
export declare const retainedInputSkipReasons: readonly ["input_not_read", "password_protected", "too_large", "not_eligible", "storage_full", "storage_error"];
|
|
2230
|
+
export declare const retainedInputActorTypes: readonly ["admin", "workspace_owner", "account_deletion"];
|
|
2231
|
+
export declare const retainedInputUsageKindSchema: z.ZodEnum<{
|
|
2232
|
+
api: "api";
|
|
2233
|
+
free: "free";
|
|
2234
|
+
}>;
|
|
2235
|
+
export declare const retainedInputActorSchema: z.ZodObject<{
|
|
2236
|
+
type: z.ZodEnum<{
|
|
2237
|
+
account_deletion: "account_deletion";
|
|
2238
|
+
admin: "admin";
|
|
2239
|
+
workspace_owner: "workspace_owner";
|
|
2240
|
+
}>;
|
|
2241
|
+
userId: z.ZodString;
|
|
2242
|
+
email: z.ZodOptional<z.ZodString>;
|
|
2243
|
+
}, z.core.$strip>;
|
|
2244
|
+
export declare const providerChainEntrySchema: z.ZodObject<{
|
|
2245
|
+
provider: z.ZodString;
|
|
2246
|
+
service: z.ZodString;
|
|
2247
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2248
|
+
status: z.ZodString;
|
|
2249
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2250
|
+
}, z.core.$strip>;
|
|
2251
|
+
export declare const inputDiagnosticsSchema: z.ZodObject<{
|
|
2252
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
2253
|
+
errorStage: z.ZodNullable<z.ZodString>;
|
|
2254
|
+
errorStatus: z.ZodNullable<z.ZodString>;
|
|
2255
|
+
providerChain: z.ZodArray<z.ZodObject<{
|
|
2256
|
+
provider: z.ZodString;
|
|
2257
|
+
service: z.ZodString;
|
|
2258
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2259
|
+
status: z.ZodString;
|
|
2260
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2261
|
+
}, z.core.$strip>>;
|
|
2262
|
+
inputSource: z.ZodNullable<z.ZodString>;
|
|
2263
|
+
declaredMime: z.ZodNullable<z.ZodString>;
|
|
2264
|
+
detectedMime: z.ZodNullable<z.ZodString>;
|
|
2265
|
+
detectedExtension: z.ZodNullable<z.ZodString>;
|
|
2266
|
+
extension: z.ZodNullable<z.ZodString>;
|
|
2267
|
+
documentType: z.ZodNullable<z.ZodString>;
|
|
2268
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
2269
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
2270
|
+
pageCount: z.ZodNullable<z.ZodNumber>;
|
|
2271
|
+
pdf: z.ZodNullable<z.ZodObject<{
|
|
2272
|
+
version: z.ZodNullable<z.ZodString>;
|
|
2273
|
+
producer: z.ZodNullable<z.ZodString>;
|
|
2274
|
+
creator: z.ZodNullable<z.ZodString>;
|
|
2275
|
+
encrypted: z.ZodBoolean;
|
|
2276
|
+
hasForms: z.ZodNullable<z.ZodBoolean>;
|
|
2277
|
+
hasAttachments: z.ZodNullable<z.ZodBoolean>;
|
|
2278
|
+
pagesSampled: z.ZodNumber;
|
|
2279
|
+
pagesWithoutText: z.ZodNumber;
|
|
2280
|
+
scannedRatio: z.ZodNullable<z.ZodNumber>;
|
|
2281
|
+
openError: z.ZodNullable<z.ZodString>;
|
|
2282
|
+
}, z.core.$strip>>;
|
|
2283
|
+
image: z.ZodNullable<z.ZodObject<{
|
|
2284
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
2285
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
2286
|
+
type: z.ZodNullable<z.ZodString>;
|
|
2287
|
+
}, z.core.$strip>>;
|
|
2288
|
+
}, z.core.$strip>;
|
|
2289
|
+
export declare const retainedInputAuditEntrySchema: z.ZodObject<{
|
|
2290
|
+
action: z.ZodEnum<{
|
|
2291
|
+
delete: "delete";
|
|
2292
|
+
download: "download";
|
|
2293
|
+
}>;
|
|
2294
|
+
actorType: z.ZodEnum<{
|
|
2295
|
+
account_deletion: "account_deletion";
|
|
2296
|
+
admin: "admin";
|
|
2297
|
+
workspace_owner: "workspace_owner";
|
|
2298
|
+
}>;
|
|
2299
|
+
actorId: z.ZodString;
|
|
2300
|
+
actorEmail: z.ZodNullable<z.ZodString>;
|
|
2301
|
+
createdAt: z.ZodNumber;
|
|
2302
|
+
}, z.core.$strip>;
|
|
2303
|
+
export declare const retainedInputRecordSchema: z.ZodObject<{
|
|
2304
|
+
usageKind: z.ZodEnum<{
|
|
2305
|
+
api: "api";
|
|
2306
|
+
free: "free";
|
|
2307
|
+
}>;
|
|
2308
|
+
usageId: z.ZodNumber;
|
|
2309
|
+
workspaceId: z.ZodNullable<z.ZodNumber>;
|
|
2310
|
+
operation: z.ZodString;
|
|
2311
|
+
reason: z.ZodEnum<{
|
|
2312
|
+
fallback_success: "fallback_success";
|
|
2313
|
+
system_error: "system_error";
|
|
2314
|
+
user_error: "user_error";
|
|
2315
|
+
}>;
|
|
2316
|
+
fileStatus: z.ZodEnum<{
|
|
2317
|
+
deleted: "deleted";
|
|
2318
|
+
evicted: "evicted";
|
|
2319
|
+
expired: "expired";
|
|
2320
|
+
kept: "kept";
|
|
2321
|
+
skipped: "skipped";
|
|
2322
|
+
}>;
|
|
2323
|
+
skipReason: z.ZodNullable<z.ZodEnum<{
|
|
2324
|
+
input_not_read: "input_not_read";
|
|
2325
|
+
not_eligible: "not_eligible";
|
|
2326
|
+
password_protected: "password_protected";
|
|
2327
|
+
storage_error: "storage_error";
|
|
2328
|
+
storage_full: "storage_full";
|
|
2329
|
+
too_large: "too_large";
|
|
2330
|
+
}>>;
|
|
2331
|
+
inputBytes: z.ZodNullable<z.ZodNumber>;
|
|
2332
|
+
expiresAt: z.ZodNullable<z.ZodNumber>;
|
|
2333
|
+
deletedAt: z.ZodNullable<z.ZodNumber>;
|
|
2334
|
+
diagnostics: z.ZodObject<{
|
|
2335
|
+
errorCode: z.ZodNullable<z.ZodString>;
|
|
2336
|
+
errorStage: z.ZodNullable<z.ZodString>;
|
|
2337
|
+
errorStatus: z.ZodNullable<z.ZodString>;
|
|
2338
|
+
providerChain: z.ZodArray<z.ZodObject<{
|
|
2339
|
+
provider: z.ZodString;
|
|
2340
|
+
service: z.ZodString;
|
|
2341
|
+
model: z.ZodNullable<z.ZodString>;
|
|
2342
|
+
status: z.ZodString;
|
|
2343
|
+
error: z.ZodNullable<z.ZodString>;
|
|
2344
|
+
}, z.core.$strip>>;
|
|
2345
|
+
inputSource: z.ZodNullable<z.ZodString>;
|
|
2346
|
+
declaredMime: z.ZodNullable<z.ZodString>;
|
|
2347
|
+
detectedMime: z.ZodNullable<z.ZodString>;
|
|
2348
|
+
detectedExtension: z.ZodNullable<z.ZodString>;
|
|
2349
|
+
extension: z.ZodNullable<z.ZodString>;
|
|
2350
|
+
documentType: z.ZodNullable<z.ZodString>;
|
|
2351
|
+
sizeBytes: z.ZodNullable<z.ZodNumber>;
|
|
2352
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
2353
|
+
pageCount: z.ZodNullable<z.ZodNumber>;
|
|
2354
|
+
pdf: z.ZodNullable<z.ZodObject<{
|
|
2355
|
+
version: z.ZodNullable<z.ZodString>;
|
|
2356
|
+
producer: z.ZodNullable<z.ZodString>;
|
|
2357
|
+
creator: z.ZodNullable<z.ZodString>;
|
|
2358
|
+
encrypted: z.ZodBoolean;
|
|
2359
|
+
hasForms: z.ZodNullable<z.ZodBoolean>;
|
|
2360
|
+
hasAttachments: z.ZodNullable<z.ZodBoolean>;
|
|
2361
|
+
pagesSampled: z.ZodNumber;
|
|
2362
|
+
pagesWithoutText: z.ZodNumber;
|
|
2363
|
+
scannedRatio: z.ZodNullable<z.ZodNumber>;
|
|
2364
|
+
openError: z.ZodNullable<z.ZodString>;
|
|
2365
|
+
}, z.core.$strip>>;
|
|
2366
|
+
image: z.ZodNullable<z.ZodObject<{
|
|
2367
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
2368
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
2369
|
+
type: z.ZodNullable<z.ZodString>;
|
|
2370
|
+
}, z.core.$strip>>;
|
|
2371
|
+
}, z.core.$strip>;
|
|
2372
|
+
audit: z.ZodArray<z.ZodObject<{
|
|
2373
|
+
action: z.ZodEnum<{
|
|
2374
|
+
delete: "delete";
|
|
2375
|
+
download: "download";
|
|
2376
|
+
}>;
|
|
2377
|
+
actorType: z.ZodEnum<{
|
|
2378
|
+
account_deletion: "account_deletion";
|
|
2379
|
+
admin: "admin";
|
|
2380
|
+
workspace_owner: "workspace_owner";
|
|
2381
|
+
}>;
|
|
2382
|
+
actorId: z.ZodString;
|
|
2383
|
+
actorEmail: z.ZodNullable<z.ZodString>;
|
|
2384
|
+
createdAt: z.ZodNumber;
|
|
2385
|
+
}, z.core.$strip>>;
|
|
2386
|
+
createdAt: z.ZodNumber;
|
|
2387
|
+
}, z.core.$strip>;
|
|
2226
2388
|
type ContractInputs = InferContractRouterInputs<typeof index_d_exports>;
|
|
2227
2389
|
type ContractOutputs = InferContractRouterOutputs<typeof index_d_exports>;
|
|
2228
2390
|
export { type ContractInputs, type ContractOutputs, type ContractRouterClient, type PDFVectorModel, index_d_exports as contract };
|
package/dist/contract.mjs
CHANGED
|
@@ -433,6 +433,7 @@ const allTierFormats = [
|
|
|
433
433
|
"Word (.docx)",
|
|
434
434
|
"Excel (.xlsx)",
|
|
435
435
|
"PowerPoint (.pptx)",
|
|
436
|
+
"Word, Excel and PowerPoint 97-2003 (.doc, .xls, .ppt)",
|
|
436
437
|
"CSV",
|
|
437
438
|
"Text (.txt, .md, .tsv, .xml)",
|
|
438
439
|
"HTML",
|
|
@@ -444,9 +445,9 @@ const allTierFormats = [
|
|
|
444
445
|
/** Formats added by the pro/max/auto tiers. */
|
|
445
446
|
const proTierAdditionalFormats = ["Image (PNG, JPG, TIFF, BMP, HEIF)"];
|
|
446
447
|
/** Short human-readable summary of all supported formats. */
|
|
447
|
-
const allSupportedFormatsShort = "PDF, DOCX, XLSX, PPTX, CSV, PNG, JPG, TIFF, BMP, HEIF, TXT, MD, TSV, XML, RTF, HTML, ODT, ODS, ODP, EPUB, BIB, RIS, NBIB, ENW";
|
|
448
|
+
const allSupportedFormatsShort = "PDF, DOCX, XLSX, PPTX, DOC, XLS, PPT, CSV, PNG, JPG, TIFF, BMP, HEIF, TXT, MD, TSV, XML, RTF, HTML, ODT, ODS, ODP, EPUB, BIB, RIS, NBIB, ENW";
|
|
448
449
|
/** Long human-readable summary of all supported formats. */
|
|
449
|
-
const allSupportedFormatsLong = "PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), CSV, Image (.png, .jpg, .tiff, .bmp, .heif), Plain Text (.txt, .md, .tsv, .xml), RTF, HTML, OpenDocument (.odt, .ods, .odp), EPUB, and Bibliography (.bib, .ris, .nbib, .enw) files";
|
|
450
|
+
const allSupportedFormatsLong = "PDF, Word (.docx, .doc), Excel (.xlsx, .xls), PowerPoint (.pptx, .ppt), CSV, Image (.png, .jpg, .tiff, .bmp, .heif), Plain Text (.txt, .md, .tsv, .xml), RTF, HTML, OpenDocument (.odt, .ods, .odp), EPUB, and Bibliography (.bib, .ris, .nbib, .enw) files";
|
|
450
451
|
/** Image dimension limits enforced by the underlying OCR engine (Azure Document Intelligence).
|
|
451
452
|
* Images outside this range are rejected with HTTP 400 before processing begins. */
|
|
452
453
|
const imageDimensionLimits = {
|
|
@@ -455,7 +456,7 @@ const imageDimensionLimits = {
|
|
|
455
456
|
};
|
|
456
457
|
/** Pre-built format note for API descriptions (used in contract model descriptions). */
|
|
457
458
|
const formatsByTierDescription = `Supported formats by tier:
|
|
458
|
-
- All tiers: ${allTierFormats.join(", ")}.\n- Pro/Max/Auto adds: ${proTierAdditionalFormats.join(", ")}. Image dimensions must be between ${imageDimensionLimits.minPixels}×${imageDimensionLimits.minPixels} and ${imageDimensionLimits.maxPixels}×${imageDimensionLimits.maxPixels} pixels.`;
|
|
459
|
+
- All tiers: ${allTierFormats.join(", ")}.\n- Pro/Max/Auto adds: ${proTierAdditionalFormats.join(", ")}. Image dimensions must be between ${imageDimensionLimits.minPixels}×${imageDimensionLimits.minPixels} and ${imageDimensionLimits.maxPixels}×${imageDimensionLimits.maxPixels} pixels.\nHow pages are counted: PDF and TIFF pages as they are; Word (.docx, .doc), Excel (.xlsx, .xls), RTF, OpenDocument text and spreadsheets, HTML and EPUB: every 3,000 characters of text is one page; PowerPoint (.pptx, .ppt) and OpenDocument presentations: one page per slide; images: one page per image; CSV and plain text: every 3,000 characters is one page; bibliographies: every 10 entries is one page. Credits follow the requested tier, whichever engine reads the file. Auto bills the tier it selects for the document, but at most mini when a local engine reads it without OCR (text PDFs, CSV, spreadsheets, Office and text files); scans, images and provider parses bill the tier that ran.`;
|
|
459
460
|
/** Academic/grant API: fixed credits per request */
|
|
460
461
|
const academicCreditCosts = {
|
|
461
462
|
academicSearch: 2,
|
|
@@ -2180,6 +2181,9 @@ const supportedFileMimes = [
|
|
|
2180
2181
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
2181
2182
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2182
2183
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
2184
|
+
"application/msword",
|
|
2185
|
+
"application/vnd.ms-excel",
|
|
2186
|
+
"application/vnd.ms-powerpoint",
|
|
2183
2187
|
"text/csv",
|
|
2184
2188
|
"application/csv",
|
|
2185
2189
|
"image/png",
|
|
@@ -4091,4 +4095,4 @@ var router_exports = /* @__PURE__ */ __exportAll({
|
|
|
4091
4095
|
identity: () => identity_exports,
|
|
4092
4096
|
invoice: () => invoice_exports
|
|
4093
4097
|
});
|
|
4094
|
-
export { router_exports as contract, pdfvectorModelSchema };
|
|
4098
|
+
export { router_exports as contract, inputDiagnosticsSchema, pdfvectorModelSchema, providerChainEntrySchema, retainedInputActorSchema, retainedInputActorTypes, retainedInputAuditEntrySchema, retainedInputFileStatuses, retainedInputReasons, retainedInputRecordSchema, retainedInputSkipReasons, retainedInputUsageKindSchema, retainedInputUsageKinds };
|
package/dist/index.cjs
CHANGED
|
@@ -1475,8 +1475,15 @@ function inferCategory(code, message, data) {
|
|
|
1475
1475
|
if (lower.includes("json schema") || lower.includes("invalid input") || lower.includes("invalid type") || lower.includes("expected")) return "validation";
|
|
1476
1476
|
return "document_input";
|
|
1477
1477
|
}
|
|
1478
|
+
/** A source website refused or failed a download: neither the caller's input nor a PDF Vector bug, retry later. */
|
|
1479
|
+
const upstreamReasonCodes = /* @__PURE__ */ new Set(["UPSTREAM_FETCH_FAILED", "PDF_NOT_FETCHABLE"]);
|
|
1480
|
+
function isUpstreamFailure(data) {
|
|
1481
|
+
const code = data["code"];
|
|
1482
|
+
return typeof code === "string" && upstreamReasonCodes.has(code);
|
|
1483
|
+
}
|
|
1478
1484
|
function inferOrigin(code, category, data) {
|
|
1479
1485
|
if (data["userError"] === true) return "user";
|
|
1486
|
+
if (isUpstreamFailure(data)) return "system";
|
|
1480
1487
|
if (code === "INTERNAL_SERVER_ERROR") return "system";
|
|
1481
1488
|
if (category === "document_processing" && data["userError"] !== true) return "system";
|
|
1482
1489
|
return "user";
|
|
@@ -1536,6 +1543,10 @@ function inferSuggestion(code, message, data) {
|
|
|
1536
1543
|
}
|
|
1537
1544
|
const reasonCode = readString(data, "code");
|
|
1538
1545
|
if (reasonCode === "DOCUMENT_PROCESSING_FAILED" || reasonCode === "DOCUMENT_AI_INVALID_ARGUMENT" || reasonCode === "DOCUMENT_INTELLIGENCE_INVALID_REQUEST") return requestId ? `Retry the request. If it keeps failing, contact support with requestId ${requestId}.` : "Retry the request. If it keeps failing, contact support with the request details.";
|
|
1546
|
+
if (reasonCode === "UPSTREAM_FETCH_FAILED") return "The website blocked or failed the download. Download the file yourself and send it as file or base64, or retry later.";
|
|
1547
|
+
if (reasonCode === "PDF_NOT_FETCHABLE") return "The paper's open-access PDF could not be downloaded right now. Retry later, upload the PDF, or pass a direct PDF URL to document.parse.";
|
|
1548
|
+
if (reasonCode === "CONTENT_TYPE_MISMATCH") return "Send the original file: its content does not match the declared MIME type or extension.";
|
|
1549
|
+
if (reasonCode === "ARCHIVE_TOO_LARGE") return "Send the document itself or a smaller archive: this one expands beyond the processing limit.";
|
|
1539
1550
|
if (reasonCode === "EXTRACTION_FAILED") return "Simplify the extraction schema or prompt, then retry.";
|
|
1540
1551
|
if (reasonCode === "MODEL_OUTPUT_UNUSABLE") return "Try a simpler question or a clearer document, then retry.";
|
|
1541
1552
|
if (lower.includes("password-protected")) return "Remove the document password or upload an unlocked copy.";
|
|
@@ -1580,7 +1591,7 @@ var PDFVectorError = class extends Error {
|
|
|
1580
1591
|
this.title = inferTitle(this.code, this.name, this.message, readString(this.data, "code")?.startsWith("BILLING_") ?? false);
|
|
1581
1592
|
this.suggestion = inferSuggestion(this.code, this.message, this.data);
|
|
1582
1593
|
this.retryableWithHigherModel = hasHigherModelHint(this.message, this.data);
|
|
1583
|
-
this.retryable = this.retryableWithHigherModel || this.code === "TOO_MANY_REQUESTS" || this.code === "INTERNAL_SERVER_ERROR";
|
|
1594
|
+
this.retryable = this.retryableWithHigherModel || isUpstreamFailure(this.data) || this.code === "TOO_MANY_REQUESTS" || this.code === "INTERNAL_SERVER_ERROR";
|
|
1584
1595
|
this.requestedModel = readString(this.data, "requestedModel");
|
|
1585
1596
|
this.reasonCode = readString(this.data, "code");
|
|
1586
1597
|
this.supportMessage = this.requestId ? `PDF Vector request ${this.requestId} failed with ${this.code}: ${this.message}` : `PDF Vector request failed with ${this.code}: ${this.message}`;
|
package/dist/index.mjs
CHANGED
|
@@ -1474,8 +1474,15 @@ function inferCategory(code, message, data) {
|
|
|
1474
1474
|
if (lower.includes("json schema") || lower.includes("invalid input") || lower.includes("invalid type") || lower.includes("expected")) return "validation";
|
|
1475
1475
|
return "document_input";
|
|
1476
1476
|
}
|
|
1477
|
+
/** A source website refused or failed a download: neither the caller's input nor a PDF Vector bug, retry later. */
|
|
1478
|
+
const upstreamReasonCodes = /* @__PURE__ */ new Set(["UPSTREAM_FETCH_FAILED", "PDF_NOT_FETCHABLE"]);
|
|
1479
|
+
function isUpstreamFailure(data) {
|
|
1480
|
+
const code = data["code"];
|
|
1481
|
+
return typeof code === "string" && upstreamReasonCodes.has(code);
|
|
1482
|
+
}
|
|
1477
1483
|
function inferOrigin(code, category, data) {
|
|
1478
1484
|
if (data["userError"] === true) return "user";
|
|
1485
|
+
if (isUpstreamFailure(data)) return "system";
|
|
1479
1486
|
if (code === "INTERNAL_SERVER_ERROR") return "system";
|
|
1480
1487
|
if (category === "document_processing" && data["userError"] !== true) return "system";
|
|
1481
1488
|
return "user";
|
|
@@ -1535,6 +1542,10 @@ function inferSuggestion(code, message, data) {
|
|
|
1535
1542
|
}
|
|
1536
1543
|
const reasonCode = readString(data, "code");
|
|
1537
1544
|
if (reasonCode === "DOCUMENT_PROCESSING_FAILED" || reasonCode === "DOCUMENT_AI_INVALID_ARGUMENT" || reasonCode === "DOCUMENT_INTELLIGENCE_INVALID_REQUEST") return requestId ? `Retry the request. If it keeps failing, contact support with requestId ${requestId}.` : "Retry the request. If it keeps failing, contact support with the request details.";
|
|
1545
|
+
if (reasonCode === "UPSTREAM_FETCH_FAILED") return "The website blocked or failed the download. Download the file yourself and send it as file or base64, or retry later.";
|
|
1546
|
+
if (reasonCode === "PDF_NOT_FETCHABLE") return "The paper's open-access PDF could not be downloaded right now. Retry later, upload the PDF, or pass a direct PDF URL to document.parse.";
|
|
1547
|
+
if (reasonCode === "CONTENT_TYPE_MISMATCH") return "Send the original file: its content does not match the declared MIME type or extension.";
|
|
1548
|
+
if (reasonCode === "ARCHIVE_TOO_LARGE") return "Send the document itself or a smaller archive: this one expands beyond the processing limit.";
|
|
1538
1549
|
if (reasonCode === "EXTRACTION_FAILED") return "Simplify the extraction schema or prompt, then retry.";
|
|
1539
1550
|
if (reasonCode === "MODEL_OUTPUT_UNUSABLE") return "Try a simpler question or a clearer document, then retry.";
|
|
1540
1551
|
if (lower.includes("password-protected")) return "Remove the document password or upload an unlocked copy.";
|
|
@@ -1579,7 +1590,7 @@ var PDFVectorError = class extends Error {
|
|
|
1579
1590
|
this.title = inferTitle(this.code, this.name, this.message, readString(this.data, "code")?.startsWith("BILLING_") ?? false);
|
|
1580
1591
|
this.suggestion = inferSuggestion(this.code, this.message, this.data);
|
|
1581
1592
|
this.retryableWithHigherModel = hasHigherModelHint(this.message, this.data);
|
|
1582
|
-
this.retryable = this.retryableWithHigherModel || this.code === "TOO_MANY_REQUESTS" || this.code === "INTERNAL_SERVER_ERROR";
|
|
1593
|
+
this.retryable = this.retryableWithHigherModel || isUpstreamFailure(this.data) || this.code === "TOO_MANY_REQUESTS" || this.code === "INTERNAL_SERVER_ERROR";
|
|
1583
1594
|
this.requestedModel = readString(this.data, "requestedModel");
|
|
1584
1595
|
this.reasonCode = readString(this.data, "code");
|
|
1585
1596
|
this.supportMessage = this.requestId ? `PDF Vector request ${this.requestId} failed with ${this.code}: ${this.message}` : `PDF Vector request failed with ${this.code}: ${this.message}`;
|