@deepcitation/deepcitation-js 1.1.10 → 1.1.12
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/lib/prompts/citationPrompts.d.ts +1 -1
- package/lib/prompts/citationPrompts.js +4 -4
- package/lib/react/CitationComponent.d.ts +6 -6
- package/lib/react/CitationComponent.js +9 -8
- package/lib/react/primitives.d.ts +5 -5
- package/lib/react/primitives.js +10 -10
- package/lib/react/types.d.ts +5 -5
- package/lib/react/utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CITATION_MARKDOWN_SYNTAX_PROMPT = "\nCitation syntax to use within Markdown:\n\u2022 To support any ideas or information that requires a citation from the provided content, use the following citation syntax:\n<cite file_id='file_id' start_page_key='page_number_PAGE_index_INDEX' full_phrase='the verbatim text of the terse phrase inside <file_text />; remember to escape quotes and newlines inside the full_phrase to remain as valid JSON' key_span='the verbatim
|
|
1
|
+
export declare const CITATION_MARKDOWN_SYNTAX_PROMPT = "\nCitation syntax to use within Markdown:\n\u2022 To support any ideas or information that requires a citation from the provided content, use the following citation syntax:\n<cite file_id='file_id' start_page_key='page_number_PAGE_index_INDEX' full_phrase='the verbatim text of the terse phrase inside <file_text />; remember to escape quotes and newlines inside the full_phrase to remain as valid JSON' key_span='the verbatim 1-3 words within full_phrase that best support the citation' line_ids='2-6' reasoning='the terse logic used to conclude the citation' />\n\n\u2022 Very important: for page numbers, only use the page number and page index info from the page_number_PAGE_index_INDEX format (e.g. <page_number_1_index_0>) and never from the contents inside the page.\n\u2022 start_page_key, full_phrase, and line_ids are required for each citation.\n\u2022 Infer line_ids, as we only provide the first, last, and every 5th line. When copying a previous <cite />, use the full info from the previous citation without changing the start_page_key, line_ids, or any other <cite /> attributes.\n\u2022 Use refer to line_ids inclusively, and use a range (or single) for each citation, split multiple sequential line_ids into multiple citations.\n\u2022 These citations will be replaced and displayed in-line as a numeric element (e.g. [1]), the markdown preceding <cite /> should read naturally with only one <cite /> per sentence with rare exceptions for two <cite /> in a sentence. <cite /> often present best at the end of the sentence, and are not grouped at the end of the document.\n\u2022 The full_phrase should be the exact verbatim text of the phrase or paragraph from the source document to support the insight or idea.\n\u2022 We do NOT put the full_phrase inside <cite ...></cite>; we only use full_phrase inside the full_phrase attribute.\n";
|
|
2
2
|
export declare const AV_CITATION_MARKDOWN_SYNTAX_PROMPT = "\n\u2022 To support any ideas or information that requires a citation from the provided content, use the following citation syntax:\n<cite file_id='file_id' full_phrase='the verbatim text of the phrase; remember to escape quotes and newlines inside the full_phrase to remain as valid JSON' timestamps='HH:MM:SS.SSS-HH:MM:SS.SSS' reasoning='the logic connecting the form section requirements to the supporting source citation' />\n\u2022 These citations are displayed in-line or in the relevant list item, and are not grouped at the end of the document.\n";
|
|
3
3
|
export interface WrapSystemPromptOptions {
|
|
4
4
|
/** The original system prompt to wrap with citation instructions */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const CITATION_MARKDOWN_SYNTAX_PROMPT = `
|
|
2
2
|
Citation syntax to use within Markdown:
|
|
3
3
|
• To support any ideas or information that requires a citation from the provided content, use the following citation syntax:
|
|
4
|
-
<cite file_id='file_id' start_page_key='page_number_PAGE_index_INDEX' full_phrase='the verbatim text of the terse phrase inside <file_text />; remember to escape quotes and newlines inside the full_phrase to remain as valid JSON' key_span='the verbatim
|
|
4
|
+
<cite file_id='file_id' start_page_key='page_number_PAGE_index_INDEX' full_phrase='the verbatim text of the terse phrase inside <file_text />; remember to escape quotes and newlines inside the full_phrase to remain as valid JSON' key_span='the verbatim 1-3 words within full_phrase that best support the citation' line_ids='2-6' reasoning='the terse logic used to conclude the citation' />
|
|
5
5
|
|
|
6
6
|
• Very important: for page numbers, only use the page number and page index info from the page_number_PAGE_index_INDEX format (e.g. <page_number_1_index_0>) and never from the contents inside the page.
|
|
7
7
|
• start_page_key, full_phrase, and line_ids are required for each citation.
|
|
@@ -121,11 +121,11 @@ export const CITATION_JSON_OUTPUT_FORMAT = {
|
|
|
121
121
|
},
|
|
122
122
|
fullPhrase: {
|
|
123
123
|
type: "string",
|
|
124
|
-
description: "The verbatim text of the terse phrase inside <file_text /> to support the
|
|
124
|
+
description: "The verbatim text of the terse phrase inside <file_text /> to support the citation (if there is a detected OCR correction, use the corrected text)",
|
|
125
125
|
},
|
|
126
126
|
keySpan: {
|
|
127
127
|
type: "string",
|
|
128
|
-
description: "the verbatim
|
|
128
|
+
description: "the verbatim 1-3 words within fullPhrase that best support the citation",
|
|
129
129
|
},
|
|
130
130
|
lineIds: {
|
|
131
131
|
type: "array",
|
|
@@ -152,7 +152,7 @@ export const CITATION_AV_BASED_JSON_OUTPUT_FORMAT = {
|
|
|
152
152
|
},
|
|
153
153
|
fullPhrase: {
|
|
154
154
|
type: "string",
|
|
155
|
-
description: "The exact verbatim text of the phrase or paragraph from the source document to support the
|
|
155
|
+
description: "The exact verbatim text of the phrase or paragraph from the source document to support the citation (if there is a detected OCR correction, use the verbatim corrected text)",
|
|
156
156
|
},
|
|
157
157
|
timestamps: {
|
|
158
158
|
type: "object",
|
|
@@ -7,7 +7,7 @@ export type { CitationVariant } from "./types.js";
|
|
|
7
7
|
/**
|
|
8
8
|
* Props for the CitationComponent.
|
|
9
9
|
*
|
|
10
|
-
* @example Brackets variant (default) - shows
|
|
10
|
+
* @example Brackets variant (default) - shows keySpan/number in brackets with blue styling
|
|
11
11
|
* ```tsx
|
|
12
12
|
* <CitationComponent
|
|
13
13
|
* citation={{ citationNumber: 1, fullPhrase: "Revenue grew by 25%" }}
|
|
@@ -19,17 +19,17 @@ export type { CitationVariant } from "./types.js";
|
|
|
19
19
|
* @example Numeric variant - shows just the citation number with indicator
|
|
20
20
|
* ```tsx
|
|
21
21
|
* <CitationComponent
|
|
22
|
-
* citation={{ citationNumber: 1,
|
|
22
|
+
* citation={{ citationNumber: 1, keySpan: "25% growth" }}
|
|
23
23
|
* verification={verificationResult}
|
|
24
24
|
* variant="numeric"
|
|
25
25
|
* />
|
|
26
26
|
* // Renders: 1✓
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @example Text variant - shows the
|
|
29
|
+
* @example Text variant - shows the keySpan without styling
|
|
30
30
|
* ```tsx
|
|
31
31
|
* <CitationComponent
|
|
32
|
-
* citation={{ citationNumber: 1,
|
|
32
|
+
* citation={{ citationNumber: 1, keySpan: "25% growth" }}
|
|
33
33
|
* verification={verificationResult}
|
|
34
34
|
* variant="text"
|
|
35
35
|
* />
|
|
@@ -73,9 +73,9 @@ export interface CitationComponentProps extends BaseCitationProps {
|
|
|
73
73
|
verification?: Verification | null;
|
|
74
74
|
/**
|
|
75
75
|
* Display variant for the citation.
|
|
76
|
-
* - `brackets`: Shows
|
|
76
|
+
* - `brackets`: Shows keySpan/number in brackets, blue text styling (default)
|
|
77
77
|
* - `numeric`: Shows citation number with indicator, no brackets
|
|
78
|
-
* - `text`: Shows the
|
|
78
|
+
* - `text`: Shows the keySpan, no text styling, no truncate, shows indicator
|
|
79
79
|
* - `minimal`: No brackets, just display text with indicator
|
|
80
80
|
* - `indicator`: Only the status indicator (checkmark/warning), no text
|
|
81
81
|
*/
|
|
@@ -272,11 +272,11 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
272
272
|
if (variant === "numeric") {
|
|
273
273
|
return citation.citationNumber?.toString() ?? "";
|
|
274
274
|
}
|
|
275
|
-
// For text/minimal
|
|
275
|
+
// For text/minimal variants, always show keySpan
|
|
276
|
+
// For brackets variant, show keySpan only if displayKeySpan prop is true
|
|
276
277
|
return getCitationDisplayText(citation, {
|
|
277
278
|
displayKeySpan: variant === "text" ||
|
|
278
279
|
variant === "minimal" ||
|
|
279
|
-
variant === "brackets" ||
|
|
280
280
|
displayKeySpan,
|
|
281
281
|
fallbackDisplay,
|
|
282
282
|
});
|
|
@@ -309,12 +309,13 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
309
309
|
if (renderIndicator) {
|
|
310
310
|
return renderIndicator(status);
|
|
311
311
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
else if (isPartialMatch) {
|
|
312
|
+
// Check partial match first since isVerified includes isPartialMatch
|
|
313
|
+
if (isPartialMatch) {
|
|
316
314
|
return _jsx(DefaultPartialIndicator, {});
|
|
317
315
|
}
|
|
316
|
+
else if (isVerified) {
|
|
317
|
+
return _jsx(DefaultVerifiedIndicator, {});
|
|
318
|
+
}
|
|
318
319
|
else if (isPending) {
|
|
319
320
|
return (_jsx("span", { className: "dc-indicator dc-indicator--pending", "aria-hidden": "true", children: TWO_DOTS_THINKING_CONTENT }));
|
|
320
321
|
}
|
|
@@ -339,7 +340,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
339
340
|
if (variant === "indicator") {
|
|
340
341
|
return (_jsx("span", { className: "dc-citation-text", children: renderStatusIndicator() }));
|
|
341
342
|
}
|
|
342
|
-
// Text variant - no special styling, shows
|
|
343
|
+
// Text variant - no special styling, shows keySpan with indicator
|
|
343
344
|
if (variant === "text") {
|
|
344
345
|
return (_jsxs("span", { className: "dc-citation-text dc-citation-text--plain", children: [displayText, renderStatusIndicator()] }));
|
|
345
346
|
}
|
|
@@ -351,7 +352,7 @@ export const CitationComponent = forwardRef(({ citation, children, className, di
|
|
|
351
352
|
if (variant === "numeric") {
|
|
352
353
|
return (_jsxs("span", { className: "dc-citation-text", children: [displayText, renderStatusIndicator()] }));
|
|
353
354
|
}
|
|
354
|
-
// Brackets variant (default) -
|
|
355
|
+
// Brackets variant (default) - keySpan/number in brackets with styling
|
|
355
356
|
return (_jsxs("span", { className: "dc-citation-bracket", "aria-hidden": "true", role: "presentation", children: ["[", _jsxs("span", { className: "dc-citation-text", children: [displayText, renderStatusIndicator()] }), "]"] }));
|
|
356
357
|
};
|
|
357
358
|
// Determine if popover should be shown
|
|
@@ -55,12 +55,12 @@ export interface CitationNumberProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
55
55
|
}
|
|
56
56
|
/** Displays the citation number. */
|
|
57
57
|
export declare const CitationNumber: React.ForwardRefExoticComponent<CitationNumberProps & React.RefAttributes<HTMLSpanElement>>;
|
|
58
|
-
export interface
|
|
59
|
-
|
|
58
|
+
export interface CitationKeySpanProps extends HTMLAttributes<HTMLSpanElement> {
|
|
59
|
+
keySpan?: string;
|
|
60
60
|
separator?: string;
|
|
61
61
|
}
|
|
62
|
-
/** Displays the citation
|
|
63
|
-
export declare const
|
|
62
|
+
/** Displays the citation keySpan (summary text). */
|
|
63
|
+
export declare const CitationKeySpan: React.ForwardRefExoticComponent<CitationKeySpanProps & React.RefAttributes<HTMLSpanElement>>;
|
|
64
64
|
export interface CitationIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
65
65
|
verifiedIndicator?: ReactNode;
|
|
66
66
|
partialIndicator?: ReactNode;
|
|
@@ -95,7 +95,7 @@ export declare const Citation: {
|
|
|
95
95
|
readonly Trigger: React.ForwardRefExoticComponent<CitationTriggerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
96
96
|
readonly Bracket: React.ForwardRefExoticComponent<CitationBracketProps & React.RefAttributes<HTMLSpanElement>>;
|
|
97
97
|
readonly Number: React.ForwardRefExoticComponent<CitationNumberProps & React.RefAttributes<HTMLSpanElement>>;
|
|
98
|
-
readonly
|
|
98
|
+
readonly KeySpan: React.ForwardRefExoticComponent<CitationKeySpanProps & React.RefAttributes<HTMLSpanElement>>;
|
|
99
99
|
readonly Indicator: React.ForwardRefExoticComponent<CitationIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
100
100
|
readonly Status: typeof CitationStatusComponent;
|
|
101
101
|
readonly Phrase: React.ForwardRefExoticComponent<CitationPhraseProps & React.RefAttributes<HTMLSpanElement>>;
|
package/lib/react/primitives.js
CHANGED
|
@@ -114,21 +114,21 @@ export const CitationNumber = forwardRef(({ className, number, ...props }, ref)
|
|
|
114
114
|
return (_jsx("span", { ref: ref, className: classNames("citation-number", className), ...props, children: displayNumber }));
|
|
115
115
|
});
|
|
116
116
|
CitationNumber.displayName = "Citation.Number";
|
|
117
|
-
/** Displays the citation
|
|
118
|
-
export const
|
|
117
|
+
/** Displays the citation keySpan (summary text). */
|
|
118
|
+
export const CitationKeySpan = forwardRef(({ className, keySpan, separator = " ", ...props }, ref) => {
|
|
119
119
|
const { citation, config } = useCitationContext();
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
return
|
|
120
|
+
const displayKeySpan = useMemo(() => {
|
|
121
|
+
if (keySpan !== undefined)
|
|
122
|
+
return keySpan;
|
|
123
123
|
if (!config.displayKeySpan)
|
|
124
124
|
return "";
|
|
125
125
|
return citation.keySpan?.toString() || "";
|
|
126
|
-
}, [
|
|
127
|
-
if (!
|
|
126
|
+
}, [keySpan, citation, config]);
|
|
127
|
+
if (!displayKeySpan)
|
|
128
128
|
return null;
|
|
129
|
-
return (_jsxs("span", { ref: ref, className: classNames("citation-
|
|
129
|
+
return (_jsxs("span", { ref: ref, className: classNames("citation-key-span", className), ...props, children: [displayKeySpan, separator] }));
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
CitationKeySpan.displayName = "Citation.KeySpan";
|
|
132
132
|
/** Displays a status indicator based on citation verification state. */
|
|
133
133
|
export const CitationIndicator = forwardRef(({ className, verifiedIndicator = "✓", partialIndicator = "*", missIndicator = null, pendingIndicator = null, showFor, ...props }, ref) => {
|
|
134
134
|
const { status } = useCitationContext();
|
|
@@ -187,7 +187,7 @@ export const Citation = {
|
|
|
187
187
|
Trigger: CitationTrigger,
|
|
188
188
|
Bracket: CitationBracket,
|
|
189
189
|
Number: CitationNumber,
|
|
190
|
-
|
|
190
|
+
KeySpan: CitationKeySpan,
|
|
191
191
|
Indicator: CitationIndicator,
|
|
192
192
|
Status: CitationStatusComponent,
|
|
193
193
|
Phrase: CitationPhrase,
|
package/lib/react/types.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import type { SearchState } from "../types/search.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Available citation display variants.
|
|
6
6
|
*
|
|
7
|
-
* - `brackets`: Shows
|
|
7
|
+
* - `brackets`: Shows keySpan/number in brackets with blue text styling (default)
|
|
8
8
|
* - `numeric`: Shows citation number with indicator, no brackets
|
|
9
|
-
* - `text`: Shows the
|
|
9
|
+
* - `text`: Shows the keySpan, no text styling, no truncate, shows indicator
|
|
10
10
|
* - `minimal`: No brackets, just display text with indicator
|
|
11
11
|
* - `indicator`: Only the status indicator (checkmark/warning), no text
|
|
12
12
|
*/
|
|
@@ -89,9 +89,9 @@ export interface BaseCitationProps {
|
|
|
89
89
|
className?: string;
|
|
90
90
|
/** Class name for controlling inner content width */
|
|
91
91
|
innerWidthClassName?: string;
|
|
92
|
-
/** When true, displays
|
|
92
|
+
/** When true, displays keySpan/citationNumber merged in the bracket */
|
|
93
93
|
displayKeySpan?: boolean;
|
|
94
|
-
/** Fallback display text when citation
|
|
94
|
+
/** Fallback display text when citation keySpan is empty */
|
|
95
95
|
fallbackDisplay?: string | null;
|
|
96
96
|
/** Display variant for the citation */
|
|
97
97
|
variant?: CitationVariant;
|
|
@@ -164,7 +164,7 @@ export interface CitationRenderProps {
|
|
|
164
164
|
citationKey: string;
|
|
165
165
|
/** Display text for the citation */
|
|
166
166
|
displayText: string;
|
|
167
|
-
/** Whether this is a merged
|
|
167
|
+
/** Whether this is a merged keySpan display */
|
|
168
168
|
isMergedDisplay: boolean;
|
|
169
169
|
}
|
|
170
170
|
/**
|
package/lib/react/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha1Hash } from "../utils/sha.js";
|
|
2
|
-
import { getCitationPageNumber } from "
|
|
2
|
+
import { getCitationPageNumber } from "../parsing/normalizeCitation.js";
|
|
3
3
|
/**
|
|
4
4
|
* Generates a unique, deterministic key for a citation based on its content.
|
|
5
5
|
* Uses a hash of the citation's identifying properties.
|