@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/client/index.d.ts
CHANGED
|
@@ -1,2 +1,342 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Citation, Verification } from '../types/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the DeepCitation client
|
|
5
|
+
*/
|
|
6
|
+
interface DeepCitationConfig {
|
|
7
|
+
/** Your DeepCitation API key (starts with sk-dc-) */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Optional custom API base URL. Defaults to https://api.deepcitation.com */
|
|
10
|
+
apiUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Response from uploading a file for citation verification
|
|
14
|
+
*/
|
|
15
|
+
interface UploadFileResponse {
|
|
16
|
+
/** The attachment ID assigned by DeepCitation (custom or auto-generated) */
|
|
17
|
+
attachmentId: string;
|
|
18
|
+
/** The full text content formatted for LLM prompts with page markers and line IDs. Use this in your user prompts. */
|
|
19
|
+
deepTextPromptPortion: string;
|
|
20
|
+
/** Form fields extracted from PDF forms */
|
|
21
|
+
formFields?: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
value?: string;
|
|
24
|
+
pageIndex?: number;
|
|
25
|
+
type?: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** Metadata about the processed file */
|
|
28
|
+
metadata: {
|
|
29
|
+
filename: string;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
pageCount: number;
|
|
32
|
+
textByteSize: number;
|
|
33
|
+
};
|
|
34
|
+
/** Processing status */
|
|
35
|
+
status: "ready" | "error";
|
|
36
|
+
/** Time taken to process the file in milliseconds */
|
|
37
|
+
processingTimeMs?: number;
|
|
38
|
+
/** Error message if status is "error" */
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for file upload
|
|
43
|
+
*/
|
|
44
|
+
interface UploadFileOptions {
|
|
45
|
+
/** Optional custom attachment ID to use instead of auto-generated one */
|
|
46
|
+
attachmentId?: string;
|
|
47
|
+
/** Optional custom filename (uses File.name if not provided) */
|
|
48
|
+
filename?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Response from verifying citations
|
|
52
|
+
*/
|
|
53
|
+
interface VerifyCitationsResponse {
|
|
54
|
+
/** Map of citation keys to their verification results */
|
|
55
|
+
verifications: Record<string, Verification>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for citation verification
|
|
59
|
+
*/
|
|
60
|
+
interface VerifyCitationsOptions {
|
|
61
|
+
/** Output image format for verification screenshots */
|
|
62
|
+
outputImageFormat?: "jpeg" | "png" | "avif";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Simplified citation input for verification
|
|
66
|
+
*/
|
|
67
|
+
type CitationInput = Citation | Record<string, Citation>;
|
|
68
|
+
/**
|
|
69
|
+
* Input for file upload in prepareFiles
|
|
70
|
+
*/
|
|
71
|
+
interface FileInput {
|
|
72
|
+
/** The file content (File, Blob, or Buffer) */
|
|
73
|
+
file: File | Blob | Buffer;
|
|
74
|
+
/** Optional filename */
|
|
75
|
+
filename?: string;
|
|
76
|
+
/** Optional custom attachment ID */
|
|
77
|
+
attachmentId?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* File reference returned from prepareFiles
|
|
81
|
+
*/
|
|
82
|
+
interface FileDataPart {
|
|
83
|
+
/** The attachment ID assigned by DeepCitation */
|
|
84
|
+
attachmentId: string;
|
|
85
|
+
/** The formatted text content for LLM prompts (with page markers and line IDs) */
|
|
86
|
+
deepTextPromptPortion: string;
|
|
87
|
+
/** Optional filename for display purposes */
|
|
88
|
+
filename?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Result from prepareFiles
|
|
92
|
+
*/
|
|
93
|
+
interface PrepareFilesResult {
|
|
94
|
+
/** Array of file references for verification (includes deepTextPromptPortion for each file) */
|
|
95
|
+
fileDataParts: FileDataPart[];
|
|
96
|
+
/**
|
|
97
|
+
* Array of formatted text content for LLM prompts (with page markers and line IDs).
|
|
98
|
+
* @deprecated Use fileDataParts[].deepTextPromptPortion instead for single source of truth.
|
|
99
|
+
* This is kept for backwards compatibility but will be removed in a future version.
|
|
100
|
+
*/
|
|
101
|
+
deepTextPromptPortion: string[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Input for verifyCitationsFromLlmOutput
|
|
105
|
+
*/
|
|
106
|
+
interface VerifyCitationsFromLlmOutput {
|
|
107
|
+
/** The LLM response containing citations */
|
|
108
|
+
llmOutput: string;
|
|
109
|
+
/** Optional file references (required for Zero Data Retention or after storage expires) */
|
|
110
|
+
fileDataParts?: FileDataPart[];
|
|
111
|
+
/** Output image format for verification screenshots */
|
|
112
|
+
outputImageFormat?: "jpeg" | "png" | "avif";
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Input for convertFile - convert URL or Office file to PDF
|
|
116
|
+
*/
|
|
117
|
+
interface ConvertFileInput {
|
|
118
|
+
/** URL to convert to PDF (for web pages or direct PDF links) */
|
|
119
|
+
url?: string;
|
|
120
|
+
/** Office file to convert (doc, docx, xls, xlsx, ppt, pptx, odt, ods, odp) */
|
|
121
|
+
file?: File | Blob | Buffer;
|
|
122
|
+
/** Optional custom filename for the converted PDF */
|
|
123
|
+
filename?: string;
|
|
124
|
+
/** Optional custom attachment ID */
|
|
125
|
+
attachmentId?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Response from convertFile
|
|
129
|
+
*/
|
|
130
|
+
interface ConvertFileResponse {
|
|
131
|
+
/** The attachment ID assigned by DeepCitation. Pass this to prepareConvertedFile(). */
|
|
132
|
+
attachmentId: string;
|
|
133
|
+
/** Metadata about the conversion */
|
|
134
|
+
metadata: {
|
|
135
|
+
/** Original filename before conversion */
|
|
136
|
+
originalFilename: string;
|
|
137
|
+
/** Original MIME type before conversion */
|
|
138
|
+
originalMimeType: string;
|
|
139
|
+
/** MIME type after conversion (always application/pdf) */
|
|
140
|
+
convertedMimeType: string;
|
|
141
|
+
/** Time taken for conversion in milliseconds */
|
|
142
|
+
conversionTimeMs: number;
|
|
143
|
+
};
|
|
144
|
+
/** Conversion status */
|
|
145
|
+
status: "converted" | "error";
|
|
146
|
+
/** Error message if status is "error" */
|
|
147
|
+
error?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Options for processing a converted file
|
|
151
|
+
*/
|
|
152
|
+
interface PrepareConvertedFileOptions {
|
|
153
|
+
/** The attachment ID from a previous convertFile call */
|
|
154
|
+
attachmentId: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* DeepCitation client for file upload and citation verification.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* import { DeepCitation } from '@deepcitation/deepcitation-js';
|
|
163
|
+
*
|
|
164
|
+
* const dc = new DeepCitation({ apiKey: process.env.DEEPCITATION_API_KEY });
|
|
165
|
+
*
|
|
166
|
+
* // Upload a file
|
|
167
|
+
* const { attachmentId, promptContent } = await dc.uploadFile(file);
|
|
168
|
+
*
|
|
169
|
+
* // Include promptContent in your LLM messages
|
|
170
|
+
* const response = await llm.chat({
|
|
171
|
+
* messages: [
|
|
172
|
+
* { role: "system", content: wrapSystemCitationPrompt({ systemPrompt }) },
|
|
173
|
+
* { role: "user", content: userMessage + "\n\n" + promptContent },
|
|
174
|
+
* ]
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* // Verify citations in the LLM output
|
|
178
|
+
* const citations = getAllCitationsFromLlmOutput(response);
|
|
179
|
+
* const verified = await dc.verifyCitations(attachmentId, citations);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare class DeepCitation {
|
|
183
|
+
private readonly apiKey;
|
|
184
|
+
private readonly apiUrl;
|
|
185
|
+
/**
|
|
186
|
+
* Create a new DeepCitation client instance.
|
|
187
|
+
*
|
|
188
|
+
* @param config - Configuration options
|
|
189
|
+
* @throws Error if apiKey is not provided
|
|
190
|
+
*/
|
|
191
|
+
constructor(config: DeepCitationConfig);
|
|
192
|
+
/**
|
|
193
|
+
* Upload a file for citation verification.
|
|
194
|
+
*
|
|
195
|
+
* Supported file types:
|
|
196
|
+
* - PDF documents
|
|
197
|
+
* - Images (PNG, JPEG, WebP, AVIF, HEIC)
|
|
198
|
+
* - Coming soon: DOCX, XLSX, plain text
|
|
199
|
+
*
|
|
200
|
+
* @param file - The file to upload (File, Blob, or Buffer)
|
|
201
|
+
* @param options - Optional upload options
|
|
202
|
+
* @returns Upload response with attachmentId and extracted text
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* // Browser with File object
|
|
207
|
+
* const file = document.querySelector('input[type="file"]').files[0];
|
|
208
|
+
* const result = await dc.uploadFile(file);
|
|
209
|
+
*
|
|
210
|
+
* // Node.js with Buffer
|
|
211
|
+
* const buffer = fs.readFileSync('document.pdf');
|
|
212
|
+
* const result = await dc.uploadFile(buffer, { filename: 'document.pdf' });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
uploadFile(file: File | Blob | Buffer, options?: UploadFileOptions): Promise<UploadFileResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Convert a URL or Office file to PDF for citation verification.
|
|
218
|
+
* The converted file can then be processed with prepareConvertedFile().
|
|
219
|
+
*
|
|
220
|
+
* Supported Office formats:
|
|
221
|
+
* - Microsoft Word (.doc, .docx)
|
|
222
|
+
* - Microsoft Excel (.xls, .xlsx)
|
|
223
|
+
* - Microsoft PowerPoint (.ppt, .pptx)
|
|
224
|
+
* - OpenDocument (.odt, .ods, .odp)
|
|
225
|
+
* - Rich Text Format (.rtf)
|
|
226
|
+
* - CSV (.csv)
|
|
227
|
+
*
|
|
228
|
+
* @param input - URL string or object with URL/file options
|
|
229
|
+
* @returns Conversion result with attachmentId for prepareConvertedFile
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // Convert a URL to PDF
|
|
234
|
+
* const result = await dc.convertToPdf({ url: "https://example.com/article" });
|
|
235
|
+
*
|
|
236
|
+
* // Convert an Office document
|
|
237
|
+
* const result = await dc.convertToPdf({
|
|
238
|
+
* file: docxBuffer,
|
|
239
|
+
* filename: "report.docx"
|
|
240
|
+
* });
|
|
241
|
+
*
|
|
242
|
+
* // Then prepare the file for verification
|
|
243
|
+
* const { deepTextPromptPortion, attachmentId } = await dc.prepareConvertedFile({
|
|
244
|
+
* attachmentId: result.attachmentId
|
|
245
|
+
* });
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
convertToPdf(input: ConvertFileInput | string): Promise<ConvertFileResponse>;
|
|
249
|
+
/**
|
|
250
|
+
* Prepare a previously converted file for citation verification.
|
|
251
|
+
* Use this after calling convertToPdf() to extract text and get deepTextPromptPortion.
|
|
252
|
+
*
|
|
253
|
+
* @param options - Options with attachmentId from convertFile
|
|
254
|
+
* @returns Upload response with attachmentId and extracted text
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* // First convert the file
|
|
259
|
+
* const converted = await dc.convertToPdf({ url: "https://example.com/article" });
|
|
260
|
+
*
|
|
261
|
+
* // Then prepare it for verification
|
|
262
|
+
* const { deepTextPromptPortion, attachmentId } = await dc.prepareConvertedFile({
|
|
263
|
+
* attachmentId: converted.attachmentId
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* // Use deepTextPromptPortion in your LLM prompt...
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
prepareConvertedFile(options: PrepareConvertedFileOptions): Promise<UploadFileResponse>;
|
|
270
|
+
/**
|
|
271
|
+
* Upload multiple files for citation verification and get structured content.
|
|
272
|
+
* This is the recommended way to prepare files for LLM prompts.
|
|
273
|
+
*
|
|
274
|
+
* @param files - Array of files to upload with optional filenames and attachmentIds
|
|
275
|
+
* @returns Object containing fileDataParts for verification and deepTextPromptPortion for LLM
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* const { fileDataParts, deepTextPromptPortion } = await dc.prepareFiles([
|
|
280
|
+
* { file: pdfBuffer, filename: "report.pdf" },
|
|
281
|
+
* { file: invoiceBuffer, filename: "invoice.pdf" },
|
|
282
|
+
* ]);
|
|
283
|
+
*
|
|
284
|
+
* // Use deepTextPromptPortion in wrapCitationPrompt
|
|
285
|
+
* const { enhancedSystemPrompt, enhancedUserPrompt } = wrapCitationPrompt({
|
|
286
|
+
* systemPrompt,
|
|
287
|
+
* userPrompt,
|
|
288
|
+
* deepTextPromptPortion
|
|
289
|
+
* });
|
|
290
|
+
*
|
|
291
|
+
* // Use fileDataParts later for verification
|
|
292
|
+
* const result = await dc.verifyCitationsFromLlmOutput({ llmOutput, fileDataParts });
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
prepareFiles(files: FileInput[]): Promise<PrepareFilesResult>;
|
|
296
|
+
/**
|
|
297
|
+
* Verify citations against a previously uploaded file.
|
|
298
|
+
*
|
|
299
|
+
* @param attachmentId - The attachment ID returned from uploadFile
|
|
300
|
+
* @param citations - Citations to verify (from getAllCitationsFromLlmOutput)
|
|
301
|
+
* @param options - Optional verification options
|
|
302
|
+
* @returns Verification results with status and proof images
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```typescript
|
|
306
|
+
* import { getAllCitationsFromLlmOutput } from '@deepcitation/deepcitation-js';
|
|
307
|
+
*
|
|
308
|
+
* const citations = getAllCitationsFromLlmOutput(llmResponse);
|
|
309
|
+
* const verified = await dc.verifyCitations(attachmentId, citations);
|
|
310
|
+
*
|
|
311
|
+
* for (const [key, result] of Object.entries(verified.verifications)) {
|
|
312
|
+
* console.log(key, result.searchState?.status);
|
|
313
|
+
* // "found", "partial_text_found", "not_found", etc.
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
verifyCitations(attachmentId: string, citations: CitationInput, options?: VerifyCitationsOptions): Promise<VerifyCitationsResponse>;
|
|
318
|
+
/**
|
|
319
|
+
* Verify citations from LLM output with automatic parsing.
|
|
320
|
+
* This is the recommended way to verify citations for new integrations.
|
|
321
|
+
*
|
|
322
|
+
* @param input - Object containing llmOutput and optional fileDataParts
|
|
323
|
+
* @returns Verification results with status and proof images
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const result = await dc.verifyCitationsFromLlmOutput({
|
|
328
|
+
* llmOutput: response.content,
|
|
329
|
+
* fileDataParts, // From prepareFiles()
|
|
330
|
+
* });
|
|
331
|
+
*
|
|
332
|
+
* for (const [key, result] of Object.entries(result.verifications)) {
|
|
333
|
+
* console.log(key, result.searchState?.status);
|
|
334
|
+
* }
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
verifyCitationsFromLlmOutput(input: VerifyCitationsFromLlmOutput, citations?: {
|
|
338
|
+
[key: string]: Citation;
|
|
339
|
+
}): Promise<VerifyCitationsResponse>;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export { type CitationInput, type ConvertFileInput, type ConvertFileResponse, DeepCitation, type DeepCitationConfig, type FileDataPart, type FileInput, type PrepareConvertedFileOptions, type PrepareFilesResult, type UploadFileOptions, type UploadFileResponse, type VerifyCitationsFromLlmOutput, type VerifyCitationsOptions, type VerifyCitationsResponse };
|
package/lib/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{f as DeepCitation}from'../chunk-RCHWBA6D.js';import'../chunk-QGXCOW3E.js';import'../chunk-O2XFH626.js';
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkLSKISWWH_cjs=require('./chunk-LSKISWWH.cjs'),chunk4FGOHQFP_cjs=require('./chunk-4FGOHQFP.cjs'),chunkCFXDRAJL_cjs=require('./chunk-CFXDRAJL.cjs'),chunk3GR7VKUJ_cjs=require('./chunk-3GR7VKUJ.cjs');require('./chunk-F2MMVEVC.cjs');var H=t=>{if(!t)return false;let e=t.trim();if(e.length<64)return false;let a=e?.[0];for(let n=1;n<e.length;n++)if(e[n]!==a)return false;return true};function Y(t){t=t.trim();let e=2,a=10,n=/[.?!](?=\s+|$)/g,m,r=[];for(;(m=n.exec(t))!==null;)r.push(m.index);if(r.length<2)return t;let I=r[r.length-1],N=r[r.length-2],o=t.substring(N+1,I+1),p=o.length;if(o.trim().slice(0,-1).length<a||p<=0||t.length<p*e)return t;let c=0,s=I+1;t.endsWith(o)&&(s=t.length);let f=-1;for(;;){let i=s-p;if(i<0)break;if(t.substring(i,s)===o)c++,f=i,s=i;else break}return c>=e?t.substring(0,f)+o:t}Object.defineProperty(exports,"DeepCitation",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.f}});Object.defineProperty(exports,"getAllCitationsFromLlmOutput",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.c}});Object.defineProperty(exports,"getCitationStatus",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.a}});Object.defineProperty(exports,"groupCitationsByAttachmentId",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.d}});Object.defineProperty(exports,"groupCitationsByAttachmentIdObject",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.e}});Object.defineProperty(exports,"parseCitation",{enumerable:true,get:function(){return chunkLSKISWWH_cjs.b}});Object.defineProperty(exports,"AV_CITATION_MARKDOWN_SYNTAX_PROMPT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.b}});Object.defineProperty(exports,"CITATION_AV_BASED_JSON_OUTPUT_FORMAT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.h}});Object.defineProperty(exports,"CITATION_AV_REMINDER",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.d}});Object.defineProperty(exports,"CITATION_JSON_OUTPUT_FORMAT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.g}});Object.defineProperty(exports,"CITATION_MARKDOWN_SYNTAX_PROMPT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.a}});Object.defineProperty(exports,"CITATION_REMINDER",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.c}});Object.defineProperty(exports,"compressPromptIds",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.i}});Object.defineProperty(exports,"decompressPromptIds",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.j}});Object.defineProperty(exports,"wrapCitationPrompt",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.f}});Object.defineProperty(exports,"wrapSystemCitationPrompt",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.e}});Object.defineProperty(exports,"BLANK_VERIFICATION",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.d}});Object.defineProperty(exports,"DEFAULT_OUTPUT_IMAGE_FORMAT",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.a}});Object.defineProperty(exports,"NOT_FOUND_VERIFICATION_INDEX",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.b}});Object.defineProperty(exports,"PENDING_VERIFICATION_INDEX",{enumerable:true,get:function(){return chunkCFXDRAJL_cjs.c}});Object.defineProperty(exports,"CITATION_X_PADDING",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.o}});Object.defineProperty(exports,"CITATION_Y_PADDING",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.p}});Object.defineProperty(exports,"generateCitationInstanceId",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.j}});Object.defineProperty(exports,"generateCitationKey",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.h}});Object.defineProperty(exports,"generateVerificationKey",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.i}});Object.defineProperty(exports,"getCitationPageNumber",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.d}});Object.defineProperty(exports,"normalizeCitations",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.e}});Object.defineProperty(exports,"removeCitations",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.a}});Object.defineProperty(exports,"removeLineIdMetadata",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.c}});Object.defineProperty(exports,"removePageNumberMetadata",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.b}});Object.defineProperty(exports,"sha1Hash",{enumerable:true,get:function(){return chunk3GR7VKUJ_cjs.f}});exports.cleanRepeatingLastSentence=Y;exports.isGeminiGarbage=H;
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export { CitationInput, DeepCitation, DeepCitationConfig, FileDataPart, FileInput, PrepareFilesResult, UploadFileOptions, UploadFileResponse, VerifyCitationsFromLlmOutput, VerifyCitationsOptions, VerifyCitationsResponse } from './client/index.cjs';
|
|
2
|
+
import { Citation, Verification, CitationStatus } from './types/index.cjs';
|
|
3
|
+
export { BLANK_VERIFICATION, DEFAULT_OUTPUT_IMAGE_FORMAT, IVertex, NOT_FOUND_VERIFICATION_INDEX, OutputImageFormat, PENDING_VERIFICATION_INDEX, PdfSpaceItem, ScreenBox, SearchAttempt, SearchMethod, SearchStatus, VerifyCitationRequest, VerifyCitationResponse } from './types/index.cjs';
|
|
4
|
+
export { C as CITATION_X_PADDING, c as CITATION_Y_PADDING, b as generateCitationInstanceId, g as generateCitationKey, a as generateVerificationKey } from './utils-CSqRI6NU.cjs';
|
|
5
|
+
export { AV_CITATION_MARKDOWN_SYNTAX_PROMPT, CITATION_AV_BASED_JSON_OUTPUT_FORMAT, CITATION_AV_REMINDER, CITATION_JSON_OUTPUT_FORMAT, CITATION_MARKDOWN_SYNTAX_PROMPT, CITATION_REMINDER, CompressedResult, WrapCitationPromptOptions, WrapCitationPromptResult, WrapSystemPromptOptions, compressPromptIds, decompressPromptIds, wrapCitationPrompt, wrapSystemCitationPrompt } from './prompts/index.cjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the verification status of a citation based on the found highlight and search state.
|
|
9
|
+
*
|
|
10
|
+
* @param verification - The found highlight location, or null/undefined if not found
|
|
11
|
+
* @returns An object containing boolean flags for verification status
|
|
12
|
+
*/
|
|
13
|
+
declare function getCitationStatus(verification: Verification | null | undefined): CitationStatus;
|
|
14
|
+
declare const parseCitation: (fragment: string, mdAttachmentId?: string | null, citationCounterRef?: any | null, isVerbose?: boolean) => {
|
|
15
|
+
beforeCite: string;
|
|
16
|
+
afterCite: string;
|
|
17
|
+
citation: Citation;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Extracts all citations from LLM output.
|
|
21
|
+
* Supports both XML <cite ... /> tags (embedded in strings/markdown) and JSON-based citation formats.
|
|
22
|
+
*
|
|
23
|
+
* For object input:
|
|
24
|
+
* - Traverses the object looking for `citation` or `citations` properties matching JSON format
|
|
25
|
+
* - Also stringifies the object to find embedded XML citations in markdown content
|
|
26
|
+
*
|
|
27
|
+
* @param llmOutput - The LLM output (string or object)
|
|
28
|
+
* @returns Dictionary of parsed Citation objects keyed by citation key
|
|
29
|
+
*/
|
|
30
|
+
declare const getAllCitationsFromLlmOutput: (llmOutput: any) => {
|
|
31
|
+
[key: string]: Citation;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Groups citations by their attachmentId for multi-file verification scenarios.
|
|
35
|
+
* This is useful when you have citations from multiple files and need to
|
|
36
|
+
* verify them against their respective source documents.
|
|
37
|
+
*
|
|
38
|
+
* @param citations - Array of Citation objects or a dictionary of citations
|
|
39
|
+
* @returns Map of attachmentId to dictionary of citations from that file
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const citations = getAllCitationsFromLlmOutput(response.content);
|
|
44
|
+
* const citationsByAttachment = groupCitationsByAttachmentId(citations);
|
|
45
|
+
*
|
|
46
|
+
* // Verify citations for each file
|
|
47
|
+
* for (const [attachmentId, fileCitations] of citationsByAttachment) {
|
|
48
|
+
* const verified = await dc.verifyCitations(attachmentId, fileCitations);
|
|
49
|
+
* // Process verification results...
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function groupCitationsByAttachmentId(citations: Citation[] | {
|
|
54
|
+
[key: string]: Citation;
|
|
55
|
+
}): Map<string, {
|
|
56
|
+
[key: string]: Citation;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Groups citations by their attachmentId and returns as a plain object.
|
|
60
|
+
* Alternative to groupCitationsByAttachmentId that returns a plain object instead of a Map.
|
|
61
|
+
*
|
|
62
|
+
* @param citations - Array of Citation objects or a dictionary of citations
|
|
63
|
+
* @returns Object with attachmentId keys mapping to citation dictionaries
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const citations = getAllCitationsFromLlmOutput(response.content);
|
|
68
|
+
* const citationsByAttachment = groupCitationsByAttachmentIdObject(citations);
|
|
69
|
+
*
|
|
70
|
+
* // Verify citations for each file using Promise.all
|
|
71
|
+
* const verificationPromises = Object.entries(citationsByAttachment).map(
|
|
72
|
+
* ([attachmentId, fileCitations]) => dc.verifyCitations(attachmentId, fileCitations)
|
|
73
|
+
* );
|
|
74
|
+
* const results = await Promise.all(verificationPromises);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function groupCitationsByAttachmentIdObject(citations: Citation[] | {
|
|
78
|
+
[key: string]: Citation;
|
|
79
|
+
}): {
|
|
80
|
+
[attachmentId: string]: {
|
|
81
|
+
[key: string]: Citation;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
declare const removeCitations: (pageText: string, leaveKeySpanBehind?: boolean) => string;
|
|
86
|
+
declare const removePageNumberMetadata: (pageText: string) => string;
|
|
87
|
+
declare const removeLineIdMetadata: (pageText: string) => string;
|
|
88
|
+
declare const getCitationPageNumber: (startPageKey?: string | null) => number | null;
|
|
89
|
+
declare const normalizeCitations: (response: string) => string;
|
|
90
|
+
|
|
91
|
+
declare const isGeminiGarbage: (content: string) => boolean;
|
|
92
|
+
declare function cleanRepeatingLastSentence(text: string): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Pure JavaScript SHA-1 implementation.
|
|
96
|
+
* Based on the FIPS 180-4 specification.
|
|
97
|
+
* No external dependencies.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Computes a SHA-1 hash of the provided data.
|
|
101
|
+
* Used internally by generateCitationKey in react/utils.ts
|
|
102
|
+
*/
|
|
103
|
+
declare function sha1Hash(data: string | any): string;
|
|
104
|
+
|
|
105
|
+
export { Citation, CitationStatus, Verification, cleanRepeatingLastSentence, getAllCitationsFromLlmOutput, getCitationPageNumber, getCitationStatus, groupCitationsByAttachmentId, groupCitationsByAttachmentIdObject, isGeminiGarbage, normalizeCitations, parseCitation, removeCitations, removeLineIdMetadata, removePageNumberMetadata, sha1Hash };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,23 +1,105 @@
|
|
|
1
|
+
export { CitationInput, DeepCitation, DeepCitationConfig, FileDataPart, FileInput, PrepareFilesResult, UploadFileOptions, UploadFileResponse, VerifyCitationsFromLlmOutput, VerifyCitationsOptions, VerifyCitationsResponse } from './client/index.js';
|
|
2
|
+
import { Citation, Verification, CitationStatus } from './types/index.js';
|
|
3
|
+
export { BLANK_VERIFICATION, DEFAULT_OUTPUT_IMAGE_FORMAT, IVertex, NOT_FOUND_VERIFICATION_INDEX, OutputImageFormat, PENDING_VERIFICATION_INDEX, PdfSpaceItem, ScreenBox, SearchAttempt, SearchMethod, SearchStatus, VerifyCitationRequest, VerifyCitationResponse } from './types/index.js';
|
|
4
|
+
export { C as CITATION_X_PADDING, c as CITATION_Y_PADDING, b as generateCitationInstanceId, g as generateCitationKey, a as generateVerificationKey } from './utils-D_wxy_ni.js';
|
|
5
|
+
export { AV_CITATION_MARKDOWN_SYNTAX_PROMPT, CITATION_AV_BASED_JSON_OUTPUT_FORMAT, CITATION_AV_REMINDER, CITATION_JSON_OUTPUT_FORMAT, CITATION_MARKDOWN_SYNTAX_PROMPT, CITATION_REMINDER, CompressedResult, WrapCitationPromptOptions, WrapCitationPromptResult, WrapSystemPromptOptions, compressPromptIds, decompressPromptIds, wrapCitationPrompt, wrapSystemCitationPrompt } from './prompts/index.js';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
8
|
+
* Calculates the verification status of a citation based on the found highlight and search state.
|
|
9
|
+
*
|
|
10
|
+
* @param verification - The found highlight location, or null/undefined if not found
|
|
11
|
+
* @returns An object containing boolean flags for verification status
|
|
4
12
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
declare function getCitationStatus(verification: Verification | null | undefined): CitationStatus;
|
|
14
|
+
declare const parseCitation: (fragment: string, mdAttachmentId?: string | null, citationCounterRef?: any | null, isVerbose?: boolean) => {
|
|
15
|
+
beforeCite: string;
|
|
16
|
+
afterCite: string;
|
|
17
|
+
citation: Citation;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Extracts all citations from LLM output.
|
|
21
|
+
* Supports both XML <cite ... /> tags (embedded in strings/markdown) and JSON-based citation formats.
|
|
22
|
+
*
|
|
23
|
+
* For object input:
|
|
24
|
+
* - Traverses the object looking for `citation` or `citations` properties matching JSON format
|
|
25
|
+
* - Also stringifies the object to find embedded XML citations in markdown content
|
|
26
|
+
*
|
|
27
|
+
* @param llmOutput - The LLM output (string or object)
|
|
28
|
+
* @returns Dictionary of parsed Citation objects keyed by citation key
|
|
29
|
+
*/
|
|
30
|
+
declare const getAllCitationsFromLlmOutput: (llmOutput: any) => {
|
|
31
|
+
[key: string]: Citation;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Groups citations by their attachmentId for multi-file verification scenarios.
|
|
35
|
+
* This is useful when you have citations from multiple files and need to
|
|
36
|
+
* verify them against their respective source documents.
|
|
37
|
+
*
|
|
38
|
+
* @param citations - Array of Citation objects or a dictionary of citations
|
|
39
|
+
* @returns Map of attachmentId to dictionary of citations from that file
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const citations = getAllCitationsFromLlmOutput(response.content);
|
|
44
|
+
* const citationsByAttachment = groupCitationsByAttachmentId(citations);
|
|
45
|
+
*
|
|
46
|
+
* // Verify citations for each file
|
|
47
|
+
* for (const [attachmentId, fileCitations] of citationsByAttachment) {
|
|
48
|
+
* const verified = await dc.verifyCitations(attachmentId, fileCitations);
|
|
49
|
+
* // Process verification results...
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function groupCitationsByAttachmentId(citations: Citation[] | {
|
|
54
|
+
[key: string]: Citation;
|
|
55
|
+
}): Map<string, {
|
|
56
|
+
[key: string]: Citation;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Groups citations by their attachmentId and returns as a plain object.
|
|
60
|
+
* Alternative to groupCitationsByAttachmentId that returns a plain object instead of a Map.
|
|
61
|
+
*
|
|
62
|
+
* @param citations - Array of Citation objects or a dictionary of citations
|
|
63
|
+
* @returns Object with attachmentId keys mapping to citation dictionaries
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const citations = getAllCitationsFromLlmOutput(response.content);
|
|
68
|
+
* const citationsByAttachment = groupCitationsByAttachmentIdObject(citations);
|
|
69
|
+
*
|
|
70
|
+
* // Verify citations for each file using Promise.all
|
|
71
|
+
* const verificationPromises = Object.entries(citationsByAttachment).map(
|
|
72
|
+
* ([attachmentId, fileCitations]) => dc.verifyCitations(attachmentId, fileCitations)
|
|
73
|
+
* );
|
|
74
|
+
* const results = await Promise.all(verificationPromises);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function groupCitationsByAttachmentIdObject(citations: Citation[] | {
|
|
78
|
+
[key: string]: Citation;
|
|
79
|
+
}): {
|
|
80
|
+
[attachmentId: string]: {
|
|
81
|
+
[key: string]: Citation;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
declare const removeCitations: (pageText: string, leaveKeySpanBehind?: boolean) => string;
|
|
86
|
+
declare const removePageNumberMetadata: (pageText: string) => string;
|
|
87
|
+
declare const removeLineIdMetadata: (pageText: string) => string;
|
|
88
|
+
declare const getCitationPageNumber: (startPageKey?: string | null) => number | null;
|
|
89
|
+
declare const normalizeCitations: (response: string) => string;
|
|
90
|
+
|
|
91
|
+
declare const isGeminiGarbage: (content: string) => boolean;
|
|
92
|
+
declare function cleanRepeatingLastSentence(text: string): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Pure JavaScript SHA-1 implementation.
|
|
96
|
+
* Based on the FIPS 180-4 specification.
|
|
97
|
+
* No external dependencies.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Computes a SHA-1 hash of the provided data.
|
|
101
|
+
* Used internally by generateCitationKey in react/utils.ts
|
|
102
|
+
*/
|
|
103
|
+
declare function sha1Hash(data: string | any): string;
|
|
104
|
+
|
|
105
|
+
export { Citation, CitationStatus, Verification, cleanRepeatingLastSentence, getAllCitationsFromLlmOutput, getCitationPageNumber, getCitationStatus, groupCitationsByAttachmentId, groupCitationsByAttachmentIdObject, isGeminiGarbage, normalizeCitations, parseCitation, removeCitations, removeLineIdMetadata, removePageNumberMetadata, sha1Hash };
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* DeepCitation - Citation parsing, verification, and rendering library
|
|
3
|
-
* @packageDocumentation
|
|
4
|
-
*/
|
|
5
|
-
// Client
|
|
6
|
-
export { DeepCitation } from "./client/index.js";
|
|
7
|
-
// Parsing
|
|
8
|
-
export { parseCitation, getCitationStatus, getAllCitationsFromLlmOutput, groupCitationsByAttachmentId, groupCitationsByAttachmentIdObject, } from "./parsing/parseCitation.js";
|
|
9
|
-
export { normalizeCitations, getCitationPageNumber, } from "./parsing/normalizeCitation.js";
|
|
10
|
-
export { isGeminiGarbage, cleanRepeatingLastSentence, } from "./parsing/parseWorkAround.js";
|
|
11
|
-
export { DEFAULT_OUTPUT_IMAGE_FORMAT } from "./types/citation.js";
|
|
12
|
-
export { NOT_FOUND_VERIFICATION_INDEX, PENDING_VERIFICATION_INDEX, BLANK_VERIFICATION, } from "./types/verification.js";
|
|
13
|
-
// Utilities
|
|
14
|
-
export { sha1Hash } from "./utils/sha.js";
|
|
15
|
-
export { generateCitationKey, generateVerificationKey, generateCitationInstanceId, } from "./react/utils.js";
|
|
16
|
-
export { CITATION_X_PADDING, CITATION_Y_PADDING } from "./react/utils.js";
|
|
17
|
-
// Prompts
|
|
18
|
-
export { CITATION_JSON_OUTPUT_FORMAT, CITATION_MARKDOWN_SYNTAX_PROMPT, AV_CITATION_MARKDOWN_SYNTAX_PROMPT, CITATION_AV_BASED_JSON_OUTPUT_FORMAT, wrapSystemCitationPrompt, wrapCitationPrompt, } from "./prompts/citationPrompts.js";
|
|
19
|
-
export { removeLineIdMetadata, removePageNumberMetadata, removeCitations, } from "./parsing/normalizeCitation.js";
|
|
20
|
-
export { compressPromptIds, decompressPromptIds, } from "./prompts/promptCompression.js";
|
|
1
|
+
export{f as DeepCitation,c as getAllCitationsFromLlmOutput,a as getCitationStatus,d as groupCitationsByAttachmentId,e as groupCitationsByAttachmentIdObject,b as parseCitation}from'./chunk-RCHWBA6D.js';export{b as AV_CITATION_MARKDOWN_SYNTAX_PROMPT,h as CITATION_AV_BASED_JSON_OUTPUT_FORMAT,d as CITATION_AV_REMINDER,g as CITATION_JSON_OUTPUT_FORMAT,a as CITATION_MARKDOWN_SYNTAX_PROMPT,c as CITATION_REMINDER,i as compressPromptIds,j as decompressPromptIds,f as wrapCitationPrompt,e as wrapSystemCitationPrompt}from'./chunk-2IZXUOQR.js';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';export{o as CITATION_X_PADDING,p as CITATION_Y_PADDING,j as generateCitationInstanceId,h as generateCitationKey,i as generateVerificationKey,d as getCitationPageNumber,e as normalizeCitations,a as removeCitations,c as removeLineIdMetadata,b as removePageNumberMetadata,f as sha1Hash}from'./chunk-QGXCOW3E.js';import'./chunk-O2XFH626.js';var H=t=>{if(!t)return false;let e=t.trim();if(e.length<64)return false;let a=e?.[0];for(let n=1;n<e.length;n++)if(e[n]!==a)return false;return true};function Y(t){t=t.trim();let e=2,a=10,n=/[.?!](?=\s+|$)/g,m,r=[];for(;(m=n.exec(t))!==null;)r.push(m.index);if(r.length<2)return t;let I=r[r.length-1],N=r[r.length-2],o=t.substring(N+1,I+1),p=o.length;if(o.trim().slice(0,-1).length<a||p<=0||t.length<p*e)return t;let c=0,s=I+1;t.endsWith(o)&&(s=t.length);let f=-1;for(;;){let i=s-p;if(i<0)break;if(t.substring(i,s)===o)c++,f=i,s=i;else break}return c>=e?t.substring(0,f)+o:t}export{Y as cleanRepeatingLastSentence,H as isGeminiGarbage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk4FGOHQFP_cjs=require('../chunk-4FGOHQFP.cjs');require('../chunk-F2MMVEVC.cjs');Object.defineProperty(exports,"AV_CITATION_MARKDOWN_SYNTAX_PROMPT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.b}});Object.defineProperty(exports,"CITATION_AV_BASED_JSON_OUTPUT_FORMAT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.h}});Object.defineProperty(exports,"CITATION_AV_REMINDER",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.d}});Object.defineProperty(exports,"CITATION_JSON_OUTPUT_FORMAT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.g}});Object.defineProperty(exports,"CITATION_MARKDOWN_SYNTAX_PROMPT",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.a}});Object.defineProperty(exports,"CITATION_REMINDER",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.c}});Object.defineProperty(exports,"compressPromptIds",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.i}});Object.defineProperty(exports,"decompressPromptIds",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.j}});Object.defineProperty(exports,"wrapCitationPrompt",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.f}});Object.defineProperty(exports,"wrapSystemCitationPrompt",{enumerable:true,get:function(){return chunk4FGOHQFP_cjs.e}});
|