@pdfvector/client 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +19 -2
- package/dist/contract.cjs +175 -66
- package/dist/contract.d.cts +22 -1
- package/dist/contract.d.mts +22 -1
- package/dist/contract.mjs +175 -66
- package/dist/index.cjs +17 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.mjs +17 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @pdfvector/client
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#691](https://github.com/phuctm97/pdfvector/pull/691) [`69e9221`](https://github.com/phuctm97/pdfvector/commit/69e9221bd12b0d941b8809652d4a564ffca1bb8c) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Errors that need a different model now name it: the API returns `data.suggestedModel`, the SDK exposes `error.suggestedModel`, and Make shows it in the error message.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`69e9221`](https://github.com/phuctm97/pdfvector/commit/69e9221bd12b0d941b8809652d4a564ffca1bb8c)]:
|
|
12
|
+
- @pdfvector/instance-client@0.2.0
|
|
13
|
+
|
|
14
|
+
## 0.1.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#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.
|
|
19
|
+
|
|
20
|
+
- 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).
|
|
21
|
+
- 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.
|
|
22
|
+
- 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.
|
|
23
|
+
- 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.
|
|
24
|
+
- 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.
|
|
25
|
+
- Sentry events are rate limited per error key (10 per hour).
|
|
26
|
+
- 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.
|
|
27
|
+
- Updated dependencies [[`6dcf020`](https://github.com/phuctm97/pdfvector/commit/6dcf0205899627e57b7824d7d7a2837f4537e336)]:
|
|
28
|
+
- @pdfvector/instance-client@0.1.2
|
|
29
|
+
|
|
3
30
|
## 0.1.2
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -635,7 +635,18 @@ console.log(resultB.documentId); // "doc-b"
|
|
|
635
635
|
|
|
636
636
|
All API errors are thrown as `PDFVectorError` instances. The SDK maps server errors into specific subclasses and adds user/agent-friendly fields such as `title`, `suggestion`, `userError`, retry flags, and `requestId`.
|
|
637
637
|
|
|
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 `
|
|
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`, `retryableWithHigherModel` and `suggestedModel` 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
|
+
|
|
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.
|
|
639
650
|
|
|
640
651
|
```typescript
|
|
641
652
|
import {
|
|
@@ -686,6 +697,11 @@ try {
|
|
|
686
697
|
if (isPDFVectorError(error) && error.retryableWithHigherModel) {
|
|
687
698
|
console.error("Retry with a stronger model or a smaller document.");
|
|
688
699
|
}
|
|
700
|
+
|
|
701
|
+
// e.g. "mini" for a scanned PDF sent to nano, "auto" for a document over the 30-page limit
|
|
702
|
+
if (isPDFVectorError(error) && error.suggestedModel) {
|
|
703
|
+
console.error(`Retry with model ${error.suggestedModel}.`);
|
|
704
|
+
}
|
|
689
705
|
}
|
|
690
706
|
```
|
|
691
707
|
|
|
@@ -788,7 +804,7 @@ PDFVectorError
|
|
|
788
804
|
│ ├── PageLimitExceededError — pageCount, pageLimit, model
|
|
789
805
|
│ ├── PasswordProtectedError
|
|
790
806
|
│ ├── UnsupportedFormatError — format, supportedFormats
|
|
791
|
-
│ ├── URLFetchError — url, statusCode, statusText
|
|
807
|
+
│ ├── URLFetchError — url, statusCode, statusText (reasonCode UPSTREAM_FETCH_FAILED: the site refused)
|
|
792
808
|
│ ├── InvalidDocumentURLError
|
|
793
809
|
│ ├── InvalidBase64Error
|
|
794
810
|
│ ├── TierNotSupportedError — documentType, model, allowedTypes
|
|
@@ -823,6 +839,7 @@ PDFVectorError
|
|
|
823
839
|
| `userError` | `boolean` | `true` for expected caller-fixable failures |
|
|
824
840
|
| `retryable` | `boolean` | `true` when retrying may help |
|
|
825
841
|
| `retryableWithHigherModel` | `boolean` | `true` when retrying with a stronger model or smaller document may help |
|
|
842
|
+
| `suggestedModel` | `string \| undefined` | Model to retry with when the server names one (`data.suggestedModel`): the next tier after a model that could not read the document, `auto` for files over the tier's page or size limit that fit auto's (no suggestion when nothing fits), the lowest tier that supports the file type. It does not change `retryable` or `retryableWithHigherModel` |
|
|
826
843
|
| `requestId` | `number \| undefined` | Server-assigned request ID; include in support tickets |
|
|
827
844
|
| `documentId` | `string \| undefined` | Echoed back if you passed `context.documentId` |
|
|
828
845
|
| `reasonCode` | `string \| undefined` | More specific server reason when available, such as `NO_PUBLIC_PDF` |
|