@ontos-ai/knowhere-sdk 0.10.0 → 2.0.0
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/README.md +21 -4
- package/dist/index.d.mts +56 -16
- package/dist/index.d.ts +56 -16
- package/dist/index.js +64 -12
- package/dist/index.mjs +64 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ const result = await client.parse({
|
|
|
46
46
|
console.log(`Found ${result.textChunks.length} text chunks`);
|
|
47
47
|
console.log(`Found ${result.imageChunks.length} images`);
|
|
48
48
|
console.log(`Found ${result.tableChunks.length} tables`);
|
|
49
|
+
console.log(`Found ${result.pageChunks.length} page chunks`);
|
|
49
50
|
|
|
50
51
|
// Work with chunks — worker metadata is in chunk.metadata
|
|
51
52
|
result.textChunks.forEach((chunk) => {
|
|
@@ -54,6 +55,12 @@ result.textChunks.forEach((chunk) => {
|
|
|
54
55
|
console.log(chunk.metadata.summary);
|
|
55
56
|
});
|
|
56
57
|
|
|
58
|
+
result.pageChunks.forEach((chunk) => {
|
|
59
|
+
console.log(chunk.contentSource); // "summary"
|
|
60
|
+
console.log(chunk.content); // page-level summary
|
|
61
|
+
console.log(chunk.metadata.pageNums); // citation pages
|
|
62
|
+
});
|
|
63
|
+
|
|
57
64
|
// Save results to disk
|
|
58
65
|
await result.save('./output/');
|
|
59
66
|
```
|
|
@@ -200,6 +207,7 @@ console.log(documentId);
|
|
|
200
207
|
const response = await client.retrieval.query({
|
|
201
208
|
namespace: 'support-center',
|
|
202
209
|
query: 'How do I reset Bluetooth pairing?',
|
|
210
|
+
chunkTypes: ['page'],
|
|
203
211
|
topK: 5,
|
|
204
212
|
useAgentic: true,
|
|
205
213
|
});
|
|
@@ -212,7 +220,9 @@ console.log(response.failureReason); // no-answer reason, when returned
|
|
|
212
220
|
|
|
213
221
|
for (const result of response.results) {
|
|
214
222
|
console.log(result.content);
|
|
223
|
+
console.log(result.contentSource);
|
|
215
224
|
console.log(result.score);
|
|
225
|
+
console.log(result.metadata?.pageNums);
|
|
216
226
|
console.log(result.source.sourceFileName, result.source.sectionPath);
|
|
217
227
|
}
|
|
218
228
|
```
|
|
@@ -221,9 +231,12 @@ Retrieval results use one canonical source object:
|
|
|
221
231
|
|
|
222
232
|
```typescript
|
|
223
233
|
result.content;
|
|
234
|
+
result.chunkId;
|
|
224
235
|
result.chunkType;
|
|
236
|
+
result.contentSource;
|
|
225
237
|
result.score;
|
|
226
238
|
result.assetUrl;
|
|
239
|
+
result.metadata;
|
|
227
240
|
result.source.documentId;
|
|
228
241
|
result.source.sourceFileName;
|
|
229
242
|
result.source.sectionPath;
|
|
@@ -237,10 +250,12 @@ const reference = response.referencedChunks[0];
|
|
|
237
250
|
reference.chunkId;
|
|
238
251
|
reference.documentId;
|
|
239
252
|
reference.chunkType;
|
|
253
|
+
reference.contentSource;
|
|
240
254
|
reference.sectionPath;
|
|
241
255
|
reference.filePath;
|
|
242
256
|
reference.jobId;
|
|
243
257
|
reference.assetUrl;
|
|
258
|
+
reference.metadata;
|
|
244
259
|
```
|
|
245
260
|
|
|
246
261
|
Use `documentId` to update or archive a document:
|
|
@@ -261,7 +276,7 @@ const document = await client.documents.get(documentId);
|
|
|
261
276
|
const chunks = await client.documents.listChunks(documentId, {
|
|
262
277
|
page: 1,
|
|
263
278
|
pageSize: 50,
|
|
264
|
-
chunkType: '
|
|
279
|
+
chunkType: 'page',
|
|
265
280
|
includeAssetUrls: true,
|
|
266
281
|
});
|
|
267
282
|
const archived = await client.documents.archive(documentId);
|
|
@@ -275,6 +290,8 @@ if (chunks.chunks[0]) {
|
|
|
275
290
|
includeAssetUrls: true,
|
|
276
291
|
});
|
|
277
292
|
console.log(chunk.chunk.content);
|
|
293
|
+
console.log(chunk.chunk.contentSource);
|
|
294
|
+
console.log(chunk.chunk.metadata.pageNums);
|
|
278
295
|
console.log(chunk.chunk.assetUrl);
|
|
279
296
|
}
|
|
280
297
|
console.log(archived.status);
|
|
@@ -289,7 +306,7 @@ tools over that cached copy. This is the implementation used by the separate
|
|
|
289
306
|
```typescript
|
|
290
307
|
const parsed = await client.knowledge.parse({
|
|
291
308
|
file: './manual.pdf',
|
|
292
|
-
localDocumentId: 'manual
|
|
309
|
+
localDocumentId: 'manual',
|
|
293
310
|
});
|
|
294
311
|
|
|
295
312
|
const outline = await client.knowledge.getDocumentOutline(parsed.document.localDocumentId);
|
|
@@ -339,7 +356,7 @@ const remoteOutline = await client.knowledge.getDocumentOutline({
|
|
|
339
356
|
|
|
340
357
|
const jobRead = await client.knowledge.readChunks({
|
|
341
358
|
jobId: jobResult.jobId,
|
|
342
|
-
localDocumentId: 'manual
|
|
359
|
+
localDocumentId: 'manual',
|
|
343
360
|
limit: 5,
|
|
344
361
|
});
|
|
345
362
|
```
|
|
@@ -354,7 +371,7 @@ job completes:
|
|
|
354
371
|
```typescript
|
|
355
372
|
const started = await client.knowledge.startParse({
|
|
356
373
|
file: './manual.pdf',
|
|
357
|
-
localDocumentId: 'manual
|
|
374
|
+
localDocumentId: 'manual',
|
|
358
375
|
});
|
|
359
376
|
|
|
360
377
|
const status = await client.knowledge.getJobStatus(started.job.jobId);
|
package/dist/index.d.mts
CHANGED
|
@@ -300,6 +300,8 @@ interface Statistics {
|
|
|
300
300
|
imageChunks: number;
|
|
301
301
|
/** Number of table chunks */
|
|
302
302
|
tableChunks: number;
|
|
303
|
+
/** Number of page chunks */
|
|
304
|
+
pageChunks?: number;
|
|
303
305
|
/** Total number of pages (if applicable) */
|
|
304
306
|
totalPages?: number;
|
|
305
307
|
}
|
|
@@ -417,6 +419,7 @@ interface DocNav {
|
|
|
417
419
|
interface ChunkMetadata {
|
|
418
420
|
length?: number;
|
|
419
421
|
pageNums?: number[];
|
|
422
|
+
entities?: Record<string, unknown>[];
|
|
420
423
|
tokens?: string[];
|
|
421
424
|
keywords?: string[];
|
|
422
425
|
summary?: string;
|
|
@@ -435,7 +438,9 @@ interface BaseChunk {
|
|
|
435
438
|
/** Unique chunk identifier */
|
|
436
439
|
chunkId: string;
|
|
437
440
|
/** Chunk type */
|
|
438
|
-
type: 'text' | 'image' | 'table';
|
|
441
|
+
type: 'text' | 'image' | 'table' | 'page';
|
|
442
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
443
|
+
contentSource?: string;
|
|
439
444
|
/** Main content */
|
|
440
445
|
content: string;
|
|
441
446
|
/** Relative path in ZIP */
|
|
@@ -447,7 +452,7 @@ interface BaseChunk {
|
|
|
447
452
|
* Minimal chunk representation emitted in chunks_slim.json (legacy).
|
|
448
453
|
*/
|
|
449
454
|
interface SlimChunk {
|
|
450
|
-
type: 'text' | 'image' | 'table';
|
|
455
|
+
type: 'text' | 'image' | 'table' | 'page';
|
|
451
456
|
path: string;
|
|
452
457
|
content: string;
|
|
453
458
|
}
|
|
@@ -483,10 +488,16 @@ interface TableChunk extends BaseChunk {
|
|
|
483
488
|
/** Save table HTML to disk */
|
|
484
489
|
save(directory: string): Promise<string>;
|
|
485
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Page chunk
|
|
493
|
+
*/
|
|
494
|
+
interface PageChunk extends BaseChunk {
|
|
495
|
+
type: 'page';
|
|
496
|
+
}
|
|
486
497
|
/**
|
|
487
498
|
* Union type of all chunk types
|
|
488
499
|
*/
|
|
489
|
-
type Chunk = TextChunk | ImageChunk | TableChunk;
|
|
500
|
+
type Chunk = TextChunk | ImageChunk | TableChunk | PageChunk;
|
|
490
501
|
/**
|
|
491
502
|
* Complete parse result
|
|
492
503
|
*/
|
|
@@ -517,6 +528,8 @@ interface ParseResult {
|
|
|
517
528
|
readonly imageChunks: ImageChunk[];
|
|
518
529
|
/** Table chunks only */
|
|
519
530
|
readonly tableChunks: TableChunk[];
|
|
531
|
+
/** Page chunks only */
|
|
532
|
+
readonly pageChunks: PageChunk[];
|
|
520
533
|
/** Job ID */
|
|
521
534
|
readonly jobId: string;
|
|
522
535
|
/** Effective retrieval namespace when loaded from a job result */
|
|
@@ -602,6 +615,7 @@ declare class HttpClient {
|
|
|
602
615
|
declare abstract class BaseResource {
|
|
603
616
|
protected httpClient: HttpClient;
|
|
604
617
|
constructor(httpClient: HttpClient);
|
|
618
|
+
protected endpoint(path: string): string;
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
/**
|
|
@@ -651,6 +665,7 @@ type RetrievalChannel = 'path' | 'content' | 'term';
|
|
|
651
665
|
* Path filtering mode for retrieval queries.
|
|
652
666
|
*/
|
|
653
667
|
type RetrievalFilterMode = 'delete' | 'keep';
|
|
668
|
+
type RetrievalChunkType = 'text' | 'image' | 'table' | 'page';
|
|
654
669
|
/**
|
|
655
670
|
* Retrieval query parameters.
|
|
656
671
|
*/
|
|
@@ -669,8 +684,10 @@ interface RetrievalQueryParams {
|
|
|
669
684
|
* - ``undefined`` / omitted — server default
|
|
670
685
|
*/
|
|
671
686
|
useAgentic?: boolean;
|
|
672
|
-
/** Chunk type filter: 1=all, 2=text, 3=image, 4=table, 5=text+image, 6=text+table */
|
|
673
|
-
dataType?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
687
|
+
/** Chunk type filter: 1=all, 2=text, 3=image, 4=table, 5=text+image, 6=text+table, 7=page, 8=text+image+table */
|
|
688
|
+
dataType?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
689
|
+
/** Allowed chunk types. Overrides dataType when provided. */
|
|
690
|
+
chunkTypes?: RetrievalChunkType[];
|
|
674
691
|
/** Path keywords for include/exclude filtering */
|
|
675
692
|
signalPaths?: string[];
|
|
676
693
|
/** Signal path filter mode */
|
|
@@ -705,14 +722,24 @@ interface RetrievalSource {
|
|
|
705
722
|
* Canonical chunk result returned by retrieval query.
|
|
706
723
|
*/
|
|
707
724
|
interface RetrievalResult {
|
|
725
|
+
/** Parser-provided chunk identifier when included by the API */
|
|
726
|
+
chunkId?: string;
|
|
708
727
|
/** Knowledge content to use directly in the caller's answer */
|
|
709
728
|
content: string;
|
|
710
|
-
/** Chunk type, for example text, image, or
|
|
729
|
+
/** Chunk type, for example text, image, table, or page */
|
|
711
730
|
chunkType: string;
|
|
731
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
732
|
+
contentSource?: string;
|
|
712
733
|
/** Retrieval score returned by the API. Null when no score is available (agentic navigation-only results). */
|
|
713
734
|
score: number | null;
|
|
714
735
|
/** Presigned asset URL for media chunks when available */
|
|
715
736
|
assetUrl?: string;
|
|
737
|
+
/** Source chunk path when returned by the API */
|
|
738
|
+
sourceChunkPath?: string | null;
|
|
739
|
+
/** Generated artifact file path for media chunks */
|
|
740
|
+
filePath?: string | null;
|
|
741
|
+
/** Chunk metadata returned by the API */
|
|
742
|
+
metadata?: Record<string, unknown>;
|
|
716
743
|
/** Source reference for this result */
|
|
717
744
|
source: RetrievalSource;
|
|
718
745
|
}
|
|
@@ -724,19 +751,25 @@ interface RetrievalReferencedChunk {
|
|
|
724
751
|
chunkId: string;
|
|
725
752
|
/** Stable document identifier */
|
|
726
753
|
documentId: string;
|
|
727
|
-
/** Chunk type, for example text, image, or
|
|
754
|
+
/** Chunk type, for example text, image, table, or page */
|
|
728
755
|
chunkType: string;
|
|
756
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
757
|
+
contentSource?: string | null;
|
|
729
758
|
/** Human-readable section path */
|
|
730
759
|
sectionPath: string;
|
|
760
|
+
/** Source chunk path when returned by the API */
|
|
761
|
+
sourceChunkPath?: string | null;
|
|
731
762
|
/** Generated artifact file path for media chunks */
|
|
732
763
|
filePath?: string | null;
|
|
733
764
|
/** Published job identifier for the referenced chunk */
|
|
734
765
|
jobId?: string | null;
|
|
735
766
|
/** Presigned asset URL for media chunks when available */
|
|
736
767
|
assetUrl?: string | null;
|
|
768
|
+
/** Chunk metadata returned by the API */
|
|
769
|
+
metadata?: Record<string, unknown>;
|
|
737
770
|
}
|
|
738
771
|
/**
|
|
739
|
-
* Response from POST /
|
|
772
|
+
* Response from POST /v2/retrieval/query.
|
|
740
773
|
*
|
|
741
774
|
* Three PRIMARY output fields for downstream agent consumption:
|
|
742
775
|
* - `evidenceText`: hierarchical evidence tree for LLM context
|
|
@@ -813,7 +846,7 @@ interface DocumentListPagination {
|
|
|
813
846
|
totalPages: number;
|
|
814
847
|
}
|
|
815
848
|
/**
|
|
816
|
-
* Query parameters for GET /
|
|
849
|
+
* Query parameters for GET /v2/documents.
|
|
817
850
|
*/
|
|
818
851
|
interface DocumentListParams {
|
|
819
852
|
/** Retrieval namespace */
|
|
@@ -824,7 +857,7 @@ interface DocumentListParams {
|
|
|
824
857
|
pageSize?: number;
|
|
825
858
|
}
|
|
826
859
|
/**
|
|
827
|
-
* Response from GET /
|
|
860
|
+
* Response from GET /v2/documents.
|
|
828
861
|
*/
|
|
829
862
|
interface DocumentListResponse {
|
|
830
863
|
/** Namespace listed by the API */
|
|
@@ -837,7 +870,7 @@ interface DocumentListResponse {
|
|
|
837
870
|
/**
|
|
838
871
|
* Document chunk types supported by document chunk endpoints.
|
|
839
872
|
*/
|
|
840
|
-
type DocumentChunkType = 'text' | 'image' | 'table';
|
|
873
|
+
type DocumentChunkType = 'text' | 'image' | 'table' | 'page';
|
|
841
874
|
/**
|
|
842
875
|
* Pagination metadata returned by chunk list endpoints.
|
|
843
876
|
*/
|
|
@@ -852,7 +885,7 @@ interface DocumentChunkPagination {
|
|
|
852
885
|
totalPages: number;
|
|
853
886
|
}
|
|
854
887
|
/**
|
|
855
|
-
* Query parameters for GET /
|
|
888
|
+
* Query parameters for GET /v2/documents/{document_id}/chunks.
|
|
856
889
|
*/
|
|
857
890
|
interface DocumentChunkListParams {
|
|
858
891
|
/** Page number (default: 1) */
|
|
@@ -865,7 +898,7 @@ interface DocumentChunkListParams {
|
|
|
865
898
|
includeAssetUrls?: boolean;
|
|
866
899
|
}
|
|
867
900
|
/**
|
|
868
|
-
* Query parameters for GET /
|
|
901
|
+
* Query parameters for GET /v2/documents/{document_id}/chunks/{document_chunk_id}.
|
|
869
902
|
*/
|
|
870
903
|
interface DocumentChunkGetParams {
|
|
871
904
|
/** Set true to include 7-day asset URLs for media chunks */
|
|
@@ -881,6 +914,8 @@ interface DocumentChunk {
|
|
|
881
914
|
chunkId: string;
|
|
882
915
|
/** Chunk content type */
|
|
883
916
|
chunkType: DocumentChunkType;
|
|
917
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
918
|
+
contentSource?: string | null;
|
|
884
919
|
/** Chunk text or generated summary content */
|
|
885
920
|
content?: string | null;
|
|
886
921
|
/** Parent section identifier */
|
|
@@ -901,7 +936,7 @@ interface DocumentChunk {
|
|
|
901
936
|
createdAt?: Date;
|
|
902
937
|
}
|
|
903
938
|
/**
|
|
904
|
-
* Response from GET /
|
|
939
|
+
* Response from GET /v2/documents/{document_id}/chunks.
|
|
905
940
|
*/
|
|
906
941
|
interface DocumentChunkListResponse {
|
|
907
942
|
/** Stable document identifier */
|
|
@@ -918,7 +953,7 @@ interface DocumentChunkListResponse {
|
|
|
918
953
|
pagination: DocumentChunkPagination;
|
|
919
954
|
}
|
|
920
955
|
/**
|
|
921
|
-
* Response from GET /
|
|
956
|
+
* Response from GET /v2/documents/{document_id}/chunks/{document_chunk_id}.
|
|
922
957
|
*/
|
|
923
958
|
interface DocumentChunkResponse {
|
|
924
959
|
/** Stable document identifier */
|
|
@@ -1066,10 +1101,15 @@ interface KnowledgeReadChunk {
|
|
|
1066
1101
|
position: number;
|
|
1067
1102
|
chunkId: string;
|
|
1068
1103
|
chunkType: KnowledgeChunkType;
|
|
1104
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
1105
|
+
contentSource?: string;
|
|
1069
1106
|
content: string;
|
|
1107
|
+
/** Display-safe text. For page chunks this prefers metadata.summary. */
|
|
1108
|
+
readableContent: string;
|
|
1070
1109
|
sectionPath: string;
|
|
1071
1110
|
sourceChunkPath: string;
|
|
1072
1111
|
filePath?: string;
|
|
1112
|
+
pageNumbers?: number[];
|
|
1073
1113
|
metadata: Record<string, unknown>;
|
|
1074
1114
|
}
|
|
1075
1115
|
interface KnowledgeReadResponse {
|
|
@@ -1384,4 +1424,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1384
1424
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1385
1425
|
}
|
|
1386
1426
|
|
|
1387
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
|
1427
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type PageChunk, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalChunkType, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -300,6 +300,8 @@ interface Statistics {
|
|
|
300
300
|
imageChunks: number;
|
|
301
301
|
/** Number of table chunks */
|
|
302
302
|
tableChunks: number;
|
|
303
|
+
/** Number of page chunks */
|
|
304
|
+
pageChunks?: number;
|
|
303
305
|
/** Total number of pages (if applicable) */
|
|
304
306
|
totalPages?: number;
|
|
305
307
|
}
|
|
@@ -417,6 +419,7 @@ interface DocNav {
|
|
|
417
419
|
interface ChunkMetadata {
|
|
418
420
|
length?: number;
|
|
419
421
|
pageNums?: number[];
|
|
422
|
+
entities?: Record<string, unknown>[];
|
|
420
423
|
tokens?: string[];
|
|
421
424
|
keywords?: string[];
|
|
422
425
|
summary?: string;
|
|
@@ -435,7 +438,9 @@ interface BaseChunk {
|
|
|
435
438
|
/** Unique chunk identifier */
|
|
436
439
|
chunkId: string;
|
|
437
440
|
/** Chunk type */
|
|
438
|
-
type: 'text' | 'image' | 'table';
|
|
441
|
+
type: 'text' | 'image' | 'table' | 'page';
|
|
442
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
443
|
+
contentSource?: string;
|
|
439
444
|
/** Main content */
|
|
440
445
|
content: string;
|
|
441
446
|
/** Relative path in ZIP */
|
|
@@ -447,7 +452,7 @@ interface BaseChunk {
|
|
|
447
452
|
* Minimal chunk representation emitted in chunks_slim.json (legacy).
|
|
448
453
|
*/
|
|
449
454
|
interface SlimChunk {
|
|
450
|
-
type: 'text' | 'image' | 'table';
|
|
455
|
+
type: 'text' | 'image' | 'table' | 'page';
|
|
451
456
|
path: string;
|
|
452
457
|
content: string;
|
|
453
458
|
}
|
|
@@ -483,10 +488,16 @@ interface TableChunk extends BaseChunk {
|
|
|
483
488
|
/** Save table HTML to disk */
|
|
484
489
|
save(directory: string): Promise<string>;
|
|
485
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Page chunk
|
|
493
|
+
*/
|
|
494
|
+
interface PageChunk extends BaseChunk {
|
|
495
|
+
type: 'page';
|
|
496
|
+
}
|
|
486
497
|
/**
|
|
487
498
|
* Union type of all chunk types
|
|
488
499
|
*/
|
|
489
|
-
type Chunk = TextChunk | ImageChunk | TableChunk;
|
|
500
|
+
type Chunk = TextChunk | ImageChunk | TableChunk | PageChunk;
|
|
490
501
|
/**
|
|
491
502
|
* Complete parse result
|
|
492
503
|
*/
|
|
@@ -517,6 +528,8 @@ interface ParseResult {
|
|
|
517
528
|
readonly imageChunks: ImageChunk[];
|
|
518
529
|
/** Table chunks only */
|
|
519
530
|
readonly tableChunks: TableChunk[];
|
|
531
|
+
/** Page chunks only */
|
|
532
|
+
readonly pageChunks: PageChunk[];
|
|
520
533
|
/** Job ID */
|
|
521
534
|
readonly jobId: string;
|
|
522
535
|
/** Effective retrieval namespace when loaded from a job result */
|
|
@@ -602,6 +615,7 @@ declare class HttpClient {
|
|
|
602
615
|
declare abstract class BaseResource {
|
|
603
616
|
protected httpClient: HttpClient;
|
|
604
617
|
constructor(httpClient: HttpClient);
|
|
618
|
+
protected endpoint(path: string): string;
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
/**
|
|
@@ -651,6 +665,7 @@ type RetrievalChannel = 'path' | 'content' | 'term';
|
|
|
651
665
|
* Path filtering mode for retrieval queries.
|
|
652
666
|
*/
|
|
653
667
|
type RetrievalFilterMode = 'delete' | 'keep';
|
|
668
|
+
type RetrievalChunkType = 'text' | 'image' | 'table' | 'page';
|
|
654
669
|
/**
|
|
655
670
|
* Retrieval query parameters.
|
|
656
671
|
*/
|
|
@@ -669,8 +684,10 @@ interface RetrievalQueryParams {
|
|
|
669
684
|
* - ``undefined`` / omitted — server default
|
|
670
685
|
*/
|
|
671
686
|
useAgentic?: boolean;
|
|
672
|
-
/** Chunk type filter: 1=all, 2=text, 3=image, 4=table, 5=text+image, 6=text+table */
|
|
673
|
-
dataType?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
687
|
+
/** Chunk type filter: 1=all, 2=text, 3=image, 4=table, 5=text+image, 6=text+table, 7=page, 8=text+image+table */
|
|
688
|
+
dataType?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
689
|
+
/** Allowed chunk types. Overrides dataType when provided. */
|
|
690
|
+
chunkTypes?: RetrievalChunkType[];
|
|
674
691
|
/** Path keywords for include/exclude filtering */
|
|
675
692
|
signalPaths?: string[];
|
|
676
693
|
/** Signal path filter mode */
|
|
@@ -705,14 +722,24 @@ interface RetrievalSource {
|
|
|
705
722
|
* Canonical chunk result returned by retrieval query.
|
|
706
723
|
*/
|
|
707
724
|
interface RetrievalResult {
|
|
725
|
+
/** Parser-provided chunk identifier when included by the API */
|
|
726
|
+
chunkId?: string;
|
|
708
727
|
/** Knowledge content to use directly in the caller's answer */
|
|
709
728
|
content: string;
|
|
710
|
-
/** Chunk type, for example text, image, or
|
|
729
|
+
/** Chunk type, for example text, image, table, or page */
|
|
711
730
|
chunkType: string;
|
|
731
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
732
|
+
contentSource?: string;
|
|
712
733
|
/** Retrieval score returned by the API. Null when no score is available (agentic navigation-only results). */
|
|
713
734
|
score: number | null;
|
|
714
735
|
/** Presigned asset URL for media chunks when available */
|
|
715
736
|
assetUrl?: string;
|
|
737
|
+
/** Source chunk path when returned by the API */
|
|
738
|
+
sourceChunkPath?: string | null;
|
|
739
|
+
/** Generated artifact file path for media chunks */
|
|
740
|
+
filePath?: string | null;
|
|
741
|
+
/** Chunk metadata returned by the API */
|
|
742
|
+
metadata?: Record<string, unknown>;
|
|
716
743
|
/** Source reference for this result */
|
|
717
744
|
source: RetrievalSource;
|
|
718
745
|
}
|
|
@@ -724,19 +751,25 @@ interface RetrievalReferencedChunk {
|
|
|
724
751
|
chunkId: string;
|
|
725
752
|
/** Stable document identifier */
|
|
726
753
|
documentId: string;
|
|
727
|
-
/** Chunk type, for example text, image, or
|
|
754
|
+
/** Chunk type, for example text, image, table, or page */
|
|
728
755
|
chunkType: string;
|
|
756
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
757
|
+
contentSource?: string | null;
|
|
729
758
|
/** Human-readable section path */
|
|
730
759
|
sectionPath: string;
|
|
760
|
+
/** Source chunk path when returned by the API */
|
|
761
|
+
sourceChunkPath?: string | null;
|
|
731
762
|
/** Generated artifact file path for media chunks */
|
|
732
763
|
filePath?: string | null;
|
|
733
764
|
/** Published job identifier for the referenced chunk */
|
|
734
765
|
jobId?: string | null;
|
|
735
766
|
/** Presigned asset URL for media chunks when available */
|
|
736
767
|
assetUrl?: string | null;
|
|
768
|
+
/** Chunk metadata returned by the API */
|
|
769
|
+
metadata?: Record<string, unknown>;
|
|
737
770
|
}
|
|
738
771
|
/**
|
|
739
|
-
* Response from POST /
|
|
772
|
+
* Response from POST /v2/retrieval/query.
|
|
740
773
|
*
|
|
741
774
|
* Three PRIMARY output fields for downstream agent consumption:
|
|
742
775
|
* - `evidenceText`: hierarchical evidence tree for LLM context
|
|
@@ -813,7 +846,7 @@ interface DocumentListPagination {
|
|
|
813
846
|
totalPages: number;
|
|
814
847
|
}
|
|
815
848
|
/**
|
|
816
|
-
* Query parameters for GET /
|
|
849
|
+
* Query parameters for GET /v2/documents.
|
|
817
850
|
*/
|
|
818
851
|
interface DocumentListParams {
|
|
819
852
|
/** Retrieval namespace */
|
|
@@ -824,7 +857,7 @@ interface DocumentListParams {
|
|
|
824
857
|
pageSize?: number;
|
|
825
858
|
}
|
|
826
859
|
/**
|
|
827
|
-
* Response from GET /
|
|
860
|
+
* Response from GET /v2/documents.
|
|
828
861
|
*/
|
|
829
862
|
interface DocumentListResponse {
|
|
830
863
|
/** Namespace listed by the API */
|
|
@@ -837,7 +870,7 @@ interface DocumentListResponse {
|
|
|
837
870
|
/**
|
|
838
871
|
* Document chunk types supported by document chunk endpoints.
|
|
839
872
|
*/
|
|
840
|
-
type DocumentChunkType = 'text' | 'image' | 'table';
|
|
873
|
+
type DocumentChunkType = 'text' | 'image' | 'table' | 'page';
|
|
841
874
|
/**
|
|
842
875
|
* Pagination metadata returned by chunk list endpoints.
|
|
843
876
|
*/
|
|
@@ -852,7 +885,7 @@ interface DocumentChunkPagination {
|
|
|
852
885
|
totalPages: number;
|
|
853
886
|
}
|
|
854
887
|
/**
|
|
855
|
-
* Query parameters for GET /
|
|
888
|
+
* Query parameters for GET /v2/documents/{document_id}/chunks.
|
|
856
889
|
*/
|
|
857
890
|
interface DocumentChunkListParams {
|
|
858
891
|
/** Page number (default: 1) */
|
|
@@ -865,7 +898,7 @@ interface DocumentChunkListParams {
|
|
|
865
898
|
includeAssetUrls?: boolean;
|
|
866
899
|
}
|
|
867
900
|
/**
|
|
868
|
-
* Query parameters for GET /
|
|
901
|
+
* Query parameters for GET /v2/documents/{document_id}/chunks/{document_chunk_id}.
|
|
869
902
|
*/
|
|
870
903
|
interface DocumentChunkGetParams {
|
|
871
904
|
/** Set true to include 7-day asset URLs for media chunks */
|
|
@@ -881,6 +914,8 @@ interface DocumentChunk {
|
|
|
881
914
|
chunkId: string;
|
|
882
915
|
/** Chunk content type */
|
|
883
916
|
chunkType: DocumentChunkType;
|
|
917
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
918
|
+
contentSource?: string | null;
|
|
884
919
|
/** Chunk text or generated summary content */
|
|
885
920
|
content?: string | null;
|
|
886
921
|
/** Parent section identifier */
|
|
@@ -901,7 +936,7 @@ interface DocumentChunk {
|
|
|
901
936
|
createdAt?: Date;
|
|
902
937
|
}
|
|
903
938
|
/**
|
|
904
|
-
* Response from GET /
|
|
939
|
+
* Response from GET /v2/documents/{document_id}/chunks.
|
|
905
940
|
*/
|
|
906
941
|
interface DocumentChunkListResponse {
|
|
907
942
|
/** Stable document identifier */
|
|
@@ -918,7 +953,7 @@ interface DocumentChunkListResponse {
|
|
|
918
953
|
pagination: DocumentChunkPagination;
|
|
919
954
|
}
|
|
920
955
|
/**
|
|
921
|
-
* Response from GET /
|
|
956
|
+
* Response from GET /v2/documents/{document_id}/chunks/{document_chunk_id}.
|
|
922
957
|
*/
|
|
923
958
|
interface DocumentChunkResponse {
|
|
924
959
|
/** Stable document identifier */
|
|
@@ -1066,10 +1101,15 @@ interface KnowledgeReadChunk {
|
|
|
1066
1101
|
position: number;
|
|
1067
1102
|
chunkId: string;
|
|
1068
1103
|
chunkType: KnowledgeChunkType;
|
|
1104
|
+
/** Content source marker. Page chunks normally expose summaries as content. */
|
|
1105
|
+
contentSource?: string;
|
|
1069
1106
|
content: string;
|
|
1107
|
+
/** Display-safe text. For page chunks this prefers metadata.summary. */
|
|
1108
|
+
readableContent: string;
|
|
1070
1109
|
sectionPath: string;
|
|
1071
1110
|
sourceChunkPath: string;
|
|
1072
1111
|
filePath?: string;
|
|
1112
|
+
pageNumbers?: number[];
|
|
1073
1113
|
metadata: Record<string, unknown>;
|
|
1074
1114
|
}
|
|
1075
1115
|
interface KnowledgeReadResponse {
|
|
@@ -1384,4 +1424,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1384
1424
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1385
1425
|
}
|
|
1386
1426
|
|
|
1387
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
|
1427
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type PageChunk, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalChunkType, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
package/dist/index.js
CHANGED
|
@@ -756,6 +756,9 @@ var BaseResource = class {
|
|
|
756
756
|
constructor(httpClient) {
|
|
757
757
|
this.httpClient = httpClient;
|
|
758
758
|
}
|
|
759
|
+
endpoint(path3) {
|
|
760
|
+
return `/v2${path3.startsWith("/") ? path3 : `/${path3}`}`;
|
|
761
|
+
}
|
|
759
762
|
};
|
|
760
763
|
|
|
761
764
|
// src/lib/upload.ts
|
|
@@ -806,7 +809,7 @@ async function pollJobStatus(httpClient, jobId, options) {
|
|
|
806
809
|
if (signal?.aborted) {
|
|
807
810
|
throw new Error("Polling aborted");
|
|
808
811
|
}
|
|
809
|
-
const jobResult = await httpClient.get(`/
|
|
812
|
+
const jobResult = await httpClient.get(`/v2/jobs/${jobId}`);
|
|
810
813
|
enrichJobResult(jobResult);
|
|
811
814
|
const elapsed = Date.now() - startTime;
|
|
812
815
|
const elapsedSeconds = Math.floor(elapsed / 1e3);
|
|
@@ -1067,6 +1070,9 @@ function createParseResult(parts) {
|
|
|
1067
1070
|
get tableChunks() {
|
|
1068
1071
|
return chunks.filter((c) => c.type === "table");
|
|
1069
1072
|
},
|
|
1073
|
+
get pageChunks() {
|
|
1074
|
+
return chunks.filter((c) => c.type === "page");
|
|
1075
|
+
},
|
|
1070
1076
|
get jobId() {
|
|
1071
1077
|
return manifest.jobId;
|
|
1072
1078
|
},
|
|
@@ -1144,6 +1150,17 @@ function buildTextChunk(chunkData) {
|
|
|
1144
1150
|
return {
|
|
1145
1151
|
chunkId: chunkData.chunkId ?? "",
|
|
1146
1152
|
type: "text",
|
|
1153
|
+
contentSource: chunkData.contentSource ?? "content",
|
|
1154
|
+
content: chunkData.content ?? "",
|
|
1155
|
+
path: chunkData.path ?? "",
|
|
1156
|
+
metadata: chunkData.metadata ?? {}
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function buildPageChunk(chunkData) {
|
|
1160
|
+
return {
|
|
1161
|
+
chunkId: chunkData.chunkId ?? "",
|
|
1162
|
+
type: "page",
|
|
1163
|
+
contentSource: chunkData.contentSource ?? "summary",
|
|
1147
1164
|
content: chunkData.content ?? "",
|
|
1148
1165
|
path: chunkData.path ?? "",
|
|
1149
1166
|
metadata: chunkData.metadata ?? {}
|
|
@@ -1153,6 +1170,7 @@ function buildImageChunk(chunkData, filePath, imageBuffer) {
|
|
|
1153
1170
|
return {
|
|
1154
1171
|
chunkId: chunkData.chunkId ?? "",
|
|
1155
1172
|
type: "image",
|
|
1173
|
+
contentSource: chunkData.contentSource,
|
|
1156
1174
|
content: chunkData.content ?? "",
|
|
1157
1175
|
path: chunkData.path ?? "",
|
|
1158
1176
|
filePath,
|
|
@@ -1170,6 +1188,7 @@ function buildTableChunk(chunkData, filePath, html) {
|
|
|
1170
1188
|
return {
|
|
1171
1189
|
chunkId: chunkData.chunkId ?? "",
|
|
1172
1190
|
type: "table",
|
|
1191
|
+
contentSource: chunkData.contentSource,
|
|
1173
1192
|
content: chunkData.content ?? "",
|
|
1174
1193
|
path: chunkData.path ?? "",
|
|
1175
1194
|
filePath,
|
|
@@ -1184,6 +1203,9 @@ async function processChunk(zip, chunkData) {
|
|
|
1184
1203
|
if (chunkData.type === "text") {
|
|
1185
1204
|
return buildTextChunk(chunkData);
|
|
1186
1205
|
}
|
|
1206
|
+
if (chunkData.type === "page") {
|
|
1207
|
+
return buildPageChunk(chunkData);
|
|
1208
|
+
}
|
|
1187
1209
|
if (chunkData.type === "image") {
|
|
1188
1210
|
const filePath = getChunkFilePath(chunkData);
|
|
1189
1211
|
if (!filePath) {
|
|
@@ -1216,6 +1238,9 @@ async function processDirectoryChunk(directory, chunkData) {
|
|
|
1216
1238
|
if (chunkData.type === "text") {
|
|
1217
1239
|
return buildTextChunk(chunkData);
|
|
1218
1240
|
}
|
|
1241
|
+
if (chunkData.type === "page") {
|
|
1242
|
+
return buildPageChunk(chunkData);
|
|
1243
|
+
}
|
|
1219
1244
|
if (chunkData.type === "image") {
|
|
1220
1245
|
const filePath = getChunkFilePath(chunkData);
|
|
1221
1246
|
if (!filePath) {
|
|
@@ -1254,6 +1279,7 @@ function serializeChunks(chunks) {
|
|
|
1254
1279
|
const rawChunk = {
|
|
1255
1280
|
chunkId: chunk.chunkId,
|
|
1256
1281
|
type: chunk.type,
|
|
1282
|
+
contentSource: chunk.contentSource,
|
|
1257
1283
|
content: chunk.content,
|
|
1258
1284
|
path: chunk.path,
|
|
1259
1285
|
metadata: chunk.metadata
|
|
@@ -1322,7 +1348,7 @@ var Jobs = class extends BaseResource {
|
|
|
1322
1348
|
* Create a new parsing job
|
|
1323
1349
|
*/
|
|
1324
1350
|
async create(params) {
|
|
1325
|
-
const job = await this.httpClient.post("/
|
|
1351
|
+
const job = await this.httpClient.post(this.endpoint("/jobs"), params);
|
|
1326
1352
|
if (job.uploadUrl) {
|
|
1327
1353
|
this.pendingUploadJobs.set(job.jobId, job);
|
|
1328
1354
|
}
|
|
@@ -1332,7 +1358,7 @@ var Jobs = class extends BaseResource {
|
|
|
1332
1358
|
* Get job status
|
|
1333
1359
|
*/
|
|
1334
1360
|
async get(jobId) {
|
|
1335
|
-
const jobResult = await this.httpClient.get(`/
|
|
1361
|
+
const jobResult = await this.httpClient.get(this.endpoint(`/jobs/${jobId}`));
|
|
1336
1362
|
enrichJobResult(jobResult);
|
|
1337
1363
|
return jobResult;
|
|
1338
1364
|
}
|
|
@@ -1428,7 +1454,7 @@ var Retrieval = class extends BaseResource {
|
|
|
1428
1454
|
* Query published documents.
|
|
1429
1455
|
*/
|
|
1430
1456
|
async query(params) {
|
|
1431
|
-
return this.httpClient.post("/
|
|
1457
|
+
return this.httpClient.post(this.endpoint("/retrieval/query"), params);
|
|
1432
1458
|
}
|
|
1433
1459
|
};
|
|
1434
1460
|
|
|
@@ -1439,7 +1465,7 @@ var Documents = class extends BaseResource {
|
|
|
1439
1465
|
*/
|
|
1440
1466
|
async list(params) {
|
|
1441
1467
|
const response = await this.httpClient.get(
|
|
1442
|
-
"/
|
|
1468
|
+
this.endpoint("/documents"),
|
|
1443
1469
|
this.createDocumentListRequestConfig(params)
|
|
1444
1470
|
);
|
|
1445
1471
|
return this.normalizeDocumentListResponse(response);
|
|
@@ -1448,14 +1474,14 @@ var Documents = class extends BaseResource {
|
|
|
1448
1474
|
* Get one canonical document by ID.
|
|
1449
1475
|
*/
|
|
1450
1476
|
async get(documentId) {
|
|
1451
|
-
return this.httpClient.get(`/
|
|
1477
|
+
return this.httpClient.get(this.endpoint(`/documents/${documentId}`));
|
|
1452
1478
|
}
|
|
1453
1479
|
/**
|
|
1454
1480
|
* List current-revision chunks for one canonical document.
|
|
1455
1481
|
*/
|
|
1456
1482
|
async listChunks(documentId, params) {
|
|
1457
1483
|
return this.httpClient.get(
|
|
1458
|
-
`/
|
|
1484
|
+
this.endpoint(`/documents/${documentId}/chunks`),
|
|
1459
1485
|
this.createChunkListRequestConfig(params)
|
|
1460
1486
|
);
|
|
1461
1487
|
}
|
|
@@ -1464,7 +1490,7 @@ var Documents = class extends BaseResource {
|
|
|
1464
1490
|
*/
|
|
1465
1491
|
async getChunk(documentId, documentChunkId, params) {
|
|
1466
1492
|
return this.httpClient.get(
|
|
1467
|
-
`/
|
|
1493
|
+
this.endpoint(`/documents/${documentId}/chunks/${documentChunkId}`),
|
|
1468
1494
|
this.createChunkGetRequestConfig(params)
|
|
1469
1495
|
);
|
|
1470
1496
|
}
|
|
@@ -1472,7 +1498,7 @@ var Documents = class extends BaseResource {
|
|
|
1472
1498
|
* Archive one canonical document by ID.
|
|
1473
1499
|
*/
|
|
1474
1500
|
async archive(documentId) {
|
|
1475
|
-
return this.httpClient.post(`/
|
|
1501
|
+
return this.httpClient.post(this.endpoint(`/documents/${documentId}/archive`));
|
|
1476
1502
|
}
|
|
1477
1503
|
createDocumentListRequestConfig(params) {
|
|
1478
1504
|
if (!params) {
|
|
@@ -1734,7 +1760,7 @@ function countChunkTypes(result) {
|
|
|
1734
1760
|
counts[chunk.type] += 1;
|
|
1735
1761
|
return counts;
|
|
1736
1762
|
},
|
|
1737
|
-
{ text: 0, image: 0, table: 0 }
|
|
1763
|
+
{ text: 0, image: 0, table: 0, page: 0 }
|
|
1738
1764
|
);
|
|
1739
1765
|
}
|
|
1740
1766
|
function toLocalKnowledgeDocument(stored) {
|
|
@@ -2061,19 +2087,40 @@ function createLocalDocumentIdForRemote(documentId) {
|
|
|
2061
2087
|
function indexChunks(result) {
|
|
2062
2088
|
return result.chunks.map((chunk, index) => {
|
|
2063
2089
|
const filePath = getChunkFilePath2(chunk);
|
|
2090
|
+
const readableContent = getReadableChunkContent(chunk);
|
|
2064
2091
|
return {
|
|
2065
2092
|
source: chunk,
|
|
2066
2093
|
position: index + 1,
|
|
2067
2094
|
chunkId: chunk.chunkId,
|
|
2068
2095
|
chunkType: chunk.type,
|
|
2096
|
+
contentSource: chunk.contentSource,
|
|
2069
2097
|
content: chunk.content,
|
|
2098
|
+
readableContent,
|
|
2070
2099
|
sectionPath: normalizeSectionPath(chunk.path, result.manifest.sourceFileName),
|
|
2071
2100
|
sourceChunkPath: chunk.path,
|
|
2072
2101
|
filePath,
|
|
2102
|
+
pageNumbers: getChunkPageNumbers(chunk.metadata),
|
|
2073
2103
|
metadata: chunk.metadata
|
|
2074
2104
|
};
|
|
2075
2105
|
});
|
|
2076
2106
|
}
|
|
2107
|
+
function getReadableChunkContent(chunk) {
|
|
2108
|
+
if (chunk.type !== "page") {
|
|
2109
|
+
return chunk.content;
|
|
2110
|
+
}
|
|
2111
|
+
const summary = chunk.metadata.summary;
|
|
2112
|
+
return typeof summary === "string" && summary.trim().length > 0 ? summary : chunk.content;
|
|
2113
|
+
}
|
|
2114
|
+
function getChunkPageNumbers(metadata) {
|
|
2115
|
+
const value = metadata.pageNums;
|
|
2116
|
+
if (!Array.isArray(value)) {
|
|
2117
|
+
return void 0;
|
|
2118
|
+
}
|
|
2119
|
+
const pageNumbers = value.filter(
|
|
2120
|
+
(pageNumber) => Number.isInteger(pageNumber) && pageNumber > 0
|
|
2121
|
+
);
|
|
2122
|
+
return pageNumbers.length > 0 ? [...new Set(pageNumbers)].sort((left, right) => left - right) : void 0;
|
|
2123
|
+
}
|
|
2077
2124
|
function getChunkFilePath2(chunk) {
|
|
2078
2125
|
if (chunk.type === "image" || chunk.type === "table") {
|
|
2079
2126
|
return chunk.filePath;
|
|
@@ -2147,7 +2194,7 @@ function createSectionFromChunk(pathValue, chunk) {
|
|
|
2147
2194
|
startChunk: chunk.position,
|
|
2148
2195
|
endChunk: chunk.position,
|
|
2149
2196
|
chunkCount: 1,
|
|
2150
|
-
typeCounts: { text: 0, image: 0, table: 0, [chunk.chunkType]: 1 },
|
|
2197
|
+
typeCounts: { text: 0, image: 0, table: 0, page: 0, [chunk.chunkType]: 1 },
|
|
2151
2198
|
children: []
|
|
2152
2199
|
};
|
|
2153
2200
|
}
|
|
@@ -2206,7 +2253,7 @@ function countIndexedTypes(chunks) {
|
|
|
2206
2253
|
counts[chunk.chunkType] += 1;
|
|
2207
2254
|
return counts;
|
|
2208
2255
|
},
|
|
2209
|
-
{ text: 0, image: 0, table: 0 }
|
|
2256
|
+
{ text: 0, image: 0, table: 0, page: 0 }
|
|
2210
2257
|
);
|
|
2211
2258
|
}
|
|
2212
2259
|
function isInSection(chunkSectionPath, sectionPath) {
|
|
@@ -2243,10 +2290,13 @@ function toReadChunk(chunk) {
|
|
|
2243
2290
|
position: chunk.position,
|
|
2244
2291
|
chunkId: chunk.chunkId,
|
|
2245
2292
|
chunkType: chunk.chunkType,
|
|
2293
|
+
contentSource: chunk.contentSource,
|
|
2246
2294
|
content: chunk.content,
|
|
2295
|
+
readableContent: chunk.readableContent,
|
|
2247
2296
|
sectionPath: chunk.sectionPath,
|
|
2248
2297
|
sourceChunkPath: chunk.sourceChunkPath,
|
|
2249
2298
|
filePath: chunk.filePath,
|
|
2299
|
+
pageNumbers: chunk.pageNumbers,
|
|
2250
2300
|
metadata: chunk.metadata
|
|
2251
2301
|
};
|
|
2252
2302
|
}
|
|
@@ -2298,6 +2348,7 @@ function toResultReference(result, documentByServerId) {
|
|
|
2298
2348
|
return {
|
|
2299
2349
|
localDocumentId: documentId ? documentByServerId.get(documentId)?.localDocumentId : void 0,
|
|
2300
2350
|
documentId,
|
|
2351
|
+
chunkId: result.chunkId,
|
|
2301
2352
|
sectionPath: result.source.sectionPath ?? void 0,
|
|
2302
2353
|
chunkType: result.chunkType,
|
|
2303
2354
|
score: result.score
|
|
@@ -2308,6 +2359,7 @@ function toRemoteSearchResult(result, documentByServerId) {
|
|
|
2308
2359
|
return {
|
|
2309
2360
|
localDocumentId: documentId ? documentByServerId.get(documentId)?.localDocumentId : void 0,
|
|
2310
2361
|
documentId,
|
|
2362
|
+
chunkId: result.chunkId,
|
|
2311
2363
|
chunkType: result.chunkType,
|
|
2312
2364
|
content: result.content,
|
|
2313
2365
|
score: result.score,
|
package/dist/index.mjs
CHANGED
|
@@ -696,6 +696,9 @@ var BaseResource = class {
|
|
|
696
696
|
constructor(httpClient) {
|
|
697
697
|
this.httpClient = httpClient;
|
|
698
698
|
}
|
|
699
|
+
endpoint(path3) {
|
|
700
|
+
return `/v2${path3.startsWith("/") ? path3 : `/${path3}`}`;
|
|
701
|
+
}
|
|
699
702
|
};
|
|
700
703
|
|
|
701
704
|
// src/lib/upload.ts
|
|
@@ -746,7 +749,7 @@ async function pollJobStatus(httpClient, jobId, options) {
|
|
|
746
749
|
if (signal?.aborted) {
|
|
747
750
|
throw new Error("Polling aborted");
|
|
748
751
|
}
|
|
749
|
-
const jobResult = await httpClient.get(`/
|
|
752
|
+
const jobResult = await httpClient.get(`/v2/jobs/${jobId}`);
|
|
750
753
|
enrichJobResult(jobResult);
|
|
751
754
|
const elapsed = Date.now() - startTime;
|
|
752
755
|
const elapsedSeconds = Math.floor(elapsed / 1e3);
|
|
@@ -1007,6 +1010,9 @@ function createParseResult(parts) {
|
|
|
1007
1010
|
get tableChunks() {
|
|
1008
1011
|
return chunks.filter((c) => c.type === "table");
|
|
1009
1012
|
},
|
|
1013
|
+
get pageChunks() {
|
|
1014
|
+
return chunks.filter((c) => c.type === "page");
|
|
1015
|
+
},
|
|
1010
1016
|
get jobId() {
|
|
1011
1017
|
return manifest.jobId;
|
|
1012
1018
|
},
|
|
@@ -1084,6 +1090,17 @@ function buildTextChunk(chunkData) {
|
|
|
1084
1090
|
return {
|
|
1085
1091
|
chunkId: chunkData.chunkId ?? "",
|
|
1086
1092
|
type: "text",
|
|
1093
|
+
contentSource: chunkData.contentSource ?? "content",
|
|
1094
|
+
content: chunkData.content ?? "",
|
|
1095
|
+
path: chunkData.path ?? "",
|
|
1096
|
+
metadata: chunkData.metadata ?? {}
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function buildPageChunk(chunkData) {
|
|
1100
|
+
return {
|
|
1101
|
+
chunkId: chunkData.chunkId ?? "",
|
|
1102
|
+
type: "page",
|
|
1103
|
+
contentSource: chunkData.contentSource ?? "summary",
|
|
1087
1104
|
content: chunkData.content ?? "",
|
|
1088
1105
|
path: chunkData.path ?? "",
|
|
1089
1106
|
metadata: chunkData.metadata ?? {}
|
|
@@ -1093,6 +1110,7 @@ function buildImageChunk(chunkData, filePath, imageBuffer) {
|
|
|
1093
1110
|
return {
|
|
1094
1111
|
chunkId: chunkData.chunkId ?? "",
|
|
1095
1112
|
type: "image",
|
|
1113
|
+
contentSource: chunkData.contentSource,
|
|
1096
1114
|
content: chunkData.content ?? "",
|
|
1097
1115
|
path: chunkData.path ?? "",
|
|
1098
1116
|
filePath,
|
|
@@ -1110,6 +1128,7 @@ function buildTableChunk(chunkData, filePath, html) {
|
|
|
1110
1128
|
return {
|
|
1111
1129
|
chunkId: chunkData.chunkId ?? "",
|
|
1112
1130
|
type: "table",
|
|
1131
|
+
contentSource: chunkData.contentSource,
|
|
1113
1132
|
content: chunkData.content ?? "",
|
|
1114
1133
|
path: chunkData.path ?? "",
|
|
1115
1134
|
filePath,
|
|
@@ -1124,6 +1143,9 @@ async function processChunk(zip, chunkData) {
|
|
|
1124
1143
|
if (chunkData.type === "text") {
|
|
1125
1144
|
return buildTextChunk(chunkData);
|
|
1126
1145
|
}
|
|
1146
|
+
if (chunkData.type === "page") {
|
|
1147
|
+
return buildPageChunk(chunkData);
|
|
1148
|
+
}
|
|
1127
1149
|
if (chunkData.type === "image") {
|
|
1128
1150
|
const filePath = getChunkFilePath(chunkData);
|
|
1129
1151
|
if (!filePath) {
|
|
@@ -1156,6 +1178,9 @@ async function processDirectoryChunk(directory, chunkData) {
|
|
|
1156
1178
|
if (chunkData.type === "text") {
|
|
1157
1179
|
return buildTextChunk(chunkData);
|
|
1158
1180
|
}
|
|
1181
|
+
if (chunkData.type === "page") {
|
|
1182
|
+
return buildPageChunk(chunkData);
|
|
1183
|
+
}
|
|
1159
1184
|
if (chunkData.type === "image") {
|
|
1160
1185
|
const filePath = getChunkFilePath(chunkData);
|
|
1161
1186
|
if (!filePath) {
|
|
@@ -1194,6 +1219,7 @@ function serializeChunks(chunks) {
|
|
|
1194
1219
|
const rawChunk = {
|
|
1195
1220
|
chunkId: chunk.chunkId,
|
|
1196
1221
|
type: chunk.type,
|
|
1222
|
+
contentSource: chunk.contentSource,
|
|
1197
1223
|
content: chunk.content,
|
|
1198
1224
|
path: chunk.path,
|
|
1199
1225
|
metadata: chunk.metadata
|
|
@@ -1262,7 +1288,7 @@ var Jobs = class extends BaseResource {
|
|
|
1262
1288
|
* Create a new parsing job
|
|
1263
1289
|
*/
|
|
1264
1290
|
async create(params) {
|
|
1265
|
-
const job = await this.httpClient.post("/
|
|
1291
|
+
const job = await this.httpClient.post(this.endpoint("/jobs"), params);
|
|
1266
1292
|
if (job.uploadUrl) {
|
|
1267
1293
|
this.pendingUploadJobs.set(job.jobId, job);
|
|
1268
1294
|
}
|
|
@@ -1272,7 +1298,7 @@ var Jobs = class extends BaseResource {
|
|
|
1272
1298
|
* Get job status
|
|
1273
1299
|
*/
|
|
1274
1300
|
async get(jobId) {
|
|
1275
|
-
const jobResult = await this.httpClient.get(`/
|
|
1301
|
+
const jobResult = await this.httpClient.get(this.endpoint(`/jobs/${jobId}`));
|
|
1276
1302
|
enrichJobResult(jobResult);
|
|
1277
1303
|
return jobResult;
|
|
1278
1304
|
}
|
|
@@ -1368,7 +1394,7 @@ var Retrieval = class extends BaseResource {
|
|
|
1368
1394
|
* Query published documents.
|
|
1369
1395
|
*/
|
|
1370
1396
|
async query(params) {
|
|
1371
|
-
return this.httpClient.post("/
|
|
1397
|
+
return this.httpClient.post(this.endpoint("/retrieval/query"), params);
|
|
1372
1398
|
}
|
|
1373
1399
|
};
|
|
1374
1400
|
|
|
@@ -1379,7 +1405,7 @@ var Documents = class extends BaseResource {
|
|
|
1379
1405
|
*/
|
|
1380
1406
|
async list(params) {
|
|
1381
1407
|
const response = await this.httpClient.get(
|
|
1382
|
-
"/
|
|
1408
|
+
this.endpoint("/documents"),
|
|
1383
1409
|
this.createDocumentListRequestConfig(params)
|
|
1384
1410
|
);
|
|
1385
1411
|
return this.normalizeDocumentListResponse(response);
|
|
@@ -1388,14 +1414,14 @@ var Documents = class extends BaseResource {
|
|
|
1388
1414
|
* Get one canonical document by ID.
|
|
1389
1415
|
*/
|
|
1390
1416
|
async get(documentId) {
|
|
1391
|
-
return this.httpClient.get(`/
|
|
1417
|
+
return this.httpClient.get(this.endpoint(`/documents/${documentId}`));
|
|
1392
1418
|
}
|
|
1393
1419
|
/**
|
|
1394
1420
|
* List current-revision chunks for one canonical document.
|
|
1395
1421
|
*/
|
|
1396
1422
|
async listChunks(documentId, params) {
|
|
1397
1423
|
return this.httpClient.get(
|
|
1398
|
-
`/
|
|
1424
|
+
this.endpoint(`/documents/${documentId}/chunks`),
|
|
1399
1425
|
this.createChunkListRequestConfig(params)
|
|
1400
1426
|
);
|
|
1401
1427
|
}
|
|
@@ -1404,7 +1430,7 @@ var Documents = class extends BaseResource {
|
|
|
1404
1430
|
*/
|
|
1405
1431
|
async getChunk(documentId, documentChunkId, params) {
|
|
1406
1432
|
return this.httpClient.get(
|
|
1407
|
-
`/
|
|
1433
|
+
this.endpoint(`/documents/${documentId}/chunks/${documentChunkId}`),
|
|
1408
1434
|
this.createChunkGetRequestConfig(params)
|
|
1409
1435
|
);
|
|
1410
1436
|
}
|
|
@@ -1412,7 +1438,7 @@ var Documents = class extends BaseResource {
|
|
|
1412
1438
|
* Archive one canonical document by ID.
|
|
1413
1439
|
*/
|
|
1414
1440
|
async archive(documentId) {
|
|
1415
|
-
return this.httpClient.post(`/
|
|
1441
|
+
return this.httpClient.post(this.endpoint(`/documents/${documentId}/archive`));
|
|
1416
1442
|
}
|
|
1417
1443
|
createDocumentListRequestConfig(params) {
|
|
1418
1444
|
if (!params) {
|
|
@@ -1674,7 +1700,7 @@ function countChunkTypes(result) {
|
|
|
1674
1700
|
counts[chunk.type] += 1;
|
|
1675
1701
|
return counts;
|
|
1676
1702
|
},
|
|
1677
|
-
{ text: 0, image: 0, table: 0 }
|
|
1703
|
+
{ text: 0, image: 0, table: 0, page: 0 }
|
|
1678
1704
|
);
|
|
1679
1705
|
}
|
|
1680
1706
|
function toLocalKnowledgeDocument(stored) {
|
|
@@ -2001,19 +2027,40 @@ function createLocalDocumentIdForRemote(documentId) {
|
|
|
2001
2027
|
function indexChunks(result) {
|
|
2002
2028
|
return result.chunks.map((chunk, index) => {
|
|
2003
2029
|
const filePath = getChunkFilePath2(chunk);
|
|
2030
|
+
const readableContent = getReadableChunkContent(chunk);
|
|
2004
2031
|
return {
|
|
2005
2032
|
source: chunk,
|
|
2006
2033
|
position: index + 1,
|
|
2007
2034
|
chunkId: chunk.chunkId,
|
|
2008
2035
|
chunkType: chunk.type,
|
|
2036
|
+
contentSource: chunk.contentSource,
|
|
2009
2037
|
content: chunk.content,
|
|
2038
|
+
readableContent,
|
|
2010
2039
|
sectionPath: normalizeSectionPath(chunk.path, result.manifest.sourceFileName),
|
|
2011
2040
|
sourceChunkPath: chunk.path,
|
|
2012
2041
|
filePath,
|
|
2042
|
+
pageNumbers: getChunkPageNumbers(chunk.metadata),
|
|
2013
2043
|
metadata: chunk.metadata
|
|
2014
2044
|
};
|
|
2015
2045
|
});
|
|
2016
2046
|
}
|
|
2047
|
+
function getReadableChunkContent(chunk) {
|
|
2048
|
+
if (chunk.type !== "page") {
|
|
2049
|
+
return chunk.content;
|
|
2050
|
+
}
|
|
2051
|
+
const summary = chunk.metadata.summary;
|
|
2052
|
+
return typeof summary === "string" && summary.trim().length > 0 ? summary : chunk.content;
|
|
2053
|
+
}
|
|
2054
|
+
function getChunkPageNumbers(metadata) {
|
|
2055
|
+
const value = metadata.pageNums;
|
|
2056
|
+
if (!Array.isArray(value)) {
|
|
2057
|
+
return void 0;
|
|
2058
|
+
}
|
|
2059
|
+
const pageNumbers = value.filter(
|
|
2060
|
+
(pageNumber) => Number.isInteger(pageNumber) && pageNumber > 0
|
|
2061
|
+
);
|
|
2062
|
+
return pageNumbers.length > 0 ? [...new Set(pageNumbers)].sort((left, right) => left - right) : void 0;
|
|
2063
|
+
}
|
|
2017
2064
|
function getChunkFilePath2(chunk) {
|
|
2018
2065
|
if (chunk.type === "image" || chunk.type === "table") {
|
|
2019
2066
|
return chunk.filePath;
|
|
@@ -2087,7 +2134,7 @@ function createSectionFromChunk(pathValue, chunk) {
|
|
|
2087
2134
|
startChunk: chunk.position,
|
|
2088
2135
|
endChunk: chunk.position,
|
|
2089
2136
|
chunkCount: 1,
|
|
2090
|
-
typeCounts: { text: 0, image: 0, table: 0, [chunk.chunkType]: 1 },
|
|
2137
|
+
typeCounts: { text: 0, image: 0, table: 0, page: 0, [chunk.chunkType]: 1 },
|
|
2091
2138
|
children: []
|
|
2092
2139
|
};
|
|
2093
2140
|
}
|
|
@@ -2146,7 +2193,7 @@ function countIndexedTypes(chunks) {
|
|
|
2146
2193
|
counts[chunk.chunkType] += 1;
|
|
2147
2194
|
return counts;
|
|
2148
2195
|
},
|
|
2149
|
-
{ text: 0, image: 0, table: 0 }
|
|
2196
|
+
{ text: 0, image: 0, table: 0, page: 0 }
|
|
2150
2197
|
);
|
|
2151
2198
|
}
|
|
2152
2199
|
function isInSection(chunkSectionPath, sectionPath) {
|
|
@@ -2183,10 +2230,13 @@ function toReadChunk(chunk) {
|
|
|
2183
2230
|
position: chunk.position,
|
|
2184
2231
|
chunkId: chunk.chunkId,
|
|
2185
2232
|
chunkType: chunk.chunkType,
|
|
2233
|
+
contentSource: chunk.contentSource,
|
|
2186
2234
|
content: chunk.content,
|
|
2235
|
+
readableContent: chunk.readableContent,
|
|
2187
2236
|
sectionPath: chunk.sectionPath,
|
|
2188
2237
|
sourceChunkPath: chunk.sourceChunkPath,
|
|
2189
2238
|
filePath: chunk.filePath,
|
|
2239
|
+
pageNumbers: chunk.pageNumbers,
|
|
2190
2240
|
metadata: chunk.metadata
|
|
2191
2241
|
};
|
|
2192
2242
|
}
|
|
@@ -2238,6 +2288,7 @@ function toResultReference(result, documentByServerId) {
|
|
|
2238
2288
|
return {
|
|
2239
2289
|
localDocumentId: documentId ? documentByServerId.get(documentId)?.localDocumentId : void 0,
|
|
2240
2290
|
documentId,
|
|
2291
|
+
chunkId: result.chunkId,
|
|
2241
2292
|
sectionPath: result.source.sectionPath ?? void 0,
|
|
2242
2293
|
chunkType: result.chunkType,
|
|
2243
2294
|
score: result.score
|
|
@@ -2248,6 +2299,7 @@ function toRemoteSearchResult(result, documentByServerId) {
|
|
|
2248
2299
|
return {
|
|
2249
2300
|
localDocumentId: documentId ? documentByServerId.get(documentId)?.localDocumentId : void 0,
|
|
2250
2301
|
documentId,
|
|
2302
|
+
chunkId: result.chunkId,
|
|
2251
2303
|
chunkType: result.chunkType,
|
|
2252
2304
|
content: result.content,
|
|
2253
2305
|
score: result.score,
|