@pdfvector/instance-contract 0.0.27 → 0.0.29
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/router/academic/index.d.ts +2 -0
- package/.tsc/lib/router/academic/index.js +2 -0
- package/.tsc/lib/router/academic/paper-graph.d.ts +85 -0
- package/.tsc/lib/router/academic/paper-graph.js +140 -0
- package/.tsc/lib/router/academic/similar-papers.d.ts +70 -0
- package/.tsc/lib/router/academic/similar-papers.js +139 -0
- package/.tsc/lib/router/bankStatement/ask.js +6 -22
- package/.tsc/lib/router/bankStatement/extract.js +6 -22
- package/.tsc/lib/router/bankStatement/parse.js +5 -15
- package/.tsc/lib/router/document/ask.js +6 -22
- package/.tsc/lib/router/document/extract.js +6 -22
- package/.tsc/lib/router/document/parse.js +6 -22
- package/.tsc/lib/router/free/bank-statement-parse.js +4 -11
- package/.tsc/lib/router/identity/ask.js +6 -22
- package/.tsc/lib/router/identity/extract.js +6 -22
- package/.tsc/lib/router/identity/parse.js +5 -15
- package/.tsc/lib/router/invoice/ask.js +6 -22
- package/.tsc/lib/router/invoice/extract.js +6 -22
- package/.tsc/lib/router/invoice/parse.js +5 -15
- package/.tsc/lib/supported-mimes.d.ts +29 -0
- package/.tsc/lib/supported-mimes.js +122 -0
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const paperGraph: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
citationsLimit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
referencesLimit: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
citationsOffset: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
referencesOffset: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
9
|
+
url: "url";
|
|
10
|
+
doi: "doi";
|
|
11
|
+
title: "title";
|
|
12
|
+
providerURL: "providerURL";
|
|
13
|
+
date: "date";
|
|
14
|
+
authors: "authors";
|
|
15
|
+
year: "year";
|
|
16
|
+
totalCitations: "totalCitations";
|
|
17
|
+
totalReferences: "totalReferences";
|
|
18
|
+
abstract: "abstract";
|
|
19
|
+
pdfURL: "pdfURL";
|
|
20
|
+
provider: "provider";
|
|
21
|
+
providerData: "providerData";
|
|
22
|
+
}>>>>;
|
|
23
|
+
callback: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
url: z.ZodURL;
|
|
25
|
+
type: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
paper: z.ZodObject<{
|
|
29
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>>>>;
|
|
37
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
39
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
40
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
41
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
citations: z.ZodArray<z.ZodObject<{
|
|
47
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
}, z.core.$strip>>>>;
|
|
55
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
57
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
58
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
59
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
references: z.ZodArray<z.ZodObject<{
|
|
65
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
+
}, z.core.$strip>>>>;
|
|
73
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
74
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
75
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
76
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
77
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
83
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
84
|
+
requestId: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const authorSchema = z.object({
|
|
4
|
+
name: z.string(),
|
|
5
|
+
url: z.string().nullish(),
|
|
6
|
+
});
|
|
7
|
+
const publicationSchema = z.object({
|
|
8
|
+
doi: z.string().nullish(),
|
|
9
|
+
title: z.string().nullish(),
|
|
10
|
+
url: z.string().nullish(),
|
|
11
|
+
providerURL: z.string().nullish(),
|
|
12
|
+
authors: z.array(authorSchema).nullish(),
|
|
13
|
+
date: z.string().nullish(),
|
|
14
|
+
year: z.number().nullish(),
|
|
15
|
+
totalCitations: z.number().nullish(),
|
|
16
|
+
totalReferences: z.number().nullish(),
|
|
17
|
+
abstract: z.string().nullish(),
|
|
18
|
+
pdfURL: z.string().nullish(),
|
|
19
|
+
provider: z.string().nullish(),
|
|
20
|
+
providerData: z.record(z.string(), z.unknown()).nullish(),
|
|
21
|
+
});
|
|
22
|
+
const requestExamples = {
|
|
23
|
+
"Get citations by DOI": {
|
|
24
|
+
summary: "Get citations and references for a paper by DOI",
|
|
25
|
+
value: {
|
|
26
|
+
id: "10.1038/nature12373",
|
|
27
|
+
citationsLimit: 20,
|
|
28
|
+
referencesLimit: 20,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
"Get citations by ArXiv ID": {
|
|
32
|
+
summary: "Get citations and references for an ArXiv paper",
|
|
33
|
+
value: {
|
|
34
|
+
id: "2303.08774",
|
|
35
|
+
citationsLimit: 50,
|
|
36
|
+
referencesLimit: 50,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
"Paginated citations": {
|
|
40
|
+
summary: "Page through a paper's citations",
|
|
41
|
+
value: {
|
|
42
|
+
id: "10.1038/nature12373",
|
|
43
|
+
citationsLimit: 20,
|
|
44
|
+
citationsOffset: 20,
|
|
45
|
+
referencesLimit: 0,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export const paperGraph = oc
|
|
50
|
+
.input(z.object({
|
|
51
|
+
id: z
|
|
52
|
+
.string({ message: "id is required and must be a string" })
|
|
53
|
+
.min(1, "id must not be empty")
|
|
54
|
+
.max(500, "id must be at most 500 characters")
|
|
55
|
+
.describe("Paper identifier. Supports DOI, Semantic Scholar ID, ArXiv ID, PubMed ID, OpenAlex ID, or URL."),
|
|
56
|
+
citationsLimit: z
|
|
57
|
+
.number({ message: "citationsLimit must be a number" })
|
|
58
|
+
.int("citationsLimit must be a whole number")
|
|
59
|
+
.min(0, "citationsLimit must be 0 or greater")
|
|
60
|
+
.max(1000, "citationsLimit must be at most 1000")
|
|
61
|
+
.default(100)
|
|
62
|
+
.describe("Maximum number of citing papers to return"),
|
|
63
|
+
referencesLimit: z
|
|
64
|
+
.number({ message: "referencesLimit must be a number" })
|
|
65
|
+
.int("referencesLimit must be a whole number")
|
|
66
|
+
.min(0, "referencesLimit must be 0 or greater")
|
|
67
|
+
.max(1000, "referencesLimit must be at most 1000")
|
|
68
|
+
.default(100)
|
|
69
|
+
.describe("Maximum number of referenced papers to return"),
|
|
70
|
+
citationsOffset: z
|
|
71
|
+
.number({ message: "citationsOffset must be a number" })
|
|
72
|
+
.int("citationsOffset must be a whole number")
|
|
73
|
+
.min(0, "citationsOffset must be 0 or greater")
|
|
74
|
+
.default(0)
|
|
75
|
+
.describe("Pagination offset for citations"),
|
|
76
|
+
referencesOffset: z
|
|
77
|
+
.number({ message: "referencesOffset must be a number" })
|
|
78
|
+
.int("referencesOffset must be a whole number")
|
|
79
|
+
.min(0, "referencesOffset must be 0 or greater")
|
|
80
|
+
.default(0)
|
|
81
|
+
.describe("Pagination offset for references"),
|
|
82
|
+
fields: z
|
|
83
|
+
.array(z.enum([
|
|
84
|
+
"doi",
|
|
85
|
+
"title",
|
|
86
|
+
"url",
|
|
87
|
+
"providerURL",
|
|
88
|
+
"authors",
|
|
89
|
+
"date",
|
|
90
|
+
"year",
|
|
91
|
+
"totalCitations",
|
|
92
|
+
"totalReferences",
|
|
93
|
+
"abstract",
|
|
94
|
+
"pdfURL",
|
|
95
|
+
"provider",
|
|
96
|
+
"providerData",
|
|
97
|
+
]), {
|
|
98
|
+
message: "fields must be an array of valid publication field names",
|
|
99
|
+
})
|
|
100
|
+
.nullish()
|
|
101
|
+
.describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
102
|
+
callback: z
|
|
103
|
+
.object({
|
|
104
|
+
url: z
|
|
105
|
+
.url()
|
|
106
|
+
.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
107
|
+
type: z
|
|
108
|
+
.string()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
111
|
+
})
|
|
112
|
+
.optional()
|
|
113
|
+
.describe("Optional webhook callback for async processing. " +
|
|
114
|
+
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
115
|
+
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
116
|
+
"Useful for long-running operations that may exceed client timeout limits."),
|
|
117
|
+
}))
|
|
118
|
+
.output(z.object({
|
|
119
|
+
paper: publicationSchema,
|
|
120
|
+
citations: z.array(publicationSchema),
|
|
121
|
+
references: z.array(publicationSchema),
|
|
122
|
+
totalCitations: z.number().int().nullish(),
|
|
123
|
+
totalReferences: z.number().int().nullish(),
|
|
124
|
+
requestId: z.number().int(),
|
|
125
|
+
}))
|
|
126
|
+
.route({
|
|
127
|
+
summary: "Get paper citations and references",
|
|
128
|
+
description: "Fetch a paper's citing papers and referenced papers as full publication objects with automatic provider detection and pagination support.",
|
|
129
|
+
tags: ["Academic"],
|
|
130
|
+
spec: (op) => {
|
|
131
|
+
op.security = [{ bearerAuth: [] }];
|
|
132
|
+
const reqBody = op.requestBody;
|
|
133
|
+
if (reqBody?.content) {
|
|
134
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
135
|
+
mediaType.examples = requestExamples;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return op;
|
|
139
|
+
},
|
|
140
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const similarPapers: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
includeEdges: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
7
|
+
url: "url";
|
|
8
|
+
doi: "doi";
|
|
9
|
+
title: "title";
|
|
10
|
+
providerURL: "providerURL";
|
|
11
|
+
date: "date";
|
|
12
|
+
authors: "authors";
|
|
13
|
+
year: "year";
|
|
14
|
+
totalCitations: "totalCitations";
|
|
15
|
+
totalReferences: "totalReferences";
|
|
16
|
+
abstract: "abstract";
|
|
17
|
+
pdfURL: "pdfURL";
|
|
18
|
+
provider: "provider";
|
|
19
|
+
providerData: "providerData";
|
|
20
|
+
}>>>>;
|
|
21
|
+
callback: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
url: z.ZodURL;
|
|
23
|
+
type: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
26
|
+
seed: z.ZodObject<{
|
|
27
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
}, z.core.$strip>>>>;
|
|
35
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
37
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
38
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
39
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
results: z.ZodArray<z.ZodObject<{
|
|
45
|
+
publication: z.ZodObject<{
|
|
46
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
}, z.core.$strip>>>>;
|
|
54
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
56
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
57
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
58
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
similarity: z.ZodNumber;
|
|
64
|
+
pageRank: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
65
|
+
distance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
66
|
+
citingIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
67
|
+
citedByIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
requestId: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const authorSchema = z.object({
|
|
4
|
+
name: z.string(),
|
|
5
|
+
url: z.string().nullish(),
|
|
6
|
+
});
|
|
7
|
+
const publicationSchema = z.object({
|
|
8
|
+
doi: z.string().nullish(),
|
|
9
|
+
title: z.string().nullish(),
|
|
10
|
+
url: z.string().nullish(),
|
|
11
|
+
providerURL: z.string().nullish(),
|
|
12
|
+
authors: z.array(authorSchema).nullish(),
|
|
13
|
+
date: z.string().nullish(),
|
|
14
|
+
year: z.number().nullish(),
|
|
15
|
+
totalCitations: z.number().nullish(),
|
|
16
|
+
totalReferences: z.number().nullish(),
|
|
17
|
+
abstract: z.string().nullish(),
|
|
18
|
+
pdfURL: z.string().nullish(),
|
|
19
|
+
provider: z.string().nullish(),
|
|
20
|
+
providerData: z.record(z.string(), z.unknown()).nullish(),
|
|
21
|
+
});
|
|
22
|
+
const similarPaperSchema = z.object({
|
|
23
|
+
publication: publicationSchema,
|
|
24
|
+
similarity: z
|
|
25
|
+
.number()
|
|
26
|
+
.describe("Combined similarity score from citation network analysis"),
|
|
27
|
+
pageRank: z.number().nullish().describe("Citation network importance score"),
|
|
28
|
+
distance: z
|
|
29
|
+
.number()
|
|
30
|
+
.int()
|
|
31
|
+
.nullish()
|
|
32
|
+
.describe("Graph distance from seed paper"),
|
|
33
|
+
citingIds: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.nullish()
|
|
36
|
+
.describe("OpenAlex IDs of papers in result set that cite this paper (only if includeEdges=true)"),
|
|
37
|
+
citedByIds: z
|
|
38
|
+
.array(z.string())
|
|
39
|
+
.nullish()
|
|
40
|
+
.describe("OpenAlex IDs of papers in result set cited by this paper (only if includeEdges=true)"),
|
|
41
|
+
});
|
|
42
|
+
const requestExamples = {
|
|
43
|
+
"Find similar papers by DOI": {
|
|
44
|
+
summary: "Find papers similar to a given paper",
|
|
45
|
+
value: {
|
|
46
|
+
id: "10.1038/nature12373",
|
|
47
|
+
limit: 20,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
"Find similar with edges": {
|
|
51
|
+
summary: "Find similar papers with citation graph edges",
|
|
52
|
+
value: {
|
|
53
|
+
id: "10.1038/nature12373",
|
|
54
|
+
limit: 20,
|
|
55
|
+
includeEdges: true,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
"Find similar by OpenAlex ID": {
|
|
59
|
+
summary: "Find similar papers using an OpenAlex ID",
|
|
60
|
+
value: {
|
|
61
|
+
id: "W2963403868",
|
|
62
|
+
limit: 10,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const similarPapers = oc
|
|
67
|
+
.input(z.object({
|
|
68
|
+
id: z
|
|
69
|
+
.string({ message: "id is required and must be a string" })
|
|
70
|
+
.min(1, "id must not be empty")
|
|
71
|
+
.max(500, "id must be at most 500 characters")
|
|
72
|
+
.describe("Seed paper identifier. Supports DOI, Semantic Scholar ID, ArXiv ID, PubMed ID, OpenAlex ID, or URL."),
|
|
73
|
+
limit: z
|
|
74
|
+
.number({ message: "limit must be a number" })
|
|
75
|
+
.int("limit must be a whole number")
|
|
76
|
+
.min(1, "limit must be at least 1")
|
|
77
|
+
.max(100, "limit must be at most 100")
|
|
78
|
+
.default(30)
|
|
79
|
+
.describe("Maximum number of similar papers to return"),
|
|
80
|
+
includeEdges: z
|
|
81
|
+
.boolean({ message: "includeEdges must be a boolean" })
|
|
82
|
+
.default(false)
|
|
83
|
+
.describe("Whether to include citing/cited_by edge data for graph construction"),
|
|
84
|
+
fields: z
|
|
85
|
+
.array(z.enum([
|
|
86
|
+
"doi",
|
|
87
|
+
"title",
|
|
88
|
+
"url",
|
|
89
|
+
"providerURL",
|
|
90
|
+
"authors",
|
|
91
|
+
"date",
|
|
92
|
+
"year",
|
|
93
|
+
"totalCitations",
|
|
94
|
+
"totalReferences",
|
|
95
|
+
"abstract",
|
|
96
|
+
"pdfURL",
|
|
97
|
+
"provider",
|
|
98
|
+
"providerData",
|
|
99
|
+
]), {
|
|
100
|
+
message: "fields must be an array of valid publication field names",
|
|
101
|
+
})
|
|
102
|
+
.nullish()
|
|
103
|
+
.describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
104
|
+
callback: z
|
|
105
|
+
.object({
|
|
106
|
+
url: z
|
|
107
|
+
.url()
|
|
108
|
+
.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
109
|
+
type: z
|
|
110
|
+
.string()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe("Callback type identifier (e.g. 'zapier')"),
|
|
113
|
+
})
|
|
114
|
+
.optional()
|
|
115
|
+
.describe("Optional webhook callback for async processing. " +
|
|
116
|
+
"When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
|
|
117
|
+
"On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
|
|
118
|
+
"Useful for long-running operations that may exceed client timeout limits."),
|
|
119
|
+
}))
|
|
120
|
+
.output(z.object({
|
|
121
|
+
seed: publicationSchema,
|
|
122
|
+
results: z.array(similarPaperSchema),
|
|
123
|
+
requestId: z.number().int(),
|
|
124
|
+
}))
|
|
125
|
+
.route({
|
|
126
|
+
summary: "Find similar papers",
|
|
127
|
+
description: "Find papers similar to a seed paper using citation network analysis. Returns papers ranked by similarity with optional graph edge data for visualization.",
|
|
128
|
+
tags: ["Academic"],
|
|
129
|
+
spec: (op) => {
|
|
130
|
+
op.security = [{ bearerAuth: [] }];
|
|
131
|
+
const reqBody = op.requestBody;
|
|
132
|
+
if (reqBody?.content) {
|
|
133
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
134
|
+
mediaType.examples = requestExamples;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return op;
|
|
138
|
+
},
|
|
139
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
|
|
4
|
+
import { outputAskModelDescription, specializedAskModelDescription, supportedFileFormatsDescription, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
|
|
4
5
|
import { getDefaultSpec } from "./get-default-spec";
|
|
5
6
|
const specializedModelSchema = z
|
|
6
7
|
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
@@ -12,17 +13,9 @@ const askInputSchema = z.object({
|
|
|
12
13
|
.describe("URL of the bank statement file to fetch and parse"),
|
|
13
14
|
file: z
|
|
14
15
|
.file()
|
|
15
|
-
.mime([
|
|
16
|
-
"application/pdf",
|
|
17
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
19
|
-
"text/csv",
|
|
20
|
-
"application/csv",
|
|
21
|
-
"image/png",
|
|
22
|
-
"image/jpeg",
|
|
23
|
-
])
|
|
16
|
+
.mime([...supportedFileMimes])
|
|
24
17
|
.optional()
|
|
25
|
-
.describe(
|
|
18
|
+
.describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
26
19
|
base64: z
|
|
27
20
|
.string()
|
|
28
21
|
.optional()
|
|
@@ -31,12 +24,7 @@ const askInputSchema = z.object({
|
|
|
31
24
|
.string()
|
|
32
25
|
.min(4, "question must be at least 4 characters")
|
|
33
26
|
.describe("The question to answer about the bank statement"),
|
|
34
|
-
model: specializedModelSchema.describe(
|
|
35
|
-
"'auto' (default): Automatically selects the best tier based on document complexity. " +
|
|
36
|
-
"'nano': 6 credits/page. Fastest and cheapest. Best for simple questions about straightforward documents. Supports PDF, Word, Excel, CSV. " +
|
|
37
|
-
"'mini': 10 credits/page. Balanced speed and accuracy. Handles moderately complex questions. Supports PDF, Word, Excel, CSV. " +
|
|
38
|
-
"'pro': 14 credits/page. High accuracy for nuanced questions about complex documents. Supports PDF, Word, Excel, CSV, Image. " +
|
|
39
|
-
"'max': 18 credits/page. Maximum accuracy with the most capable models. Best for difficult questions requiring deep reasoning. Supports PDF, Word, Excel, CSV, Image."),
|
|
27
|
+
model: specializedModelSchema.describe(specializedAskModelDescription),
|
|
40
28
|
callback: z
|
|
41
29
|
.object({
|
|
42
30
|
url: z
|
|
@@ -56,11 +44,7 @@ const askInputSchema = z.object({
|
|
|
56
44
|
const askOutputSchema = z.object({
|
|
57
45
|
markdown: z.string().describe("The answer to the question"),
|
|
58
46
|
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
59
|
-
model: pdfvectorModelSchema.describe(
|
|
60
|
-
"'nano': Fastest, best for simple questions. Supports PDF, Word, Excel, CSV. " +
|
|
61
|
-
"'mini': Balanced speed and accuracy. Supports PDF, Word, Excel, CSV. " +
|
|
62
|
-
"'pro': High accuracy for complex questions. Supports PDF, Word, Excel, CSV, Image. " +
|
|
63
|
-
"'max': Maximum accuracy with deep reasoning. Supports PDF, Word, Excel, CSV, Image."),
|
|
47
|
+
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
64
48
|
credits: z
|
|
65
49
|
.number()
|
|
66
50
|
.int()
|
|
@@ -86,7 +70,7 @@ const requestExamples = {
|
|
|
86
70
|
export const ask = oc
|
|
87
71
|
.route({
|
|
88
72
|
summary: "Ask a question about a bank statement",
|
|
89
|
-
description:
|
|
73
|
+
description: `Parse a bank statement and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
90
74
|
tags: ["Bank Statement"],
|
|
91
75
|
spec: (op) => getDefaultSpec(op, requestExamples),
|
|
92
76
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
|
|
4
|
+
import { outputExtractModelDescription, specializedExtractModelDescription, supportedFileFormatsDescription, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
|
|
4
5
|
import { getDefaultSpec } from "./get-default-spec";
|
|
5
6
|
const specializedModelSchema = z
|
|
6
7
|
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
@@ -12,17 +13,9 @@ const extractInputSchema = z.object({
|
|
|
12
13
|
.describe("URL of the bank statement file to fetch and parse"),
|
|
13
14
|
file: z
|
|
14
15
|
.file()
|
|
15
|
-
.mime([
|
|
16
|
-
"application/pdf",
|
|
17
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
19
|
-
"text/csv",
|
|
20
|
-
"application/csv",
|
|
21
|
-
"image/png",
|
|
22
|
-
"image/jpeg",
|
|
23
|
-
])
|
|
16
|
+
.mime([...supportedFileMimes])
|
|
24
17
|
.optional()
|
|
25
|
-
.describe(
|
|
18
|
+
.describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
26
19
|
base64: z
|
|
27
20
|
.string()
|
|
28
21
|
.optional()
|
|
@@ -57,12 +50,7 @@ const extractInputSchema = z.object({
|
|
|
57
50
|
}),
|
|
58
51
|
])
|
|
59
52
|
.describe("JSON Schema describing the structure of the data to extract from the bank statement. Can be a JSON object or a JSON string."),
|
|
60
|
-
model: specializedModelSchema.describe(
|
|
61
|
-
"'auto' (default): Automatically selects the best tier based on document complexity. " +
|
|
62
|
-
"'nano': 6 credits/page. Fastest and cheapest. Best for simple documents with straightforward schemas. Supports PDF, Word, Excel, CSV. " +
|
|
63
|
-
"'mini': 10 credits/page. Balanced speed and accuracy. Handles moderately complex documents and schemas. Supports PDF, Word, Excel, CSV. " +
|
|
64
|
-
"'pro': 14 credits/page. High accuracy for complex documents with large or nested schemas. Supports PDF, Word, Excel, CSV, Image. " +
|
|
65
|
-
"'max': 18 credits/page. Maximum accuracy with the most capable models. Best for difficult extractions requiring deep reasoning. Supports PDF, Word, Excel, CSV, Image."),
|
|
53
|
+
model: specializedModelSchema.describe(specializedExtractModelDescription),
|
|
66
54
|
callback: z
|
|
67
55
|
.object({
|
|
68
56
|
url: z
|
|
@@ -86,11 +74,7 @@ const extractOutputSchema = z.object({
|
|
|
86
74
|
(typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" })
|
|
87
75
|
.describe("Extracted structured data matching the provided JSON Schema"),
|
|
88
76
|
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
89
|
-
model: pdfvectorModelSchema.describe(
|
|
90
|
-
"'nano': Fastest, best for simple documents. Supports PDF, Word, Excel, CSV. " +
|
|
91
|
-
"'mini': Balanced speed and accuracy. Supports PDF, Word, Excel, CSV. " +
|
|
92
|
-
"'pro': High accuracy for complex documents. Supports PDF, Word, Excel, CSV, Image. " +
|
|
93
|
-
"'max': Maximum accuracy with deep reasoning. Supports PDF, Word, Excel, CSV, Image."),
|
|
77
|
+
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
94
78
|
credits: z
|
|
95
79
|
.number()
|
|
96
80
|
.int()
|
|
@@ -135,7 +119,7 @@ const requestExamples = {
|
|
|
135
119
|
export const extract = oc
|
|
136
120
|
.route({
|
|
137
121
|
summary: "Extract structured data from a bank statement",
|
|
138
|
-
description:
|
|
122
|
+
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.`,
|
|
139
123
|
tags: ["Bank Statement"],
|
|
140
124
|
spec: (op) => getDefaultSpec(op, requestExamples),
|
|
141
125
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { specializedParseModelDescription, supportedFileFormatsDescription, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
|
|
3
4
|
import { getDefaultSpec } from "./get-default-spec";
|
|
4
5
|
const specializedParseModelSchema = z
|
|
5
6
|
.enum(["pro", "max", "auto"], {
|
|
@@ -13,25 +14,14 @@ const parseInputSchema = z.object({
|
|
|
13
14
|
.describe("URL of the bank statement file to fetch and parse"),
|
|
14
15
|
file: z
|
|
15
16
|
.file()
|
|
16
|
-
.mime([
|
|
17
|
-
"application/pdf",
|
|
18
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
19
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
20
|
-
"text/csv",
|
|
21
|
-
"application/csv",
|
|
22
|
-
"image/png",
|
|
23
|
-
"image/jpeg",
|
|
24
|
-
])
|
|
17
|
+
.mime([...supportedFileMimes])
|
|
25
18
|
.optional()
|
|
26
|
-
.describe(
|
|
19
|
+
.describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
27
20
|
base64: z
|
|
28
21
|
.string()
|
|
29
22
|
.optional()
|
|
30
23
|
.describe("Base64-encoded bank statement file content"),
|
|
31
|
-
model: specializedParseModelSchema.describe("
|
|
32
|
-
"'auto' (default): Automatically selects the best parsing strategy with intelligent fallback. " +
|
|
33
|
-
"'pro': 6 credits/page. Extracts structured bank statement fields with standard accuracy. " +
|
|
34
|
-
"'max': 10 credits/page. Extracts structured bank statement fields with highest accuracy and fallback."),
|
|
24
|
+
model: specializedParseModelSchema.describe(specializedParseModelDescription("bank statement")),
|
|
35
25
|
callback: z
|
|
36
26
|
.object({
|
|
37
27
|
url: z
|
|
@@ -97,7 +87,7 @@ const requestExamples = {
|
|
|
97
87
|
export const parse = oc
|
|
98
88
|
.route({
|
|
99
89
|
summary: "Parse a bank statement",
|
|
100
|
-
description:
|
|
90
|
+
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.`,
|
|
101
91
|
tags: ["Bank Statement"],
|
|
102
92
|
spec: (op) => getDefaultSpec(op, requestExamples),
|
|
103
93
|
})
|