@pdfvector/instance-contract 0.2.8 → 0.2.9
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/.tsc/lib/index.d.ts +1 -11
- package/.tsc/lib/index.d.ts.map +1 -1
- package/.tsc/lib/index.js +1 -7
- package/CHANGELOG.md +13 -0
- package/package.json +4 -4
- package/.tsc/lib/fetchable-url-schema.d.ts +0 -3
- package/.tsc/lib/fetchable-url-schema.d.ts.map +0 -1
- package/.tsc/lib/fetchable-url-schema.js +0 -13
- package/.tsc/lib/json-schema-input.d.ts +0 -3
- package/.tsc/lib/json-schema-input.d.ts.map +0 -1
- package/.tsc/lib/json-schema-input.js +0 -25
- package/.tsc/lib/page-markdown-schema.d.ts +0 -6
- package/.tsc/lib/page-markdown-schema.d.ts.map +0 -1
- package/.tsc/lib/page-markdown-schema.js +0 -9
- package/.tsc/lib/pdfvector-model-schema.d.ts +0 -8
- package/.tsc/lib/pdfvector-model-schema.d.ts.map +0 -1
- package/.tsc/lib/pdfvector-model-schema.js +0 -4
- package/.tsc/lib/pdfvector-model.d.ts +0 -4
- package/.tsc/lib/pdfvector-model.d.ts.map +0 -1
- package/.tsc/lib/pdfvector-model.js +0 -0
- package/.tsc/lib/router/academic/fetch.d.ts +0 -69
- package/.tsc/lib/router/academic/fetch.d.ts.map +0 -1
- package/.tsc/lib/router/academic/fetch.js +0 -119
- package/.tsc/lib/router/academic/find-citations.d.ts +0 -70
- package/.tsc/lib/router/academic/find-citations.d.ts.map +0 -1
- package/.tsc/lib/router/academic/find-citations.js +0 -116
- package/.tsc/lib/router/academic/index.d.ts +0 -8
- package/.tsc/lib/router/academic/index.d.ts.map +0 -1
- package/.tsc/lib/router/academic/index.js +0 -7
- package/.tsc/lib/router/academic/paper-graph.d.ts +0 -113
- package/.tsc/lib/router/academic/paper-graph.d.ts.map +0 -1
- package/.tsc/lib/router/academic/paper-graph.js +0 -144
- package/.tsc/lib/router/academic/parse.d.ts +0 -50
- package/.tsc/lib/router/academic/parse.d.ts.map +0 -1
- package/.tsc/lib/router/academic/parse.js +0 -146
- package/.tsc/lib/router/academic/provider.d.ts +0 -18
- package/.tsc/lib/router/academic/provider.d.ts.map +0 -1
- package/.tsc/lib/router/academic/provider.js +0 -16
- package/.tsc/lib/router/academic/search-grants.d.ts +0 -84
- package/.tsc/lib/router/academic/search-grants.d.ts.map +0 -1
- package/.tsc/lib/router/academic/search-grants.js +0 -171
- package/.tsc/lib/router/academic/search.d.ts +0 -83
- package/.tsc/lib/router/academic/search.d.ts.map +0 -1
- package/.tsc/lib/router/academic/search.js +0 -154
- package/.tsc/lib/router/academic/similar-papers.d.ts +0 -89
- package/.tsc/lib/router/academic/similar-papers.d.ts.map +0 -1
- package/.tsc/lib/router/academic/similar-papers.js +0 -143
- package/.tsc/lib/router/admin/get-environment.d.ts +0 -5
- package/.tsc/lib/router/admin/get-environment.d.ts.map +0 -1
- package/.tsc/lib/router/admin/get-environment.js +0 -13
- package/.tsc/lib/router/admin/get-free-usage-records.d.ts +0 -34
- package/.tsc/lib/router/admin/get-free-usage-records.d.ts.map +0 -1
- package/.tsc/lib/router/admin/get-free-usage-records.js +0 -38
- package/.tsc/lib/router/admin/get-provider-usage-records.d.ts +0 -41
- package/.tsc/lib/router/admin/get-provider-usage-records.d.ts.map +0 -1
- package/.tsc/lib/router/admin/get-provider-usage-records.js +0 -50
- package/.tsc/lib/router/admin/get-usage-records.d.ts +0 -48
- package/.tsc/lib/router/admin/get-usage-records.d.ts.map +0 -1
- package/.tsc/lib/router/admin/get-usage-records.js +0 -44
- package/.tsc/lib/router/admin/health-check.d.ts +0 -5
- package/.tsc/lib/router/admin/health-check.d.ts.map +0 -1
- package/.tsc/lib/router/admin/health-check.js +0 -14
- package/.tsc/lib/router/admin/index.d.ts +0 -9
- package/.tsc/lib/router/admin/index.d.ts.map +0 -1
- package/.tsc/lib/router/admin/index.js +0 -8
- package/.tsc/lib/router/admin/set-domain.d.ts +0 -7
- package/.tsc/lib/router/admin/set-domain.d.ts.map +0 -1
- package/.tsc/lib/router/admin/set-domain.js +0 -20
- package/.tsc/lib/router/admin/set-environment.d.ts +0 -7
- package/.tsc/lib/router/admin/set-environment.d.ts.map +0 -1
- package/.tsc/lib/router/admin/set-environment.js +0 -41
- package/.tsc/lib/router/admin/set-version.d.ts +0 -7
- package/.tsc/lib/router/admin/set-version.d.ts.map +0 -1
- package/.tsc/lib/router/admin/set-version.js +0 -21
- package/.tsc/lib/router/authenticate/index.d.ts +0 -2
- package/.tsc/lib/router/authenticate/index.d.ts.map +0 -1
- package/.tsc/lib/router/authenticate/index.js +0 -1
- package/.tsc/lib/router/authenticate/validate-credential.d.ts +0 -7
- package/.tsc/lib/router/authenticate/validate-credential.d.ts.map +0 -1
- package/.tsc/lib/router/authenticate/validate-credential.js +0 -20
- package/.tsc/lib/router/bankStatement/ask.d.ts +0 -32
- package/.tsc/lib/router/bankStatement/ask.d.ts.map +0 -1
- package/.tsc/lib/router/bankStatement/ask.js +0 -88
- package/.tsc/lib/router/bankStatement/extract.d.ts +0 -33
- package/.tsc/lib/router/bankStatement/extract.d.ts.map +0 -1
- package/.tsc/lib/router/bankStatement/extract.js +0 -113
- package/.tsc/lib/router/bankStatement/get-default-spec.d.ts +0 -2
- package/.tsc/lib/router/bankStatement/get-default-spec.d.ts.map +0 -1
- package/.tsc/lib/router/bankStatement/get-default-spec.js +0 -19
- package/.tsc/lib/router/bankStatement/index.d.ts +0 -4
- package/.tsc/lib/router/bankStatement/index.d.ts.map +0 -1
- package/.tsc/lib/router/bankStatement/index.js +0 -3
- package/.tsc/lib/router/bankStatement/parse.d.ts +0 -28
- package/.tsc/lib/router/bankStatement/parse.d.ts.map +0 -1
- package/.tsc/lib/router/bankStatement/parse.js +0 -105
- package/.tsc/lib/router/document/ask.d.ts +0 -32
- package/.tsc/lib/router/document/ask.d.ts.map +0 -1
- package/.tsc/lib/router/document/ask.js +0 -134
- package/.tsc/lib/router/document/extract.d.ts +0 -33
- package/.tsc/lib/router/document/extract.d.ts.map +0 -1
- package/.tsc/lib/router/document/extract.js +0 -152
- package/.tsc/lib/router/document/get-default-spec.d.ts +0 -2
- package/.tsc/lib/router/document/get-default-spec.d.ts.map +0 -1
- package/.tsc/lib/router/document/get-default-spec.js +0 -19
- package/.tsc/lib/router/document/index.d.ts +0 -4
- package/.tsc/lib/router/document/index.d.ts.map +0 -1
- package/.tsc/lib/router/document/index.js +0 -3
- package/.tsc/lib/router/document/parse.d.ts +0 -40
- package/.tsc/lib/router/document/parse.d.ts.map +0 -1
- package/.tsc/lib/router/document/parse.js +0 -142
- package/.tsc/lib/router/free/bank-statement-parse.d.ts +0 -16
- package/.tsc/lib/router/free/bank-statement-parse.d.ts.map +0 -1
- package/.tsc/lib/router/free/bank-statement-parse.js +0 -87
- package/.tsc/lib/router/free/generate-schema.d.ts +0 -8
- package/.tsc/lib/router/free/generate-schema.d.ts.map +0 -1
- package/.tsc/lib/router/free/generate-schema.js +0 -110
- package/.tsc/lib/router/free/index.d.ts +0 -5
- package/.tsc/lib/router/free/index.d.ts.map +0 -1
- package/.tsc/lib/router/free/index.js +0 -4
- package/.tsc/lib/router/free/publication-pdf-url.d.ts +0 -12
- package/.tsc/lib/router/free/publication-pdf-url.d.ts.map +0 -1
- package/.tsc/lib/router/free/publication-pdf-url.js +0 -86
- package/.tsc/lib/router/free/rate-limit-status.d.ts +0 -19
- package/.tsc/lib/router/free/rate-limit-status.d.ts.map +0 -1
- package/.tsc/lib/router/free/rate-limit-status.js +0 -36
- package/.tsc/lib/router/identity/ask.d.ts +0 -32
- package/.tsc/lib/router/identity/ask.d.ts.map +0 -1
- package/.tsc/lib/router/identity/ask.js +0 -95
- package/.tsc/lib/router/identity/extract.d.ts +0 -33
- package/.tsc/lib/router/identity/extract.d.ts.map +0 -1
- package/.tsc/lib/router/identity/extract.js +0 -103
- package/.tsc/lib/router/identity/get-default-spec.d.ts +0 -2
- package/.tsc/lib/router/identity/get-default-spec.d.ts.map +0 -1
- package/.tsc/lib/router/identity/get-default-spec.js +0 -19
- package/.tsc/lib/router/identity/index.d.ts +0 -4
- package/.tsc/lib/router/identity/index.d.ts.map +0 -1
- package/.tsc/lib/router/identity/index.js +0 -3
- package/.tsc/lib/router/identity/parse.d.ts +0 -29
- package/.tsc/lib/router/identity/parse.d.ts.map +0 -1
- package/.tsc/lib/router/identity/parse.js +0 -109
- package/.tsc/lib/router/index.d.ts +0 -9
- package/.tsc/lib/router/index.d.ts.map +0 -1
- package/.tsc/lib/router/index.js +0 -8
- package/.tsc/lib/router/invoice/ask.d.ts +0 -32
- package/.tsc/lib/router/invoice/ask.d.ts.map +0 -1
- package/.tsc/lib/router/invoice/ask.js +0 -85
- package/.tsc/lib/router/invoice/extract.d.ts +0 -33
- package/.tsc/lib/router/invoice/extract.d.ts.map +0 -1
- package/.tsc/lib/router/invoice/extract.js +0 -109
- package/.tsc/lib/router/invoice/get-default-spec.d.ts +0 -2
- package/.tsc/lib/router/invoice/get-default-spec.d.ts.map +0 -1
- package/.tsc/lib/router/invoice/get-default-spec.js +0 -19
- package/.tsc/lib/router/invoice/index.d.ts +0 -4
- package/.tsc/lib/router/invoice/index.d.ts.map +0 -1
- package/.tsc/lib/router/invoice/index.js +0 -3
- package/.tsc/lib/router/invoice/parse.d.ts +0 -28
- package/.tsc/lib/router/invoice/parse.d.ts.map +0 -1
- package/.tsc/lib/router/invoice/parse.js +0 -100
- package/.tsc/lib/supported-mimes.d.ts +0 -35
- package/.tsc/lib/supported-mimes.d.ts.map +0 -1
- package/.tsc/lib/supported-mimes.js +0 -130
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/router/bankStatement/extract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkIxB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAYS,CAAC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
|
-
import { getOpenApiCodeSamples } from "@pdfvector/api-docs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
|
|
5
|
-
import { jsonSchemaInput } from "../../json-schema-input.js";
|
|
6
|
-
import { pdfvectorModelSchema } from "../../pdfvector-model-schema.js";
|
|
7
|
-
import { outputExtractModelDescription, specializedExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
|
|
8
|
-
import { getDefaultSpec } from "./get-default-spec.js";
|
|
9
|
-
const specializedModelSchema = z
|
|
10
|
-
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
11
|
-
.default("auto");
|
|
12
|
-
const extractInputSchema = z.object({
|
|
13
|
-
url: fetchableUrlSchema
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("URL of the bank statement file to fetch and parse"),
|
|
16
|
-
file: z
|
|
17
|
-
.file()
|
|
18
|
-
.mime([...supportedFileMimes], supportedFileMimeErrorMessage)
|
|
19
|
-
.optional()
|
|
20
|
-
.describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
21
|
-
base64: z
|
|
22
|
-
.string()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Base64-encoded bank statement file content"),
|
|
25
|
-
prompt: z
|
|
26
|
-
.string()
|
|
27
|
-
.min(4, "prompt must be at least 4 characters")
|
|
28
|
-
.describe("The prompt instructing the AI how to extract data from the bank statement"),
|
|
29
|
-
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the bank statement. Can be a JSON object or a JSON string."),
|
|
30
|
-
model: specializedModelSchema.describe(specializedExtractModelDescription),
|
|
31
|
-
documentId: z
|
|
32
|
-
.string()
|
|
33
|
-
.trim()
|
|
34
|
-
.min(1)
|
|
35
|
-
.max(512)
|
|
36
|
-
.optional()
|
|
37
|
-
.describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
38
|
-
callback: z
|
|
39
|
-
.object({
|
|
40
|
-
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
41
|
-
type: z
|
|
42
|
-
.string()
|
|
43
|
-
.optional()
|
|
44
|
-
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
45
|
-
})
|
|
46
|
-
.optional()
|
|
47
|
-
.describe("Optional webhook callback for async processing. " +
|
|
48
|
-
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
49
|
-
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
50
|
-
"Useful for long-running operations that may exceed client timeout limits."),
|
|
51
|
-
});
|
|
52
|
-
const extractOutputSchema = z.object({
|
|
53
|
-
data: z
|
|
54
|
-
.unknown()
|
|
55
|
-
.refine((val) => val != null &&
|
|
56
|
-
(typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" })
|
|
57
|
-
.describe("Extracted structured data matching the provided JSON Schema"),
|
|
58
|
-
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
59
|
-
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
60
|
-
credits: z
|
|
61
|
-
.number()
|
|
62
|
-
.int()
|
|
63
|
-
.describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
64
|
-
requestId: z
|
|
65
|
-
.number()
|
|
66
|
-
.int()
|
|
67
|
-
.describe("Unique request identifier for this API call"),
|
|
68
|
-
documentId: z
|
|
69
|
-
.string()
|
|
70
|
-
.optional()
|
|
71
|
-
.describe("Document ID if provided via x-pdfvector-document-id header or request body"),
|
|
72
|
-
});
|
|
73
|
-
const requestExamples = {
|
|
74
|
-
"Extract from URL": {
|
|
75
|
-
summary: "Extract from URL",
|
|
76
|
-
value: {
|
|
77
|
-
url: "https://example.com/bank-statement.pdf",
|
|
78
|
-
prompt: "Extract the account number, statement period, and transactions",
|
|
79
|
-
schema: JSON.stringify({
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
accountNumber: { type: "string" },
|
|
83
|
-
statementPeriod: { type: "string" },
|
|
84
|
-
transactions: {
|
|
85
|
-
type: "array",
|
|
86
|
-
items: {
|
|
87
|
-
type: "object",
|
|
88
|
-
properties: {
|
|
89
|
-
date: { type: "string" },
|
|
90
|
-
description: { type: "string" },
|
|
91
|
-
amount: { type: "number" },
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
required: ["accountNumber", "statementPeriod"],
|
|
97
|
-
}),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
export const extract = oc
|
|
102
|
-
.route({
|
|
103
|
-
summary: "Extract structured data from a bank statement",
|
|
104
|
-
description: `Parse a bank statement and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
105
|
-
tags: ["Bank Statement"],
|
|
106
|
-
spec: (op) => {
|
|
107
|
-
const spec = getDefaultSpec(op, requestExamples);
|
|
108
|
-
spec["x-codeSamples"] = getOpenApiCodeSamples("bank-statement-extract");
|
|
109
|
-
return spec;
|
|
110
|
-
},
|
|
111
|
-
})
|
|
112
|
-
.input(extractInputSchema)
|
|
113
|
-
.output(extractOutputSchema);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-spec.d.ts","sourceRoot":"","sources":["../../../../lib/router/bankStatement/get-default-spec.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAC7B,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function getDefaultSpec(op, requestExamples) {
|
|
2
|
-
op["security"] = [{ bearerAuth: [] }];
|
|
3
|
-
const params = (op["parameters"] ?? []);
|
|
4
|
-
params.push({
|
|
5
|
-
name: "x-pdfvector-document-id",
|
|
6
|
-
in: "header",
|
|
7
|
-
required: false,
|
|
8
|
-
schema: { type: "string", default: "my-doc-123" },
|
|
9
|
-
description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking.",
|
|
10
|
-
});
|
|
11
|
-
op["parameters"] = params;
|
|
12
|
-
const reqBody = op["requestBody"];
|
|
13
|
-
if (reqBody?.content) {
|
|
14
|
-
for (const mediaType of Object.values(reqBody.content)) {
|
|
15
|
-
mediaType["examples"] = requestExamples;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return op;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/router/bankStatement/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const parse: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
-
url: z.ZodOptional<z.ZodURL>;
|
|
4
|
-
file: z.ZodOptional<z.ZodFile>;
|
|
5
|
-
base64: z.ZodOptional<z.ZodString>;
|
|
6
|
-
model: z.ZodDefault<z.ZodEnum<{
|
|
7
|
-
auto: "auto";
|
|
8
|
-
max: "max";
|
|
9
|
-
pro: "pro";
|
|
10
|
-
}>>;
|
|
11
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
12
|
-
callback: z.ZodOptional<z.ZodObject<{
|
|
13
|
-
url: z.ZodURL;
|
|
14
|
-
type: z.ZodOptional<z.ZodString>;
|
|
15
|
-
}, z.core.$strip>>;
|
|
16
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
-
markdown: z.ZodString;
|
|
18
|
-
pageCount: z.ZodNumber;
|
|
19
|
-
model: z.ZodEnum<{
|
|
20
|
-
max: "max";
|
|
21
|
-
pro: "pro";
|
|
22
|
-
}>;
|
|
23
|
-
credits: z.ZodNumber;
|
|
24
|
-
requestId: z.ZodNumber;
|
|
25
|
-
html: z.ZodOptional<z.ZodString>;
|
|
26
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
28
|
-
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../lib/router/bankStatement/parse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsHxB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;8DAYS,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
|
-
import { getOpenApiCodeSamples } from "@pdfvector/api-docs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
|
|
5
|
-
import { specializedParseModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
|
|
6
|
-
import { getDefaultSpec } from "./get-default-spec.js";
|
|
7
|
-
const specializedParseModelSchema = z
|
|
8
|
-
.enum(["pro", "max", "auto"], {
|
|
9
|
-
message: "model must be one of: pro, max, auto",
|
|
10
|
-
})
|
|
11
|
-
.default("auto");
|
|
12
|
-
const parseInputSchema = z.object({
|
|
13
|
-
url: fetchableUrlSchema
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("URL of the bank statement file to fetch and parse"),
|
|
16
|
-
file: z
|
|
17
|
-
.file()
|
|
18
|
-
.mime([...supportedFileMimes], supportedFileMimeErrorMessage)
|
|
19
|
-
.optional()
|
|
20
|
-
.describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
21
|
-
base64: z
|
|
22
|
-
.string()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Base64-encoded bank statement file content"),
|
|
25
|
-
model: specializedParseModelSchema.describe(specializedParseModelDescription("bank statement")),
|
|
26
|
-
documentId: z
|
|
27
|
-
.string()
|
|
28
|
-
.trim()
|
|
29
|
-
.min(1)
|
|
30
|
-
.max(512)
|
|
31
|
-
.optional()
|
|
32
|
-
.describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
33
|
-
callback: z
|
|
34
|
-
.object({
|
|
35
|
-
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
36
|
-
type: z
|
|
37
|
-
.string()
|
|
38
|
-
.optional()
|
|
39
|
-
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
40
|
-
})
|
|
41
|
-
.optional()
|
|
42
|
-
.describe("Optional webhook callback for async processing. " +
|
|
43
|
-
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
44
|
-
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
45
|
-
"Useful for long-running operations that may exceed client timeout limits."),
|
|
46
|
-
});
|
|
47
|
-
const parseOutputSchema = z.object({
|
|
48
|
-
markdown: z
|
|
49
|
-
.string()
|
|
50
|
-
.describe("Extracted text content from the bank statement"),
|
|
51
|
-
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
52
|
-
model: z
|
|
53
|
-
.enum(["pro", "max"])
|
|
54
|
-
.describe("Model tier used to parse the bank statement"),
|
|
55
|
-
credits: z
|
|
56
|
-
.number()
|
|
57
|
-
.int()
|
|
58
|
-
.describe("Number of credits consumed by this API call. Cost per page: pro=6, max=10."),
|
|
59
|
-
requestId: z
|
|
60
|
-
.number()
|
|
61
|
-
.int()
|
|
62
|
-
.describe("Unique request identifier for this API call"),
|
|
63
|
-
html: z
|
|
64
|
-
.string()
|
|
65
|
-
.optional()
|
|
66
|
-
.describe("Full HTML representation of the document content. Only available when using the 'max' model. " +
|
|
67
|
-
"Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
|
|
68
|
-
documentId: z
|
|
69
|
-
.string()
|
|
70
|
-
.optional()
|
|
71
|
-
.describe("Document ID if provided via x-pdfvector-document-id header or request body"),
|
|
72
|
-
});
|
|
73
|
-
const requestExamples = {
|
|
74
|
-
"Parse from URL": {
|
|
75
|
-
summary: "Parse from URL",
|
|
76
|
-
value: {
|
|
77
|
-
url: "https://example.com/bank-statement.pdf",
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
"Parse from base64": {
|
|
81
|
-
summary: "Parse from base64",
|
|
82
|
-
value: {
|
|
83
|
-
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
"Parse from file upload": {
|
|
87
|
-
summary: "Parse from file upload",
|
|
88
|
-
value: {
|
|
89
|
-
file: "(binary)",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
export const parse = oc
|
|
94
|
-
.route({
|
|
95
|
-
summary: "Parse a bank statement",
|
|
96
|
-
description: `Extract text and structured data from a bank statement. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
97
|
-
tags: ["Bank Statement"],
|
|
98
|
-
spec: (op) => {
|
|
99
|
-
const spec = getDefaultSpec(op, requestExamples);
|
|
100
|
-
spec["x-codeSamples"] = getOpenApiCodeSamples("bank-statement-parse");
|
|
101
|
-
return spec;
|
|
102
|
-
},
|
|
103
|
-
})
|
|
104
|
-
.input(parseInputSchema)
|
|
105
|
-
.output(parseOutputSchema);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const ask: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
-
url: z.ZodOptional<z.ZodURL>;
|
|
4
|
-
file: z.ZodOptional<z.ZodFile>;
|
|
5
|
-
base64: z.ZodOptional<z.ZodString>;
|
|
6
|
-
question: z.ZodString;
|
|
7
|
-
model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
8
|
-
auto: "auto";
|
|
9
|
-
max: "max";
|
|
10
|
-
mini: "mini";
|
|
11
|
-
nano: "nano";
|
|
12
|
-
pro: "pro";
|
|
13
|
-
}>>>;
|
|
14
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
15
|
-
callback: z.ZodOptional<z.ZodObject<{
|
|
16
|
-
url: z.ZodURL;
|
|
17
|
-
type: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.core.$strip>>;
|
|
19
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
-
markdown: z.ZodString;
|
|
21
|
-
pageCount: z.ZodNumber;
|
|
22
|
-
model: z.ZodEnum<{
|
|
23
|
-
max: "max";
|
|
24
|
-
mini: "mini";
|
|
25
|
-
nano: "nano";
|
|
26
|
-
pro: "pro";
|
|
27
|
-
}>;
|
|
28
|
-
credits: z.ZodNumber;
|
|
29
|
-
requestId: z.ZodNumber;
|
|
30
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
31
|
-
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
32
|
-
//# sourceMappingURL=ask.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../../../lib/router/document/ask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiJxB,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAYS,CAAC"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
|
-
import { getOpenApiCodeSamples } from "@pdfvector/api-docs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
|
|
5
|
-
import { pdfvectorModelSchema } from "../../pdfvector-model-schema.js";
|
|
6
|
-
import { documentAskModelDescription, outputAskModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
|
|
7
|
-
import { getDefaultSpec } from "./get-default-spec.js";
|
|
8
|
-
const askInputSchema = z.object({
|
|
9
|
-
url: fetchableUrlSchema
|
|
10
|
-
.optional()
|
|
11
|
-
.describe("URL of the document file to fetch and parse"),
|
|
12
|
-
file: z
|
|
13
|
-
.file()
|
|
14
|
-
.mime([...supportedFileMimes], supportedFileMimeErrorMessage)
|
|
15
|
-
.optional()
|
|
16
|
-
.describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
17
|
-
base64: z
|
|
18
|
-
.string()
|
|
19
|
-
.optional()
|
|
20
|
-
.describe("Base64-encoded document file content"),
|
|
21
|
-
question: z
|
|
22
|
-
.string()
|
|
23
|
-
.min(4, "question must be at least 4 characters")
|
|
24
|
-
.describe("The question to answer about the document"),
|
|
25
|
-
model: z
|
|
26
|
-
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
27
|
-
.optional()
|
|
28
|
-
.default("auto")
|
|
29
|
-
.describe(documentAskModelDescription),
|
|
30
|
-
documentId: z
|
|
31
|
-
.string()
|
|
32
|
-
.trim()
|
|
33
|
-
.min(1)
|
|
34
|
-
.max(512)
|
|
35
|
-
.optional()
|
|
36
|
-
.describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
37
|
-
callback: z
|
|
38
|
-
.object({
|
|
39
|
-
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
40
|
-
type: z
|
|
41
|
-
.string()
|
|
42
|
-
.optional()
|
|
43
|
-
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
44
|
-
})
|
|
45
|
-
.optional()
|
|
46
|
-
.describe("Optional webhook callback for async processing. " +
|
|
47
|
-
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
48
|
-
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
49
|
-
"Useful for long-running operations that may exceed client timeout limits."),
|
|
50
|
-
});
|
|
51
|
-
const askOutputSchema = z
|
|
52
|
-
.object({
|
|
53
|
-
markdown: z.string().describe("The answer to the question"),
|
|
54
|
-
pageCount: z
|
|
55
|
-
.number()
|
|
56
|
-
.int()
|
|
57
|
-
.describe("Total number of pages in the document"),
|
|
58
|
-
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
59
|
-
credits: z
|
|
60
|
-
.number()
|
|
61
|
-
.int()
|
|
62
|
-
.describe("Number of credits consumed by this API call. Cost per page: nano=2, mini=4, pro=8, max=16."),
|
|
63
|
-
requestId: z
|
|
64
|
-
.number()
|
|
65
|
-
.int()
|
|
66
|
-
.describe("Unique request identifier for this API call"),
|
|
67
|
-
documentId: z
|
|
68
|
-
.string()
|
|
69
|
-
.optional()
|
|
70
|
-
.describe("Document ID if provided via x-pdfvector-document-id header or request body"),
|
|
71
|
-
})
|
|
72
|
-
.meta({
|
|
73
|
-
examples: [
|
|
74
|
-
{
|
|
75
|
-
markdown: "The study found that viral shedding peaked during the first week of symptoms, with the highest viral loads detected in throat swabs.",
|
|
76
|
-
pageCount: 12,
|
|
77
|
-
model: "mini",
|
|
78
|
-
credits: 48,
|
|
79
|
-
requestId: 1,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
const requestExamples = {
|
|
84
|
-
"Ask from URL": {
|
|
85
|
-
summary: "Ask from URL",
|
|
86
|
-
value: {
|
|
87
|
-
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
88
|
-
question: "What are the main findings of this study?",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
"Ask from base64": {
|
|
92
|
-
summary: "Ask from base64",
|
|
93
|
-
value: {
|
|
94
|
-
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
95
|
-
question: "What is the content of this document?",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
"Ask from file upload": {
|
|
99
|
-
summary: "Ask from file upload",
|
|
100
|
-
value: {
|
|
101
|
-
file: "(binary)",
|
|
102
|
-
question: "Summarize this document",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
"Ask with lightweight models (nano)": {
|
|
106
|
-
summary: "Ask with lightweight models (nano)",
|
|
107
|
-
value: {
|
|
108
|
-
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
109
|
-
question: "What is the title of this paper?",
|
|
110
|
-
model: "nano",
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
"Ask with powerful models (max)": {
|
|
114
|
-
summary: "Ask with powerful models (max)",
|
|
115
|
-
value: {
|
|
116
|
-
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
117
|
-
question: "Provide a detailed analysis of the methodology used in this study.",
|
|
118
|
-
model: "max",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
export const ask = oc
|
|
123
|
-
.route({
|
|
124
|
-
summary: "Ask a question about a document",
|
|
125
|
-
description: `Parse a document and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
126
|
-
tags: ["Document"],
|
|
127
|
-
spec: (op) => {
|
|
128
|
-
const spec = getDefaultSpec(op, requestExamples);
|
|
129
|
-
spec["x-codeSamples"] = getOpenApiCodeSamples("document-ask");
|
|
130
|
-
return spec;
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
.input(askInputSchema)
|
|
134
|
-
.output(askOutputSchema);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const extract: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
-
url: z.ZodOptional<z.ZodURL>;
|
|
4
|
-
file: z.ZodOptional<z.ZodFile>;
|
|
5
|
-
base64: z.ZodOptional<z.ZodString>;
|
|
6
|
-
prompt: z.ZodString;
|
|
7
|
-
schema: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodPipe<z.ZodString, z.ZodTransform<Record<string, unknown>, string>>]>;
|
|
8
|
-
model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
auto: "auto";
|
|
10
|
-
max: "max";
|
|
11
|
-
mini: "mini";
|
|
12
|
-
nano: "nano";
|
|
13
|
-
pro: "pro";
|
|
14
|
-
}>>>;
|
|
15
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
16
|
-
callback: z.ZodOptional<z.ZodObject<{
|
|
17
|
-
url: z.ZodURL;
|
|
18
|
-
type: z.ZodOptional<z.ZodString>;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
-
data: z.ZodUnknown;
|
|
22
|
-
pageCount: z.ZodNumber;
|
|
23
|
-
model: z.ZodEnum<{
|
|
24
|
-
max: "max";
|
|
25
|
-
mini: "mini";
|
|
26
|
-
nano: "nano";
|
|
27
|
-
pro: "pro";
|
|
28
|
-
}>;
|
|
29
|
-
credits: z.ZodNumber;
|
|
30
|
-
requestId: z.ZodNumber;
|
|
31
|
-
documentId: z.ZodOptional<z.ZodString>;
|
|
32
|
-
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
33
|
-
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/router/document/extract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2KxB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAYS,CAAC"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
|
-
import { getOpenApiCodeSamples } from "@pdfvector/api-docs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
|
|
5
|
-
import { jsonSchemaInput } from "../../json-schema-input.js";
|
|
6
|
-
import { pdfvectorModelSchema } from "../../pdfvector-model-schema.js";
|
|
7
|
-
import { documentExtractModelDescription, outputExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
|
|
8
|
-
import { getDefaultSpec } from "./get-default-spec.js";
|
|
9
|
-
const extractInputSchema = z.object({
|
|
10
|
-
url: fetchableUrlSchema
|
|
11
|
-
.optional()
|
|
12
|
-
.describe("URL of the document file to fetch and parse"),
|
|
13
|
-
file: z
|
|
14
|
-
.file()
|
|
15
|
-
.mime([...supportedFileMimes], supportedFileMimeErrorMessage)
|
|
16
|
-
.optional()
|
|
17
|
-
.describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
18
|
-
base64: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("Base64-encoded document file content"),
|
|
22
|
-
prompt: z
|
|
23
|
-
.string()
|
|
24
|
-
.min(4, "prompt must be at least 4 characters")
|
|
25
|
-
.describe("The prompt instructing the AI how to extract data from the document"),
|
|
26
|
-
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the document. Can be a JSON object or a JSON string."),
|
|
27
|
-
model: z
|
|
28
|
-
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
29
|
-
.optional()
|
|
30
|
-
.default("auto")
|
|
31
|
-
.describe(documentExtractModelDescription),
|
|
32
|
-
documentId: z
|
|
33
|
-
.string()
|
|
34
|
-
.trim()
|
|
35
|
-
.min(1)
|
|
36
|
-
.max(512)
|
|
37
|
-
.optional()
|
|
38
|
-
.describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
39
|
-
callback: z
|
|
40
|
-
.object({
|
|
41
|
-
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
42
|
-
type: z
|
|
43
|
-
.string()
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
46
|
-
})
|
|
47
|
-
.optional()
|
|
48
|
-
.describe("Optional webhook callback for async processing. " +
|
|
49
|
-
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
50
|
-
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
51
|
-
"Useful for long-running operations that may exceed client timeout limits."),
|
|
52
|
-
});
|
|
53
|
-
const extractOutputSchema = z
|
|
54
|
-
.object({
|
|
55
|
-
data: z
|
|
56
|
-
.unknown()
|
|
57
|
-
.refine((val) => val != null &&
|
|
58
|
-
(typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" })
|
|
59
|
-
.describe("Extracted structured data matching the provided JSON Schema"),
|
|
60
|
-
pageCount: z
|
|
61
|
-
.number()
|
|
62
|
-
.int()
|
|
63
|
-
.describe("Total number of pages in the document"),
|
|
64
|
-
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
65
|
-
credits: z
|
|
66
|
-
.number()
|
|
67
|
-
.int()
|
|
68
|
-
.describe("Number of credits consumed by this API call. Cost per page: nano=2, mini=4, pro=8, max=16."),
|
|
69
|
-
requestId: z
|
|
70
|
-
.number()
|
|
71
|
-
.int()
|
|
72
|
-
.describe("Unique request identifier for this API call"),
|
|
73
|
-
documentId: z
|
|
74
|
-
.string()
|
|
75
|
-
.optional()
|
|
76
|
-
.describe("Document ID if provided via x-pdfvector-document-id header or request body"),
|
|
77
|
-
})
|
|
78
|
-
.meta({
|
|
79
|
-
examples: [
|
|
80
|
-
{
|
|
81
|
-
data: {
|
|
82
|
-
title: "Virological assessment of hospitalized patients with COVID-2019",
|
|
83
|
-
authors: ["Roman Wölfel", "Victor M. Corman"],
|
|
84
|
-
year: 2020,
|
|
85
|
-
},
|
|
86
|
-
pageCount: 12,
|
|
87
|
-
model: "mini",
|
|
88
|
-
credits: 48,
|
|
89
|
-
requestId: 1,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
});
|
|
93
|
-
const requestExamples = {
|
|
94
|
-
"Extract from URL": {
|
|
95
|
-
summary: "Extract from URL",
|
|
96
|
-
value: {
|
|
97
|
-
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
98
|
-
prompt: "Extract the title, authors, and publication year from this research paper",
|
|
99
|
-
schema: JSON.stringify({
|
|
100
|
-
type: "object",
|
|
101
|
-
properties: {
|
|
102
|
-
title: { type: "string" },
|
|
103
|
-
authors: { type: "array", items: { type: "string" } },
|
|
104
|
-
year: { type: "number" },
|
|
105
|
-
},
|
|
106
|
-
required: ["title", "authors", "year"],
|
|
107
|
-
}),
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
"Extract from base64": {
|
|
111
|
-
summary: "Extract from base64",
|
|
112
|
-
value: {
|
|
113
|
-
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
114
|
-
prompt: "Extract the main content from this document",
|
|
115
|
-
schema: JSON.stringify({
|
|
116
|
-
type: "object",
|
|
117
|
-
properties: {
|
|
118
|
-
content: { type: "string" },
|
|
119
|
-
},
|
|
120
|
-
required: ["content"],
|
|
121
|
-
}),
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
"Extract from file upload": {
|
|
125
|
-
summary: "Extract from file upload",
|
|
126
|
-
value: {
|
|
127
|
-
file: "(binary)",
|
|
128
|
-
prompt: "Extract the title and summary from this document",
|
|
129
|
-
schema: JSON.stringify({
|
|
130
|
-
type: "object",
|
|
131
|
-
properties: {
|
|
132
|
-
title: { type: "string" },
|
|
133
|
-
summary: { type: "string" },
|
|
134
|
-
},
|
|
135
|
-
required: ["title", "summary"],
|
|
136
|
-
}),
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
export const extract = oc
|
|
141
|
-
.route({
|
|
142
|
-
summary: "Extract structured data from a document",
|
|
143
|
-
description: `Parse a document and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
144
|
-
tags: ["Document"],
|
|
145
|
-
spec: (op) => {
|
|
146
|
-
const spec = getDefaultSpec(op, requestExamples);
|
|
147
|
-
spec["x-codeSamples"] = getOpenApiCodeSamples("document-extract");
|
|
148
|
-
return spec;
|
|
149
|
-
},
|
|
150
|
-
})
|
|
151
|
-
.input(extractInputSchema)
|
|
152
|
-
.output(extractOutputSchema);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-spec.d.ts","sourceRoot":"","sources":["../../../../lib/router/document/get-default-spec.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAC7B,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB"}
|