@ontos-ai/knowhere-sdk 0.5.0 → 0.6.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 +17 -0
- package/dist/index.d.mts +43 -11
- package/dist/index.d.ts +43 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,6 +198,9 @@ const response = await client.retrieval.query({
|
|
|
198
198
|
|
|
199
199
|
console.log(response.answerText); // LLM-generated answer
|
|
200
200
|
console.log(response.referencedChunks); // cited evidence chunks
|
|
201
|
+
console.log(response.evidenceText); // rendered evidence context, when returned
|
|
202
|
+
console.log(response.stopReason); // agentic termination reason, when returned
|
|
203
|
+
console.log(response.failureReason); // no-answer reason, when returned
|
|
201
204
|
|
|
202
205
|
for (const result of response.results) {
|
|
203
206
|
console.log(result.content);
|
|
@@ -218,6 +221,20 @@ result.source.sourceFileName;
|
|
|
218
221
|
result.source.sectionPath;
|
|
219
222
|
```
|
|
220
223
|
|
|
224
|
+
Agentic references expose the current retrieval citation fields:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
const reference = response.referencedChunks[0];
|
|
228
|
+
|
|
229
|
+
reference.chunkId;
|
|
230
|
+
reference.documentId;
|
|
231
|
+
reference.chunkType;
|
|
232
|
+
reference.sectionPath;
|
|
233
|
+
reference.filePath;
|
|
234
|
+
reference.jobId;
|
|
235
|
+
reference.assetUrl;
|
|
236
|
+
```
|
|
237
|
+
|
|
221
238
|
Use `documentId` to update or archive a document:
|
|
222
239
|
|
|
223
240
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -679,11 +679,11 @@ interface RetrievalQueryParams {
|
|
|
679
679
|
*/
|
|
680
680
|
interface RetrievalSource {
|
|
681
681
|
/** Stable document identifier */
|
|
682
|
-
documentId?: string;
|
|
682
|
+
documentId?: string | null;
|
|
683
683
|
/** Original source file name */
|
|
684
|
-
sourceFileName?: string;
|
|
684
|
+
sourceFileName?: string | null;
|
|
685
685
|
/** Human-readable section path */
|
|
686
|
-
sectionPath?: string;
|
|
686
|
+
sectionPath?: string | null;
|
|
687
687
|
}
|
|
688
688
|
/**
|
|
689
689
|
* Canonical chunk result returned by retrieval query.
|
|
@@ -693,15 +693,39 @@ interface RetrievalResult {
|
|
|
693
693
|
content: string;
|
|
694
694
|
/** Chunk type, for example text, image, or table */
|
|
695
695
|
chunkType: string;
|
|
696
|
-
/** Retrieval score returned by the API */
|
|
697
|
-
score: number;
|
|
696
|
+
/** Retrieval score returned by the API. Null when no score is available (agentic navigation-only results). */
|
|
697
|
+
score: number | null;
|
|
698
698
|
/** Presigned asset URL for media chunks when available */
|
|
699
699
|
assetUrl?: string;
|
|
700
700
|
/** Source reference for this result */
|
|
701
701
|
source: RetrievalSource;
|
|
702
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Cited evidence chunk returned by agentic retrieval.
|
|
705
|
+
*/
|
|
706
|
+
interface RetrievalReferencedChunk {
|
|
707
|
+
/** Parser-provided chunk identifier */
|
|
708
|
+
chunkId: string;
|
|
709
|
+
/** Stable document identifier */
|
|
710
|
+
documentId: string;
|
|
711
|
+
/** Chunk type, for example text, image, or table */
|
|
712
|
+
chunkType: string;
|
|
713
|
+
/** Human-readable section path */
|
|
714
|
+
sectionPath: string;
|
|
715
|
+
/** Generated artifact file path for media chunks */
|
|
716
|
+
filePath?: string | null;
|
|
717
|
+
/** Published job identifier for the referenced chunk */
|
|
718
|
+
jobId?: string | null;
|
|
719
|
+
/** Presigned asset URL for media chunks when available */
|
|
720
|
+
assetUrl?: string | null;
|
|
721
|
+
}
|
|
703
722
|
/**
|
|
704
723
|
* Response from POST /v1/retrieval/query.
|
|
724
|
+
*
|
|
725
|
+
* Three PRIMARY output fields for downstream agent consumption:
|
|
726
|
+
* - `evidenceText`: hierarchical evidence tree for LLM context
|
|
727
|
+
* - `decisionTrace`: per-step navigation decisions (includes stop/failure)
|
|
728
|
+
* - `referencedChunks`: structured chunk citations for follow-up queries
|
|
705
729
|
*/
|
|
706
730
|
interface RetrievalQueryResponse {
|
|
707
731
|
/** Namespace searched by the API */
|
|
@@ -709,11 +733,19 @@ interface RetrievalQueryResponse {
|
|
|
709
733
|
/** Echoed query text */
|
|
710
734
|
query: string;
|
|
711
735
|
/** Retrieval router path used by the API for this query */
|
|
712
|
-
routerUsed
|
|
713
|
-
/** LLM-generated natural-language answer
|
|
714
|
-
answerText
|
|
715
|
-
/** Cited evidence chunks with asset URLs
|
|
716
|
-
referencedChunks
|
|
736
|
+
routerUsed: string;
|
|
737
|
+
/** LLM-generated natural-language answer, or null when no answer was produced */
|
|
738
|
+
answerText: string | null;
|
|
739
|
+
/** Cited evidence chunks with asset URLs when available */
|
|
740
|
+
referencedChunks: RetrievalReferencedChunk[];
|
|
741
|
+
/** Tree-structured evidence text rendered by the agentic navigator */
|
|
742
|
+
evidenceText?: string | null;
|
|
743
|
+
/** Reason why the agentic run stopped (e.g. answer_done, not_found) */
|
|
744
|
+
stopReason?: string | null;
|
|
745
|
+
/** Semantic failure reason when the agentic evidence is insufficient */
|
|
746
|
+
failureReason?: string | null;
|
|
747
|
+
/** Per-step navigation decisions from agentic retrieval, including terminal stop/failure */
|
|
748
|
+
decisionTrace?: Record<string, unknown>[];
|
|
717
749
|
/** Ranked retrieval results */
|
|
718
750
|
results: RetrievalResult[];
|
|
719
751
|
}
|
|
@@ -1056,4 +1088,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1056
1088
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1057
1089
|
}
|
|
1058
1090
|
|
|
1059
|
-
export { APIError, 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 DocumentListResponse, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, type LoadOptions, 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 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 };
|
|
1091
|
+
export { APIError, 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 DocumentListResponse, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, type LoadOptions, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -679,11 +679,11 @@ interface RetrievalQueryParams {
|
|
|
679
679
|
*/
|
|
680
680
|
interface RetrievalSource {
|
|
681
681
|
/** Stable document identifier */
|
|
682
|
-
documentId?: string;
|
|
682
|
+
documentId?: string | null;
|
|
683
683
|
/** Original source file name */
|
|
684
|
-
sourceFileName?: string;
|
|
684
|
+
sourceFileName?: string | null;
|
|
685
685
|
/** Human-readable section path */
|
|
686
|
-
sectionPath?: string;
|
|
686
|
+
sectionPath?: string | null;
|
|
687
687
|
}
|
|
688
688
|
/**
|
|
689
689
|
* Canonical chunk result returned by retrieval query.
|
|
@@ -693,15 +693,39 @@ interface RetrievalResult {
|
|
|
693
693
|
content: string;
|
|
694
694
|
/** Chunk type, for example text, image, or table */
|
|
695
695
|
chunkType: string;
|
|
696
|
-
/** Retrieval score returned by the API */
|
|
697
|
-
score: number;
|
|
696
|
+
/** Retrieval score returned by the API. Null when no score is available (agentic navigation-only results). */
|
|
697
|
+
score: number | null;
|
|
698
698
|
/** Presigned asset URL for media chunks when available */
|
|
699
699
|
assetUrl?: string;
|
|
700
700
|
/** Source reference for this result */
|
|
701
701
|
source: RetrievalSource;
|
|
702
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Cited evidence chunk returned by agentic retrieval.
|
|
705
|
+
*/
|
|
706
|
+
interface RetrievalReferencedChunk {
|
|
707
|
+
/** Parser-provided chunk identifier */
|
|
708
|
+
chunkId: string;
|
|
709
|
+
/** Stable document identifier */
|
|
710
|
+
documentId: string;
|
|
711
|
+
/** Chunk type, for example text, image, or table */
|
|
712
|
+
chunkType: string;
|
|
713
|
+
/** Human-readable section path */
|
|
714
|
+
sectionPath: string;
|
|
715
|
+
/** Generated artifact file path for media chunks */
|
|
716
|
+
filePath?: string | null;
|
|
717
|
+
/** Published job identifier for the referenced chunk */
|
|
718
|
+
jobId?: string | null;
|
|
719
|
+
/** Presigned asset URL for media chunks when available */
|
|
720
|
+
assetUrl?: string | null;
|
|
721
|
+
}
|
|
703
722
|
/**
|
|
704
723
|
* Response from POST /v1/retrieval/query.
|
|
724
|
+
*
|
|
725
|
+
* Three PRIMARY output fields for downstream agent consumption:
|
|
726
|
+
* - `evidenceText`: hierarchical evidence tree for LLM context
|
|
727
|
+
* - `decisionTrace`: per-step navigation decisions (includes stop/failure)
|
|
728
|
+
* - `referencedChunks`: structured chunk citations for follow-up queries
|
|
705
729
|
*/
|
|
706
730
|
interface RetrievalQueryResponse {
|
|
707
731
|
/** Namespace searched by the API */
|
|
@@ -709,11 +733,19 @@ interface RetrievalQueryResponse {
|
|
|
709
733
|
/** Echoed query text */
|
|
710
734
|
query: string;
|
|
711
735
|
/** Retrieval router path used by the API for this query */
|
|
712
|
-
routerUsed
|
|
713
|
-
/** LLM-generated natural-language answer
|
|
714
|
-
answerText
|
|
715
|
-
/** Cited evidence chunks with asset URLs
|
|
716
|
-
referencedChunks
|
|
736
|
+
routerUsed: string;
|
|
737
|
+
/** LLM-generated natural-language answer, or null when no answer was produced */
|
|
738
|
+
answerText: string | null;
|
|
739
|
+
/** Cited evidence chunks with asset URLs when available */
|
|
740
|
+
referencedChunks: RetrievalReferencedChunk[];
|
|
741
|
+
/** Tree-structured evidence text rendered by the agentic navigator */
|
|
742
|
+
evidenceText?: string | null;
|
|
743
|
+
/** Reason why the agentic run stopped (e.g. answer_done, not_found) */
|
|
744
|
+
stopReason?: string | null;
|
|
745
|
+
/** Semantic failure reason when the agentic evidence is insufficient */
|
|
746
|
+
failureReason?: string | null;
|
|
747
|
+
/** Per-step navigation decisions from agentic retrieval, including terminal stop/failure */
|
|
748
|
+
decisionTrace?: Record<string, unknown>[];
|
|
717
749
|
/** Ranked retrieval results */
|
|
718
750
|
results: RetrievalResult[];
|
|
719
751
|
}
|
|
@@ -1056,4 +1088,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1056
1088
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1057
1089
|
}
|
|
1058
1090
|
|
|
1059
|
-
export { APIError, 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 DocumentListResponse, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, type LoadOptions, 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 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 };
|
|
1091
|
+
export { APIError, 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 DocumentListResponse, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, type LoadOptions, 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 };
|