@deepcitation/deepcitation-js 1.1.27 → 1.1.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/LICENSE +21 -21
- package/README.md +253 -253
- package/lib/chunk-2IZXUOQR.js +66 -0
- package/lib/chunk-3GR7VKUJ.cjs +1 -0
- package/lib/chunk-4FGOHQFP.cjs +66 -0
- package/lib/chunk-CFXDRAJL.cjs +1 -0
- package/lib/chunk-F2MMVEVC.cjs +1 -0
- package/lib/chunk-LSKISWWH.cjs +2 -0
- package/lib/chunk-O2XFH626.js +1 -0
- package/lib/chunk-QGXCOW3E.js +1 -0
- package/lib/chunk-RCHWBA6D.js +2 -0
- package/lib/chunk-RQPZSRID.js +1 -0
- package/lib/client/index.cjs +1 -0
- package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
- package/lib/client/index.d.ts +342 -2
- package/lib/client/index.js +1 -1
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +105 -0
- package/lib/index.d.ts +103 -21
- package/lib/index.js +1 -20
- package/lib/prompts/index.cjs +1 -0
- package/lib/prompts/index.d.cts +196 -0
- package/lib/prompts/index.d.ts +196 -3
- package/lib/prompts/index.js +1 -3
- package/lib/react/index.cjs +4 -0
- package/lib/react/{types.d.ts → index.d.cts} +173 -22
- package/lib/react/index.d.ts +461 -12
- package/lib/react/index.js +4 -20
- package/lib/types/index.cjs +1 -0
- package/lib/types/index.d.cts +96 -0
- package/lib/types/index.d.ts +96 -11
- package/lib/types/index.js +1 -7
- package/lib/utils-CSqRI6NU.d.cts +45 -0
- package/lib/{react/utils.d.ts → utils-D_wxy_ni.d.ts} +13 -12
- package/package.json +46 -11
- package/lib/client/DeepCitation.js +0 -374
- package/lib/client/types.d.ts +0 -154
- package/lib/client/types.js +0 -1
- package/lib/parsing/normalizeCitation.d.ts +0 -5
- package/lib/parsing/normalizeCitation.js +0 -198
- package/lib/parsing/parseCitation.d.ts +0 -79
- package/lib/parsing/parseCitation.js +0 -431
- package/lib/parsing/parseWorkAround.d.ts +0 -2
- package/lib/parsing/parseWorkAround.js +0 -73
- package/lib/prompts/citationPrompts.d.ts +0 -138
- package/lib/prompts/citationPrompts.js +0 -168
- package/lib/prompts/promptCompression.d.ts +0 -14
- package/lib/prompts/promptCompression.js +0 -127
- package/lib/prompts/types.d.ts +0 -4
- package/lib/prompts/types.js +0 -1
- package/lib/react/CitationComponent.d.ts +0 -106
- package/lib/react/CitationComponent.js +0 -419
- package/lib/react/CitationVariants.d.ts +0 -132
- package/lib/react/CitationVariants.js +0 -277
- package/lib/react/DiffDisplay.d.ts +0 -10
- package/lib/react/DiffDisplay.js +0 -33
- package/lib/react/Popover.d.ts +0 -15
- package/lib/react/Popover.js +0 -20
- package/lib/react/UrlCitationComponent.d.ts +0 -83
- package/lib/react/UrlCitationComponent.js +0 -224
- package/lib/react/VerificationTabs.d.ts +0 -10
- package/lib/react/VerificationTabs.js +0 -36
- package/lib/react/icons.d.ts +0 -22
- package/lib/react/icons.js +0 -16
- package/lib/react/primitives.d.ts +0 -99
- package/lib/react/primitives.js +0 -187
- package/lib/react/types.js +0 -1
- package/lib/react/useSmartDiff.d.ts +0 -16
- package/lib/react/useSmartDiff.js +0 -64
- package/lib/react/utils.js +0 -88
- package/lib/types/boxes.d.ts +0 -11
- package/lib/types/boxes.js +0 -1
- package/lib/types/citation.d.ts +0 -39
- package/lib/types/citation.js +0 -1
- package/lib/types/search.d.ts +0 -19
- package/lib/types/search.js +0 -1
- package/lib/types/verification.d.ts +0 -27
- package/lib/types/verification.js +0 -11
- package/lib/utils/diff.d.ts +0 -60
- package/lib/utils/diff.js +0 -414
- package/lib/utils/sha.d.ts +0 -10
- package/lib/utils/sha.js +0 -108
package/lib/types/index.d.ts
CHANGED
|
@@ -1,11 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
interface PdfSpaceItem extends ScreenBox {
|
|
2
|
+
text?: string;
|
|
3
|
+
}
|
|
4
|
+
type IVertex = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
interface ScreenBox extends IVertex {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_key_span_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
|
|
14
|
+
type SearchMethod = "exact_line_match" | "line_with_buffer" | "current_page" | "keyspan_fallback" | "adjacent_pages" | "expanded_window" | "regex_search" | "bm25_search" | "fuzzy_regex" | "first_word_fallback";
|
|
15
|
+
interface SearchAttempt {
|
|
16
|
+
method: SearchMethod;
|
|
17
|
+
success: boolean;
|
|
18
|
+
searchPhrases: string[];
|
|
19
|
+
pageSearched?: number;
|
|
20
|
+
matchedPhrases?: string[];
|
|
21
|
+
matchedVariation?: string;
|
|
22
|
+
phraseVariations?: string[];
|
|
23
|
+
matchQuality?: string;
|
|
24
|
+
isPartialMatch?: boolean;
|
|
25
|
+
matchScore?: number;
|
|
26
|
+
matchSnippet?: string;
|
|
27
|
+
notes?: string;
|
|
28
|
+
startTime?: number;
|
|
29
|
+
endTime?: number;
|
|
30
|
+
durationMs?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const NOT_FOUND_VERIFICATION_INDEX = -1;
|
|
34
|
+
declare const PENDING_VERIFICATION_INDEX = -2;
|
|
35
|
+
declare const BLANK_VERIFICATION: Verification;
|
|
36
|
+
interface Verification {
|
|
37
|
+
attachmentId?: string | null;
|
|
38
|
+
label?: string | null;
|
|
39
|
+
citation?: Citation;
|
|
40
|
+
status?: SearchStatus | null;
|
|
41
|
+
searchAttempts?: SearchAttempt[];
|
|
42
|
+
highlightColor?: string | null;
|
|
43
|
+
verifiedPageNumber?: number | null;
|
|
44
|
+
verifiedLineIds?: number[] | null;
|
|
45
|
+
verifiedTimestamps?: {
|
|
46
|
+
startTime?: string;
|
|
47
|
+
endTime?: string;
|
|
48
|
+
} | null;
|
|
49
|
+
verifiedFullPhrase?: string | null;
|
|
50
|
+
verifiedKeySpan?: string | null;
|
|
51
|
+
verifiedMatchSnippet?: string | null;
|
|
52
|
+
hitIndexWithinPage?: number | null;
|
|
53
|
+
pdfSpaceItem?: PdfSpaceItem;
|
|
54
|
+
verificationImageBase64?: string | null;
|
|
55
|
+
verifiedAt?: Date;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type OutputImageFormat = "jpeg" | "png" | "avif" | undefined | null;
|
|
59
|
+
declare const DEFAULT_OUTPUT_IMAGE_FORMAT: "avif";
|
|
60
|
+
interface VerifyCitationResponse {
|
|
61
|
+
verifications: {
|
|
62
|
+
[key: string]: Verification;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
interface VerifyCitationRequest {
|
|
66
|
+
attachmentId: string;
|
|
67
|
+
citations: {
|
|
68
|
+
[key: string]: Citation;
|
|
69
|
+
};
|
|
70
|
+
outputImageFormat?: OutputImageFormat;
|
|
71
|
+
apiKey?: string;
|
|
72
|
+
}
|
|
73
|
+
interface Citation {
|
|
74
|
+
attachmentId?: string;
|
|
75
|
+
fullPhrase?: string | null;
|
|
76
|
+
keySpan?: string | null;
|
|
77
|
+
startPageKey?: string | null;
|
|
78
|
+
lineIds?: number[] | null;
|
|
79
|
+
reasoning?: string | null;
|
|
80
|
+
selection?: ScreenBox | null;
|
|
81
|
+
citationNumber?: number;
|
|
82
|
+
pageNumber?: number | null;
|
|
83
|
+
timestamps?: {
|
|
84
|
+
endTime?: string;
|
|
85
|
+
startTime?: string;
|
|
86
|
+
};
|
|
87
|
+
beforeCite?: string;
|
|
88
|
+
}
|
|
89
|
+
interface CitationStatus {
|
|
90
|
+
isVerified: boolean;
|
|
91
|
+
isMiss: boolean;
|
|
92
|
+
isPartialMatch: boolean;
|
|
93
|
+
isPending: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { BLANK_VERIFICATION, type Citation, type CitationStatus, DEFAULT_OUTPUT_IMAGE_FORMAT, type IVertex, NOT_FOUND_VERIFICATION_INDEX, type OutputImageFormat, PENDING_VERIFICATION_INDEX, type PdfSpaceItem, type ScreenBox, type SearchAttempt, type SearchMethod, type SearchStatus, type Verification, type VerifyCitationRequest, type VerifyCitationResponse };
|
package/lib/types/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Type definitions for DeepCitation
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
export { DEFAULT_OUTPUT_IMAGE_FORMAT } from "./citation.js";
|
|
7
|
-
export { NOT_FOUND_VERIFICATION_INDEX, PENDING_VERIFICATION_INDEX, BLANK_VERIFICATION, } from "./verification.js";
|
|
1
|
+
export{d as BLANK_VERIFICATION,a as DEFAULT_OUTPUT_IMAGE_FORMAT,b as NOT_FOUND_VERIFICATION_INDEX,c as PENDING_VERIFICATION_INDEX}from'../chunk-RQPZSRID.js';import'../chunk-O2XFH626.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Citation, Verification } from './types/index.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generates a unique, deterministic key for a citation based on its content.
|
|
5
|
+
* @param citation - The citation to generate a key for
|
|
6
|
+
* @returns A unique, deterministic key for the citation
|
|
7
|
+
*/
|
|
8
|
+
declare function generateCitationKey(citation: Citation): string;
|
|
9
|
+
/**
|
|
10
|
+
* Generates a unique, deterministic key for a verification based on its content.
|
|
11
|
+
* @param verification - The verification to generate a key for
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare function generateVerificationKey(verification: Verification): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a unique instance ID for a citation component render.
|
|
17
|
+
* Combines the citation key with a random suffix for uniqueness.
|
|
18
|
+
*/
|
|
19
|
+
declare function generateCitationInstanceId(citationKey: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the display text for a citation (keySpan with fallback to number).
|
|
22
|
+
*/
|
|
23
|
+
declare function getCitationDisplayText(citation: Citation, options?: {
|
|
24
|
+
fallbackDisplay?: string | null;
|
|
25
|
+
}): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the citation number as a string.
|
|
28
|
+
*/
|
|
29
|
+
declare function getCitationNumber(citation: Citation): string;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the keySpan text from a citation.
|
|
32
|
+
*/
|
|
33
|
+
declare function getCitationKeySpanText(citation: Citation): string;
|
|
34
|
+
/**
|
|
35
|
+
* Joins class names, filtering out falsy values.
|
|
36
|
+
* This is a minimal implementation for the base component.
|
|
37
|
+
*/
|
|
38
|
+
declare function classNames(...classes: (string | undefined | null | false)[]): string;
|
|
39
|
+
/**
|
|
40
|
+
* Default padding values for citation styling.
|
|
41
|
+
*/
|
|
42
|
+
declare const CITATION_X_PADDING = 4;
|
|
43
|
+
declare const CITATION_Y_PADDING = 1;
|
|
44
|
+
|
|
45
|
+
export { CITATION_X_PADDING as C, generateVerificationKey as a, generateCitationInstanceId as b, CITATION_Y_PADDING as c, getCitationDisplayText as d, getCitationNumber as e, getCitationKeySpanText as f, generateCitationKey as g, classNames as h };
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
1
|
+
import { Citation, Verification } from './types/index.js';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* Generates a unique, deterministic key for a citation based on its content.
|
|
6
5
|
* @param citation - The citation to generate a key for
|
|
7
6
|
* @returns A unique, deterministic key for the citation
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
declare function generateCitationKey(citation: Citation): string;
|
|
10
9
|
/**
|
|
11
10
|
* Generates a unique, deterministic key for a verification based on its content.
|
|
12
11
|
* @param verification - The verification to generate a key for
|
|
13
12
|
* @returns
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
declare function generateVerificationKey(verification: Verification): string;
|
|
16
15
|
/**
|
|
17
16
|
* Generates a unique instance ID for a citation component render.
|
|
18
17
|
* Combines the citation key with a random suffix for uniqueness.
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
declare function generateCitationInstanceId(citationKey: string): string;
|
|
21
20
|
/**
|
|
22
21
|
* Gets the display text for a citation (keySpan with fallback to number).
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
declare function getCitationDisplayText(citation: Citation, options?: {
|
|
25
24
|
fallbackDisplay?: string | null;
|
|
26
25
|
}): string;
|
|
27
26
|
/**
|
|
28
27
|
* Gets the citation number as a string.
|
|
29
28
|
*/
|
|
30
|
-
|
|
29
|
+
declare function getCitationNumber(citation: Citation): string;
|
|
31
30
|
/**
|
|
32
31
|
* Gets the keySpan text from a citation.
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
declare function getCitationKeySpanText(citation: Citation): string;
|
|
35
34
|
/**
|
|
36
35
|
* Joins class names, filtering out falsy values.
|
|
37
36
|
* This is a minimal implementation for the base component.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
declare function classNames(...classes: (string | undefined | null | false)[]): string;
|
|
40
39
|
/**
|
|
41
40
|
* Default padding values for citation styling.
|
|
42
41
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
declare const CITATION_X_PADDING = 4;
|
|
43
|
+
declare const CITATION_Y_PADDING = 1;
|
|
44
|
+
|
|
45
|
+
export { CITATION_X_PADDING as C, generateVerificationKey as a, generateCitationInstanceId as b, CITATION_Y_PADDING as c, getCitationDisplayText as d, getCitationNumber as e, getCitationKeySpanText as f, generateCitationKey as g, classNames as h };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepcitation/deepcitation-js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.29",
|
|
4
4
|
"description": "DeepCitation JavaScript SDK for deterministic AI citation verification",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/deepcitation/deepcitation-js.git"
|
|
16
16
|
},
|
|
17
|
-
"main": "./lib/index.
|
|
17
|
+
"main": "./lib/index.cjs",
|
|
18
|
+
"module": "./lib/index.js",
|
|
18
19
|
"types": "./lib/index.d.ts",
|
|
19
20
|
"sideEffects": false,
|
|
20
21
|
"files": [
|
|
@@ -22,17 +23,20 @@
|
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
24
25
|
"scripts": {
|
|
25
|
-
"build": "
|
|
26
|
-
"build:watch": "
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"build:watch": "tsup --watch",
|
|
28
|
+
"build:tsc": "rimraf lib && tsc",
|
|
27
29
|
"test": "bun test ./src/__tests__/*.test.ts ./src/__tests__/*.test.tsx",
|
|
28
30
|
"test:jest": "jest",
|
|
29
31
|
"test:watch": "jest --watch",
|
|
30
32
|
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
31
33
|
"test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
34
|
+
"size": "size-limit",
|
|
35
|
+
"analyze": "size-limit --why",
|
|
32
36
|
"prepublishOnly": "npm run build"
|
|
33
37
|
},
|
|
34
38
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
39
|
+
"node": ">=18"
|
|
36
40
|
},
|
|
37
41
|
"peerDependencies": {
|
|
38
42
|
"react": ">=17.0.0",
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
58
|
+
"@size-limit/preset-small-lib": "^11.0.0",
|
|
54
59
|
"@happy-dom/global-registrator": "^20.0.11",
|
|
55
60
|
"@playwright/experimental-ct-react": "^1.57.0",
|
|
56
61
|
"@playwright/test": "^1.57.0",
|
|
@@ -69,34 +74,55 @@
|
|
|
69
74
|
"react": "19.2.3",
|
|
70
75
|
"react-dom": "19.2.3",
|
|
71
76
|
"rimraf": "^5.0.5",
|
|
77
|
+
"size-limit": "^11.0.0",
|
|
72
78
|
"ts-jest": "^29.4.6",
|
|
79
|
+
"tsup": "^8.0.0",
|
|
73
80
|
"typescript": "^5.9.3",
|
|
74
81
|
"vite": "^7.3.0"
|
|
75
82
|
},
|
|
83
|
+
"size-limit": [
|
|
84
|
+
{
|
|
85
|
+
"path": "lib/index.js",
|
|
86
|
+
"limit": "25 KB"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"path": "lib/client/index.js",
|
|
90
|
+
"limit": "10 KB"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"path": "lib/prompts/index.js",
|
|
94
|
+
"limit": "15 KB"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"path": "lib/react/index.js",
|
|
98
|
+
"limit": "15 KB"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
76
101
|
"exports": {
|
|
77
102
|
".": {
|
|
78
103
|
"types": "./lib/index.d.ts",
|
|
79
104
|
"import": "./lib/index.js",
|
|
80
|
-
"require": "./lib/index.
|
|
105
|
+
"require": "./lib/index.cjs"
|
|
81
106
|
},
|
|
82
107
|
"./client": {
|
|
83
108
|
"types": "./lib/client/index.d.ts",
|
|
84
109
|
"import": "./lib/client/index.js",
|
|
85
|
-
"require": "./lib/client/index.
|
|
110
|
+
"require": "./lib/client/index.cjs"
|
|
86
111
|
},
|
|
87
112
|
"./prompts": {
|
|
88
113
|
"types": "./lib/prompts/index.d.ts",
|
|
89
114
|
"import": "./lib/prompts/index.js",
|
|
90
|
-
"require": "./lib/prompts/index.
|
|
115
|
+
"require": "./lib/prompts/index.cjs"
|
|
91
116
|
},
|
|
92
117
|
"./react": {
|
|
93
118
|
"types": "./lib/react/index.d.ts",
|
|
94
119
|
"import": "./lib/react/index.js",
|
|
95
|
-
"require": "./lib/react/index.
|
|
120
|
+
"require": "./lib/react/index.cjs"
|
|
96
121
|
},
|
|
97
122
|
"./types": {
|
|
98
123
|
"types": "./lib/types/index.d.ts",
|
|
99
|
-
"import": "./lib/types/index.js"
|
|
124
|
+
"import": "./lib/types/index.js",
|
|
125
|
+
"require": "./lib/types/index.cjs"
|
|
100
126
|
}
|
|
101
127
|
},
|
|
102
128
|
"keywords": [
|
|
@@ -106,6 +132,15 @@
|
|
|
106
132
|
"llm",
|
|
107
133
|
"hallucination",
|
|
108
134
|
"react",
|
|
109
|
-
"typescript"
|
|
135
|
+
"typescript",
|
|
136
|
+
"openai",
|
|
137
|
+
"anthropic",
|
|
138
|
+
"claude",
|
|
139
|
+
"gpt",
|
|
140
|
+
"rag",
|
|
141
|
+
"reference",
|
|
142
|
+
"source-verification",
|
|
143
|
+
"fact-checking",
|
|
144
|
+
"grounding"
|
|
110
145
|
]
|
|
111
146
|
}
|