@pdfvector/instance-contract 0.0.19 → 0.0.20
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/pdfvector-model-schema.js +3 -1
- package/.tsc/lib/router/academic/fetch.d.ts +46 -0
- package/.tsc/lib/router/academic/fetch.js +101 -0
- package/.tsc/lib/router/academic/find-citations.d.ts +55 -0
- package/.tsc/lib/router/academic/find-citations.js +108 -0
- package/.tsc/lib/router/academic/index.d.ts +3 -0
- package/.tsc/lib/router/academic/index.js +3 -0
- package/.tsc/lib/router/academic/search.d.ts +67 -0
- package/.tsc/lib/router/academic/search.js +146 -0
- package/.tsc/lib/router/bankStatement/ask.js +1 -1
- package/.tsc/lib/router/bankStatement/extract.js +1 -1
- package/.tsc/lib/router/bankStatement/parse.js +3 -1
- package/.tsc/lib/router/document/ask.js +1 -1
- package/.tsc/lib/router/document/extract.js +1 -1
- package/.tsc/lib/router/identity/ask.js +1 -1
- package/.tsc/lib/router/identity/extract.js +1 -1
- package/.tsc/lib/router/identity/parse.js +3 -1
- package/.tsc/lib/router/index.d.ts +1 -0
- package/.tsc/lib/router/index.js +1 -0
- package/.tsc/lib/router/invoice/ask.js +1 -1
- package/.tsc/lib/router/invoice/extract.js +1 -1
- package/.tsc/lib/router/invoice/parse.js +3 -1
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const fetch: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
+
ids: z.ZodArray<z.ZodString>;
|
|
4
|
+
fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
5
|
+
url: "url";
|
|
6
|
+
doi: "doi";
|
|
7
|
+
title: "title";
|
|
8
|
+
providerURL: "providerURL";
|
|
9
|
+
date: "date";
|
|
10
|
+
authors: "authors";
|
|
11
|
+
year: "year";
|
|
12
|
+
totalCitations: "totalCitations";
|
|
13
|
+
totalReferences: "totalReferences";
|
|
14
|
+
abstract: "abstract";
|
|
15
|
+
pdfURL: "pdfURL";
|
|
16
|
+
provider: "provider";
|
|
17
|
+
providerData: "providerData";
|
|
18
|
+
}>>>>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
results: z.ZodArray<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
detectedProvider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>>>>;
|
|
31
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
33
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
35
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
error: z.ZodString;
|
|
43
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
}, z.core.$strip>>>>;
|
|
45
|
+
requestId: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
id: z.string().describe("Original input identifier"),
|
|
9
|
+
detectedProvider: z
|
|
10
|
+
.string()
|
|
11
|
+
.nullish()
|
|
12
|
+
.describe("Provider that returned this result"),
|
|
13
|
+
doi: z.string().nullish(),
|
|
14
|
+
title: z.string().nullish(),
|
|
15
|
+
url: z.string().nullish(),
|
|
16
|
+
providerURL: z.string().nullish(),
|
|
17
|
+
authors: z.array(authorSchema).nullish(),
|
|
18
|
+
date: z.string().nullish(),
|
|
19
|
+
year: z.number().nullish(),
|
|
20
|
+
totalCitations: z.number().nullish(),
|
|
21
|
+
totalReferences: z.number().nullish(),
|
|
22
|
+
abstract: z.string().nullish(),
|
|
23
|
+
pdfURL: z.string().nullish(),
|
|
24
|
+
provider: z.string().nullish(),
|
|
25
|
+
providerData: z.record(z.string(), z.unknown()).nullish(),
|
|
26
|
+
});
|
|
27
|
+
const fetchErrorSchema = z.object({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
error: z.string(),
|
|
30
|
+
code: z.string().nullish(),
|
|
31
|
+
});
|
|
32
|
+
const requestExamples = {
|
|
33
|
+
"Fetch by DOI": {
|
|
34
|
+
summary: "Fetch a paper by DOI",
|
|
35
|
+
value: {
|
|
36
|
+
ids: ["10.1038/nature12373"],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
"Fetch multiple IDs": {
|
|
40
|
+
summary: "Fetch papers by mixed identifier types",
|
|
41
|
+
value: {
|
|
42
|
+
ids: ["10.1038/nature12373", "2301.08745", "33293753"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
"Fetch ArXiv paper": {
|
|
46
|
+
summary: "Fetch by ArXiv ID",
|
|
47
|
+
value: {
|
|
48
|
+
ids: ["2303.08774"],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const fetch = oc
|
|
53
|
+
.input(z.object({
|
|
54
|
+
ids: z
|
|
55
|
+
.array(z.string({ message: "Each ID must be a string" }), {
|
|
56
|
+
message: "ids is required and must be an array of strings",
|
|
57
|
+
})
|
|
58
|
+
.min(1, "ids must contain at least 1 identifier")
|
|
59
|
+
.max(100, "ids must contain at most 100 identifiers")
|
|
60
|
+
.describe("Publication identifiers to fetch. Supports DOI, PubMed ID, ArXiv ID, Semantic Scholar ID, ERIC ID, Europe PMC ID, OpenAlex ID."),
|
|
61
|
+
fields: z
|
|
62
|
+
.array(z.enum([
|
|
63
|
+
"doi",
|
|
64
|
+
"title",
|
|
65
|
+
"url",
|
|
66
|
+
"providerURL",
|
|
67
|
+
"authors",
|
|
68
|
+
"date",
|
|
69
|
+
"year",
|
|
70
|
+
"totalCitations",
|
|
71
|
+
"totalReferences",
|
|
72
|
+
"abstract",
|
|
73
|
+
"pdfURL",
|
|
74
|
+
"provider",
|
|
75
|
+
"providerData",
|
|
76
|
+
]), {
|
|
77
|
+
message: "fields must be an array of valid publication field names",
|
|
78
|
+
})
|
|
79
|
+
.nullish()
|
|
80
|
+
.describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
81
|
+
}))
|
|
82
|
+
.output(z.object({
|
|
83
|
+
results: z.array(publicationSchema),
|
|
84
|
+
errors: z.array(fetchErrorSchema).nullish(),
|
|
85
|
+
requestId: z.number().int(),
|
|
86
|
+
}))
|
|
87
|
+
.route({
|
|
88
|
+
summary: "Fetch academic papers by ID",
|
|
89
|
+
description: "Fetch specific academic publications by their unique identifiers with automatic provider detection and batch processing.",
|
|
90
|
+
tags: ["Academic"],
|
|
91
|
+
spec: (op) => {
|
|
92
|
+
op.security = [{ bearerAuth: [] }];
|
|
93
|
+
const reqBody = op.requestBody;
|
|
94
|
+
if (reqBody?.content) {
|
|
95
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
96
|
+
mediaType.examples = requestExamples;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return op;
|
|
100
|
+
},
|
|
101
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const findCitations: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
+
paragraph: z.ZodString;
|
|
4
|
+
providers: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
5
|
+
"semantic-scholar": "semantic-scholar";
|
|
6
|
+
pubmed: "pubmed";
|
|
7
|
+
arxiv: "arxiv";
|
|
8
|
+
"google-scholar": "google-scholar";
|
|
9
|
+
eric: "eric";
|
|
10
|
+
"europe-pmc": "europe-pmc";
|
|
11
|
+
openalex: "openalex";
|
|
12
|
+
}>>>;
|
|
13
|
+
fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
14
|
+
url: "url";
|
|
15
|
+
doi: "doi";
|
|
16
|
+
title: "title";
|
|
17
|
+
providerURL: "providerURL";
|
|
18
|
+
date: "date";
|
|
19
|
+
authors: "authors";
|
|
20
|
+
year: "year";
|
|
21
|
+
totalCitations: "totalCitations";
|
|
22
|
+
totalReferences: "totalReferences";
|
|
23
|
+
abstract: "abstract";
|
|
24
|
+
pdfURL: "pdfURL";
|
|
25
|
+
provider: "provider";
|
|
26
|
+
providerData: "providerData";
|
|
27
|
+
}>>>>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
results: z.ZodArray<z.ZodObject<{
|
|
30
|
+
sentence: z.ZodString;
|
|
31
|
+
citations: z.ZodArray<z.ZodObject<{
|
|
32
|
+
score: z.ZodNumber;
|
|
33
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
}, z.core.$strip>>>>;
|
|
41
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
43
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
sentenceCount: z.ZodNumber;
|
|
52
|
+
totalCitations: z.ZodNumber;
|
|
53
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
54
|
+
requestId: z.ZodNumber;
|
|
55
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const providerSchema = z.enum([
|
|
4
|
+
"semantic-scholar",
|
|
5
|
+
"pubmed",
|
|
6
|
+
"arxiv",
|
|
7
|
+
"google-scholar",
|
|
8
|
+
"eric",
|
|
9
|
+
"europe-pmc",
|
|
10
|
+
"openalex",
|
|
11
|
+
], {
|
|
12
|
+
message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex",
|
|
13
|
+
});
|
|
14
|
+
const authorSchema = z.object({
|
|
15
|
+
name: z.string(),
|
|
16
|
+
url: z.string().nullish(),
|
|
17
|
+
});
|
|
18
|
+
const scoredPublicationSchema = z.object({
|
|
19
|
+
score: z.number().describe("Relevance score (0-10)"),
|
|
20
|
+
doi: z.string().nullish(),
|
|
21
|
+
title: z.string().nullish(),
|
|
22
|
+
url: z.string().nullish(),
|
|
23
|
+
providerURL: z.string().nullish(),
|
|
24
|
+
authors: z.array(authorSchema).nullish(),
|
|
25
|
+
date: z.string().nullish(),
|
|
26
|
+
year: z.number().nullish(),
|
|
27
|
+
totalCitations: z.number().nullish(),
|
|
28
|
+
totalReferences: z.number().nullish(),
|
|
29
|
+
abstract: z.string().nullish(),
|
|
30
|
+
pdfURL: z.string().nullish(),
|
|
31
|
+
provider: z.string().nullish(),
|
|
32
|
+
providerData: z.record(z.string(), z.unknown()).nullish(),
|
|
33
|
+
});
|
|
34
|
+
const sentenceCitationSchema = z.object({
|
|
35
|
+
sentence: z.string(),
|
|
36
|
+
citations: z.array(scoredPublicationSchema),
|
|
37
|
+
});
|
|
38
|
+
const requestExamples = {
|
|
39
|
+
"Find citations for a paragraph": {
|
|
40
|
+
summary: "Find citations for a research paragraph",
|
|
41
|
+
value: {
|
|
42
|
+
paragraph: "Deep learning has revolutionized computer vision and natural language processing. Transformer architectures have become the dominant approach for sequence modeling tasks. Recent large language models demonstrate emergent capabilities not seen in smaller models.",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
"Find citations with multiple providers": {
|
|
46
|
+
summary: "Search across multiple databases",
|
|
47
|
+
value: {
|
|
48
|
+
paragraph: "CRISPR-Cas9 gene editing technology has transformed molecular biology. The ability to precisely modify DNA sequences has opened new avenues for treating genetic diseases.",
|
|
49
|
+
providers: ["semantic-scholar", "pubmed"],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const findCitations = oc
|
|
54
|
+
.input(z.object({
|
|
55
|
+
paragraph: z
|
|
56
|
+
.string({ message: "paragraph is required and must be a string" })
|
|
57
|
+
.min(1, "paragraph must not be empty")
|
|
58
|
+
.max(5000, "paragraph must be at most 5000 characters")
|
|
59
|
+
.describe("Text paragraph to find relevant academic citations for"),
|
|
60
|
+
providers: z
|
|
61
|
+
.array(providerSchema, {
|
|
62
|
+
message: "providers must be an array of valid provider names",
|
|
63
|
+
})
|
|
64
|
+
.default(["semantic-scholar"])
|
|
65
|
+
.describe("Academic databases to search for citations"),
|
|
66
|
+
fields: z
|
|
67
|
+
.array(z.enum([
|
|
68
|
+
"doi",
|
|
69
|
+
"title",
|
|
70
|
+
"url",
|
|
71
|
+
"providerURL",
|
|
72
|
+
"authors",
|
|
73
|
+
"date",
|
|
74
|
+
"year",
|
|
75
|
+
"totalCitations",
|
|
76
|
+
"totalReferences",
|
|
77
|
+
"abstract",
|
|
78
|
+
"pdfURL",
|
|
79
|
+
"provider",
|
|
80
|
+
"providerData",
|
|
81
|
+
]), {
|
|
82
|
+
message: "fields must be an array of valid publication field names",
|
|
83
|
+
})
|
|
84
|
+
.nullish()
|
|
85
|
+
.describe("Specific citation fields to return. If omitted, returns all fields except providerData."),
|
|
86
|
+
}))
|
|
87
|
+
.output(z.object({
|
|
88
|
+
results: z.array(sentenceCitationSchema),
|
|
89
|
+
sentenceCount: z.number().int(),
|
|
90
|
+
totalCitations: z.number().int(),
|
|
91
|
+
errors: z.array(z.string()).nullish(),
|
|
92
|
+
requestId: z.number().int(),
|
|
93
|
+
}))
|
|
94
|
+
.route({
|
|
95
|
+
summary: "Find citations for a paragraph",
|
|
96
|
+
description: "Find relevant academic citations for a paragraph by splitting it into sentences and scoring papers using semantic embedding similarity.",
|
|
97
|
+
tags: ["Academic"],
|
|
98
|
+
spec: (op) => {
|
|
99
|
+
op.security = [{ bearerAuth: [] }];
|
|
100
|
+
const reqBody = op.requestBody;
|
|
101
|
+
if (reqBody?.content) {
|
|
102
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
103
|
+
mediaType.examples = requestExamples;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return op;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const search: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
|
+
query: z.ZodString;
|
|
4
|
+
providers: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
5
|
+
"semantic-scholar": "semantic-scholar";
|
|
6
|
+
pubmed: "pubmed";
|
|
7
|
+
arxiv: "arxiv";
|
|
8
|
+
"google-scholar": "google-scholar";
|
|
9
|
+
eric: "eric";
|
|
10
|
+
"europe-pmc": "europe-pmc";
|
|
11
|
+
openalex: "openalex";
|
|
12
|
+
}>>>;
|
|
13
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
yearFrom: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
yearTo: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
17
|
+
fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
18
|
+
url: "url";
|
|
19
|
+
doi: "doi";
|
|
20
|
+
title: "title";
|
|
21
|
+
providerURL: "providerURL";
|
|
22
|
+
date: "date";
|
|
23
|
+
authors: "authors";
|
|
24
|
+
year: "year";
|
|
25
|
+
totalCitations: "totalCitations";
|
|
26
|
+
totalReferences: "totalReferences";
|
|
27
|
+
abstract: "abstract";
|
|
28
|
+
pdfURL: "pdfURL";
|
|
29
|
+
provider: "provider";
|
|
30
|
+
providerData: "providerData";
|
|
31
|
+
}>>>>;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
estimatedTotalResults: z.ZodNumber;
|
|
34
|
+
results: z.ZodArray<z.ZodObject<{
|
|
35
|
+
doi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
providerURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
39
|
+
authors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
}, z.core.$strip>>>>;
|
|
43
|
+
date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
totalCitations: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
46
|
+
totalReferences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
47
|
+
abstract: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
pdfURL: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
50
|
+
"semantic-scholar": "semantic-scholar";
|
|
51
|
+
pubmed: "pubmed";
|
|
52
|
+
arxiv: "arxiv";
|
|
53
|
+
"google-scholar": "google-scholar";
|
|
54
|
+
eric: "eric";
|
|
55
|
+
"europe-pmc": "europe-pmc";
|
|
56
|
+
openalex: "openalex";
|
|
57
|
+
}>>>;
|
|
58
|
+
providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
61
|
+
provider: z.ZodString;
|
|
62
|
+
message: z.ZodString;
|
|
63
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
65
|
+
}, z.core.$strip>>>>;
|
|
66
|
+
requestId: z.ZodNumber;
|
|
67
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const providerSchema = z.enum([
|
|
4
|
+
"semantic-scholar",
|
|
5
|
+
"pubmed",
|
|
6
|
+
"arxiv",
|
|
7
|
+
"google-scholar",
|
|
8
|
+
"eric",
|
|
9
|
+
"europe-pmc",
|
|
10
|
+
"openalex",
|
|
11
|
+
], {
|
|
12
|
+
message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex",
|
|
13
|
+
});
|
|
14
|
+
const authorSchema = z.object({
|
|
15
|
+
name: z.string(),
|
|
16
|
+
url: z.string().nullish(),
|
|
17
|
+
});
|
|
18
|
+
const publicationSchema = z.object({
|
|
19
|
+
doi: z.string().nullish(),
|
|
20
|
+
title: z.string().nullish(),
|
|
21
|
+
url: z.string().nullish(),
|
|
22
|
+
providerURL: z.string().nullish(),
|
|
23
|
+
authors: z.array(authorSchema).nullish(),
|
|
24
|
+
date: z.string().nullish(),
|
|
25
|
+
year: z.number().nullish(),
|
|
26
|
+
totalCitations: z.number().nullish(),
|
|
27
|
+
totalReferences: z.number().nullish(),
|
|
28
|
+
abstract: z.string().nullish(),
|
|
29
|
+
pdfURL: z.string().nullish(),
|
|
30
|
+
provider: providerSchema.nullish(),
|
|
31
|
+
providerData: z.record(z.string(), z.unknown()).nullish(),
|
|
32
|
+
});
|
|
33
|
+
const providerErrorSchema = z.object({
|
|
34
|
+
provider: z.string(),
|
|
35
|
+
message: z.string(),
|
|
36
|
+
code: z.string().nullish(),
|
|
37
|
+
details: z.record(z.string(), z.unknown()).nullish(),
|
|
38
|
+
});
|
|
39
|
+
const requestExamples = {
|
|
40
|
+
"Search with default provider": {
|
|
41
|
+
summary: "Search with Semantic Scholar",
|
|
42
|
+
value: {
|
|
43
|
+
query: "deep learning for natural language processing",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
"Search multiple providers": {
|
|
47
|
+
summary: "Search across multiple databases",
|
|
48
|
+
value: {
|
|
49
|
+
query: "CRISPR gene editing",
|
|
50
|
+
providers: ["semantic-scholar", "pubmed", "openalex"],
|
|
51
|
+
limit: 10,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
"Search with year filter": {
|
|
55
|
+
summary: "Search recent papers",
|
|
56
|
+
value: {
|
|
57
|
+
query: "large language models",
|
|
58
|
+
providers: ["semantic-scholar"],
|
|
59
|
+
yearFrom: 2023,
|
|
60
|
+
yearTo: 2026,
|
|
61
|
+
limit: 20,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const search = oc
|
|
66
|
+
.input(z.object({
|
|
67
|
+
query: z
|
|
68
|
+
.string({ message: "query is required and must be a string" })
|
|
69
|
+
.min(1, "query must not be empty")
|
|
70
|
+
.max(400, "query must be at most 400 characters")
|
|
71
|
+
.describe("Search query string for academic papers"),
|
|
72
|
+
providers: z
|
|
73
|
+
.array(providerSchema, {
|
|
74
|
+
message: "providers must be an array of valid provider names",
|
|
75
|
+
})
|
|
76
|
+
.default(["semantic-scholar"])
|
|
77
|
+
.describe("Academic databases to search"),
|
|
78
|
+
offset: z
|
|
79
|
+
.number({ message: "offset must be a number" })
|
|
80
|
+
.int("offset must be a whole number")
|
|
81
|
+
.min(0, "offset must be 0 or greater")
|
|
82
|
+
.default(0)
|
|
83
|
+
.describe("Results offset"),
|
|
84
|
+
limit: z
|
|
85
|
+
.number({ message: "limit must be a number" })
|
|
86
|
+
.int("limit must be a whole number")
|
|
87
|
+
.min(1, "limit must be at least 1")
|
|
88
|
+
.max(100, "limit must be at most 100")
|
|
89
|
+
.default(20)
|
|
90
|
+
.describe("Results per provider"),
|
|
91
|
+
yearFrom: z
|
|
92
|
+
.number({ message: "yearFrom must be a number" })
|
|
93
|
+
.int("yearFrom must be a whole number")
|
|
94
|
+
.min(1900, "yearFrom must be 1900 or later")
|
|
95
|
+
.max(2100, "yearFrom must be 2100 or earlier")
|
|
96
|
+
.nullish()
|
|
97
|
+
.describe("Filter papers published from this year"),
|
|
98
|
+
yearTo: z
|
|
99
|
+
.number({ message: "yearTo must be a number" })
|
|
100
|
+
.int("yearTo must be a whole number")
|
|
101
|
+
.min(1900, "yearTo must be 1900 or later")
|
|
102
|
+
.max(2100, "yearTo must be 2100 or earlier")
|
|
103
|
+
.nullish()
|
|
104
|
+
.describe("Filter papers published up to this year"),
|
|
105
|
+
fields: z
|
|
106
|
+
.array(z.enum([
|
|
107
|
+
"doi",
|
|
108
|
+
"title",
|
|
109
|
+
"url",
|
|
110
|
+
"providerURL",
|
|
111
|
+
"authors",
|
|
112
|
+
"date",
|
|
113
|
+
"year",
|
|
114
|
+
"totalCitations",
|
|
115
|
+
"totalReferences",
|
|
116
|
+
"abstract",
|
|
117
|
+
"pdfURL",
|
|
118
|
+
"provider",
|
|
119
|
+
"providerData",
|
|
120
|
+
]), {
|
|
121
|
+
message: "fields must be an array of valid publication field names",
|
|
122
|
+
})
|
|
123
|
+
.nullish()
|
|
124
|
+
.describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
125
|
+
}))
|
|
126
|
+
.output(z.object({
|
|
127
|
+
estimatedTotalResults: z.number(),
|
|
128
|
+
results: z.array(publicationSchema),
|
|
129
|
+
errors: z.array(providerErrorSchema).nullish(),
|
|
130
|
+
requestId: z.number().int(),
|
|
131
|
+
}))
|
|
132
|
+
.route({
|
|
133
|
+
summary: "Search academic papers",
|
|
134
|
+
description: "Search for academic publications across multiple databases with relevance ranking.",
|
|
135
|
+
tags: ["Academic"],
|
|
136
|
+
spec: (op) => {
|
|
137
|
+
op.security = [{ bearerAuth: [] }];
|
|
138
|
+
const reqBody = op.requestBody;
|
|
139
|
+
if (reqBody?.content) {
|
|
140
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
141
|
+
mediaType.examples = requestExamples;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return op;
|
|
145
|
+
},
|
|
146
|
+
});
|
|
@@ -29,7 +29,7 @@ const askInputSchema = z.object({
|
|
|
29
29
|
.describe("Base64-encoded bank statement file content"),
|
|
30
30
|
question: z
|
|
31
31
|
.string()
|
|
32
|
-
.min(4)
|
|
32
|
+
.min(4, "question must be at least 4 characters")
|
|
33
33
|
.describe("The question to answer about the bank statement"),
|
|
34
34
|
model: specializedModelSchema.describe("Model tier for answering the question. " +
|
|
35
35
|
"'auto' (default): Automatically selects the best tier. " +
|
|
@@ -29,7 +29,7 @@ const extractInputSchema = z.object({
|
|
|
29
29
|
.describe("Base64-encoded bank statement file content"),
|
|
30
30
|
prompt: z
|
|
31
31
|
.string()
|
|
32
|
-
.min(4)
|
|
32
|
+
.min(4, "prompt must be at least 4 characters")
|
|
33
33
|
.describe("The prompt instructing the AI how to extract data from the bank statement"),
|
|
34
34
|
schema: z
|
|
35
35
|
.union([
|
|
@@ -2,7 +2,9 @@ import { oc } from "@orpc/contract";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getDefaultSpec } from "./get-default-spec";
|
|
4
4
|
const specializedParseModelSchema = z
|
|
5
|
-
.enum(["pro", "max", "auto"]
|
|
5
|
+
.enum(["pro", "max", "auto"], {
|
|
6
|
+
message: "model must be one of: pro, max, auto",
|
|
7
|
+
})
|
|
6
8
|
.default("auto");
|
|
7
9
|
const parseInputSchema = z.object({
|
|
8
10
|
url: z
|
|
@@ -26,7 +26,7 @@ const askInputSchema = z.object({
|
|
|
26
26
|
.describe("Base64-encoded document file content"),
|
|
27
27
|
question: z
|
|
28
28
|
.string()
|
|
29
|
-
.min(4)
|
|
29
|
+
.min(4, "question must be at least 4 characters")
|
|
30
30
|
.describe("The question to answer about the document"),
|
|
31
31
|
model: z
|
|
32
32
|
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
@@ -26,7 +26,7 @@ const extractInputSchema = z.object({
|
|
|
26
26
|
.describe("Base64-encoded document file content"),
|
|
27
27
|
prompt: z
|
|
28
28
|
.string()
|
|
29
|
-
.min(4)
|
|
29
|
+
.min(4, "prompt must be at least 4 characters")
|
|
30
30
|
.describe("The prompt instructing the AI how to extract data from the document"),
|
|
31
31
|
schema: z
|
|
32
32
|
.union([
|
|
@@ -29,7 +29,7 @@ const askInputSchema = z.object({
|
|
|
29
29
|
.describe("Base64-encoded identity document file content"),
|
|
30
30
|
question: z
|
|
31
31
|
.string()
|
|
32
|
-
.min(4)
|
|
32
|
+
.min(4, "question must be at least 4 characters")
|
|
33
33
|
.describe("The question to answer about the identity document"),
|
|
34
34
|
model: specializedModelSchema.describe("Model tier for answering the question. " +
|
|
35
35
|
"'auto' (default): Automatically selects the best tier. " +
|
|
@@ -29,7 +29,7 @@ const extractInputSchema = z.object({
|
|
|
29
29
|
.describe("Base64-encoded identity document file content"),
|
|
30
30
|
prompt: z
|
|
31
31
|
.string()
|
|
32
|
-
.min(4)
|
|
32
|
+
.min(4, "prompt must be at least 4 characters")
|
|
33
33
|
.describe("The prompt instructing the AI how to extract data from the identity document"),
|
|
34
34
|
schema: z
|
|
35
35
|
.union([
|
|
@@ -2,7 +2,9 @@ import { oc } from "@orpc/contract";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getDefaultSpec } from "./get-default-spec";
|
|
4
4
|
const specializedParseModelSchema = z
|
|
5
|
-
.enum(["pro", "max", "auto"]
|
|
5
|
+
.enum(["pro", "max", "auto"], {
|
|
6
|
+
message: "model must be one of: pro, max, auto",
|
|
7
|
+
})
|
|
6
8
|
.default("auto");
|
|
7
9
|
const parseInputSchema = z.object({
|
|
8
10
|
url: z
|
package/.tsc/lib/router/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const askInputSchema = z.object({
|
|
|
26
26
|
base64: z.string().optional().describe("Base64-encoded invoice file content"),
|
|
27
27
|
question: z
|
|
28
28
|
.string()
|
|
29
|
-
.min(4)
|
|
29
|
+
.min(4, "question must be at least 4 characters")
|
|
30
30
|
.describe("The question to answer about the invoice"),
|
|
31
31
|
model: specializedModelSchema.describe("Model tier for answering the question. " +
|
|
32
32
|
"'auto' (default): Automatically selects the best tier. " +
|
|
@@ -26,7 +26,7 @@ const extractInputSchema = z.object({
|
|
|
26
26
|
base64: z.string().optional().describe("Base64-encoded invoice file content"),
|
|
27
27
|
prompt: z
|
|
28
28
|
.string()
|
|
29
|
-
.min(4)
|
|
29
|
+
.min(4, "prompt must be at least 4 characters")
|
|
30
30
|
.describe("The prompt instructing the AI how to extract data from the invoice"),
|
|
31
31
|
schema: z
|
|
32
32
|
.union([
|
|
@@ -2,7 +2,9 @@ import { oc } from "@orpc/contract";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getDefaultSpec } from "./get-default-spec";
|
|
4
4
|
const specializedParseModelSchema = z
|
|
5
|
-
.enum(["pro", "max", "auto"]
|
|
5
|
+
.enum(["pro", "max", "auto"], {
|
|
6
|
+
message: "model must be one of: pro, max, auto",
|
|
7
|
+
})
|
|
6
8
|
.default("auto");
|
|
7
9
|
const parseInputSchema = z.object({
|
|
8
10
|
url: z
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @pdfvector/instance-contract
|
|
2
2
|
|
|
3
|
+
## 0.0.20
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#120](https://github.com/phuctm97/pdfvector/pull/120) [`31b1d7b`](https://github.com/phuctm97/pdfvector/commit/31b1d7b22917ce8a57088132c05da7c4ec105b2b) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Add academic APIs (search, fetch, findCitations) with proxy system, publication URLs, and playground improvements
|
|
9
|
+
|
|
3
10
|
## 0.0.19
|
|
4
11
|
### Patch Changes
|
|
5
12
|
|