@ontos-ai/knowhere-sdk 2.1.2 → 2.2.0-beta.20260716073420
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 +50 -0
- package/dist/index.d.mts +72 -3
- package/dist/index.d.ts +72 -3
- package/dist/index.js +47 -18
- package/dist/index.mjs +45 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -145,6 +145,56 @@ const result = await client.parse({
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### Bring Your Own Key (BYOK)
|
|
149
|
+
|
|
150
|
+
Pass per-request LLM credentials via `llmConfig` on parse/job create and
|
|
151
|
+
retrieval queries. Flat root applies to both channels; use `models` for
|
|
152
|
+
different model ids on the same endpoint, or `text` / `vision` for different
|
|
153
|
+
provider endpoints. Use camelCase in TypeScript; the HTTP client serializes to
|
|
154
|
+
snake_case on the wire.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// Multimodal shorthand — one model for text + vision
|
|
158
|
+
const llmConfig = {
|
|
159
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
160
|
+
model: 'gpt-4o',
|
|
161
|
+
baseUrl: 'https://api.openai.com/v1',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Same endpoint, different models per channel
|
|
165
|
+
const modelsConfig = {
|
|
166
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
167
|
+
baseUrl: 'https://api.openai.com/v1',
|
|
168
|
+
models: { text: 'gpt-4o-mini', vision: 'gpt-4o' },
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// Or two different endpoints
|
|
172
|
+
const splitLlmConfig = {
|
|
173
|
+
text: {
|
|
174
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
175
|
+
model: 'gpt-4o-mini',
|
|
176
|
+
baseUrl: 'https://api.openai.com/v1',
|
|
177
|
+
},
|
|
178
|
+
vision: {
|
|
179
|
+
apiKey: process.env.DASHSCOPE_API_KEY,
|
|
180
|
+
model: 'qwen-vl-max',
|
|
181
|
+
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const result = await client.parse({
|
|
186
|
+
url: 'https://example.com/doc.pdf',
|
|
187
|
+
llmConfig: modelsConfig,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const response = await client.retrieval.query({
|
|
191
|
+
namespace: 'support-center',
|
|
192
|
+
query: 'What is the refund policy?',
|
|
193
|
+
useAgentic: true,
|
|
194
|
+
llmConfig: splitLlmConfig,
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
148
198
|
### Page Citation Assets
|
|
149
199
|
|
|
150
200
|
Page citation assets are generated by Knowhere during page-memory parsing. The
|
package/dist/index.d.mts
CHANGED
|
@@ -516,6 +516,47 @@ interface WebhookConfig {
|
|
|
516
516
|
/** Webhook URL to notify on job completion */
|
|
517
517
|
url: string;
|
|
518
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Per-provider BYOK credentials and routing overrides.
|
|
521
|
+
*/
|
|
522
|
+
interface LlmProviderConfig {
|
|
523
|
+
/** Provider API key */
|
|
524
|
+
apiKey?: string;
|
|
525
|
+
/** Model identifier */
|
|
526
|
+
model?: string;
|
|
527
|
+
/** Provider base URL override */
|
|
528
|
+
baseUrl?: string;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Per-channel model ids that share root apiKey / baseUrl.
|
|
532
|
+
*/
|
|
533
|
+
interface LlmModelsConfig {
|
|
534
|
+
/** Text / planning model id */
|
|
535
|
+
text?: string;
|
|
536
|
+
/** Vision / VLM model id */
|
|
537
|
+
vision?: string;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Bring-your-own-key LLM configuration.
|
|
541
|
+
*
|
|
542
|
+
* Flat root (`apiKey` / `model` / `baseUrl`) applies to both channels.
|
|
543
|
+
* Use `models` for different model ids on the same endpoint, or `text` /
|
|
544
|
+
* `vision` objects for different provider endpoints.
|
|
545
|
+
*/
|
|
546
|
+
interface LlmConfig {
|
|
547
|
+
/** Default provider API key (with model/models + baseUrl) */
|
|
548
|
+
apiKey?: string;
|
|
549
|
+
/** Default model for both channels (overridden by models.*) */
|
|
550
|
+
model?: string;
|
|
551
|
+
/** Default OpenAI-compatible base URL */
|
|
552
|
+
baseUrl?: string;
|
|
553
|
+
/** Per-channel model ids sharing root apiKey / baseUrl */
|
|
554
|
+
models?: LlmModelsConfig;
|
|
555
|
+
/** Text / chat credentials (replaces root for text) */
|
|
556
|
+
text?: LlmProviderConfig;
|
|
557
|
+
/** Vision / VLM credentials (replaces root for vision) */
|
|
558
|
+
vision?: LlmProviderConfig;
|
|
559
|
+
}
|
|
519
560
|
/**
|
|
520
561
|
* Client-provided display metadata copied onto the published document.
|
|
521
562
|
*/
|
|
@@ -540,6 +581,8 @@ interface CreateJobParams {
|
|
|
540
581
|
documentMetadata?: DocumentMetadata;
|
|
541
582
|
/** Parsing configuration */
|
|
542
583
|
parsingParams?: ParsingParams;
|
|
584
|
+
/** Bring-your-own-key LLM credentials for this job */
|
|
585
|
+
llmConfig?: LlmConfig;
|
|
543
586
|
/** Webhook configuration */
|
|
544
587
|
webhook?: WebhookConfig;
|
|
545
588
|
}
|
|
@@ -621,6 +664,8 @@ interface ParseParams {
|
|
|
621
664
|
* assets into application-owned storage before the result is returned.
|
|
622
665
|
*/
|
|
623
666
|
storageAdapter?: KnowhereAssetStorageOptions;
|
|
667
|
+
/** Bring-your-own-key LLM credentials for this parse */
|
|
668
|
+
llmConfig?: LlmConfig;
|
|
624
669
|
/** Webhook configuration */
|
|
625
670
|
webhook?: WebhookConfig;
|
|
626
671
|
/** Upload progress callback */
|
|
@@ -733,7 +778,10 @@ declare abstract class BaseResource {
|
|
|
733
778
|
declare class Jobs extends BaseResource {
|
|
734
779
|
private pendingUploadJobs;
|
|
735
780
|
/**
|
|
736
|
-
* Create a new parsing job
|
|
781
|
+
* Create a new parsing job.
|
|
782
|
+
*
|
|
783
|
+
* Auto-attaches `documentMetadata.createdByClient` / `clientVersion` for
|
|
784
|
+
* OSS telemetry. Caller-provided metadata keys win; defaults fill gaps only.
|
|
737
785
|
*/
|
|
738
786
|
create(params: CreateJobParams): Promise<Job>;
|
|
739
787
|
/**
|
|
@@ -815,6 +863,8 @@ interface RetrievalQueryParams {
|
|
|
815
863
|
excludeDocumentIds?: string[];
|
|
816
864
|
/** Document sections to exclude for this request only */
|
|
817
865
|
excludeSections?: RetrievalSectionExclusion[];
|
|
866
|
+
/** Bring-your-own-key LLM credentials for this query */
|
|
867
|
+
llmConfig?: LlmConfig;
|
|
818
868
|
}
|
|
819
869
|
/**
|
|
820
870
|
* Caller-facing source reference attached to a retrieval result.
|
|
@@ -1488,7 +1538,26 @@ declare class Knowhere {
|
|
|
1488
1538
|
startParse(params: ParseParams): Promise<Job>;
|
|
1489
1539
|
}
|
|
1490
1540
|
|
|
1491
|
-
declare const VERSION = "
|
|
1541
|
+
declare const VERSION = "2.1.3";
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* Official Knowhere client identity written into job `document_metadata`.
|
|
1545
|
+
*
|
|
1546
|
+
* Wire format (snake_case on the wire after HTTP serialization):
|
|
1547
|
+
* `{ created_by_client, client_version }`.
|
|
1548
|
+
*
|
|
1549
|
+
* Merge rule used by every official client: caller-provided keys win;
|
|
1550
|
+
* defaults only fill keys that are missing.
|
|
1551
|
+
*/
|
|
1552
|
+
declare const NODE_SDK_DOCUMENT_METADATA_DEFAULTS: {
|
|
1553
|
+
readonly createdByClient: "node-sdk";
|
|
1554
|
+
readonly clientVersion: "2.1.3";
|
|
1555
|
+
};
|
|
1556
|
+
/**
|
|
1557
|
+
* Merge official-client defaults under caller-provided document metadata.
|
|
1558
|
+
* Existing keys on `provided` are preserved; defaults fill gaps only.
|
|
1559
|
+
*/
|
|
1560
|
+
declare function mergeDocumentMetadataDefaults(defaults: DocumentMetadata, provided?: DocumentMetadata | null): DocumentMetadata;
|
|
1492
1561
|
|
|
1493
1562
|
declare function storeParseResultAssets(result: ParseResult, options?: KnowhereAssetStorageOptions): Promise<KnowhereAssetStorageResult>;
|
|
1494
1563
|
|
|
@@ -1651,4 +1720,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1651
1720
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1652
1721
|
}
|
|
1653
1722
|
|
|
1654
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, DiskParsedDocumentStorage, 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, type DocumentPageCitationSource, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, type KnowhereAssetStorageAdapter, type KnowhereAssetStorageBody, type KnowhereAssetStorageHead, type KnowhereAssetStorageObject, type KnowhereAssetStorageOptions, type KnowhereAssetStorageResult, type KnowhereAssetStorageWriteResult, 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 KnowledgeImportJobResultParams, type KnowledgeJobResultResponse, type KnowledgeLoadJobResultParams, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeParsedStorageOptions, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type KnowledgeSyncParsedDocumentParams, type KnowledgeSyncParsedDocumentResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type PageChunk, type PageCitationAsset, type PageCitationAssetContentType, type PageCitationAssetSource, type ParseParams, type ParseResult, type ParsedDocumentCommit, type ParsedDocumentCommitSource, type ParsedDocumentObject, type ParsedDocumentObjectHead, type ParsedDocumentObjectParams, type ParsedDocumentRevisionParams, type ParsedDocumentStorage, type ParsedDocumentStorageConfig, type ParsedDocumentStorageDocument, type ParsedDocumentStorageLimits, type ParsedDocumentSyncProgress, type ParsedDocumentSyncScheduler, type ParsedDocumentWriteObjectParams, type ParsedDocumentWriteObjectResult, 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, storeParseResultAssets, syncParseResultToParsedDocumentStorage };
|
|
1723
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, DiskParsedDocumentStorage, 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, type DocumentPageCitationSource, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, type KnowhereAssetStorageAdapter, type KnowhereAssetStorageBody, type KnowhereAssetStorageHead, type KnowhereAssetStorageObject, type KnowhereAssetStorageOptions, type KnowhereAssetStorageResult, type KnowhereAssetStorageWriteResult, 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 KnowledgeImportJobResultParams, type KnowledgeJobResultResponse, type KnowledgeLoadJobResultParams, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeParsedStorageOptions, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type KnowledgeSyncParsedDocumentParams, type KnowledgeSyncParsedDocumentResponse, type LlmConfig, type LlmModelsConfig, type LlmProviderConfig, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NODE_SDK_DOCUMENT_METADATA_DEFAULTS, NetworkError, NotFoundError, type PageChunk, type PageCitationAsset, type PageCitationAssetContentType, type PageCitationAssetSource, type ParseParams, type ParseResult, type ParsedDocumentCommit, type ParsedDocumentCommitSource, type ParsedDocumentObject, type ParsedDocumentObjectHead, type ParsedDocumentObjectParams, type ParsedDocumentRevisionParams, type ParsedDocumentStorage, type ParsedDocumentStorageConfig, type ParsedDocumentStorageDocument, type ParsedDocumentStorageLimits, type ParsedDocumentSyncProgress, type ParsedDocumentSyncScheduler, type ParsedDocumentWriteObjectParams, type ParsedDocumentWriteObjectResult, 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, mergeDocumentMetadataDefaults, storeParseResultAssets, syncParseResultToParsedDocumentStorage };
|
package/dist/index.d.ts
CHANGED
|
@@ -516,6 +516,47 @@ interface WebhookConfig {
|
|
|
516
516
|
/** Webhook URL to notify on job completion */
|
|
517
517
|
url: string;
|
|
518
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Per-provider BYOK credentials and routing overrides.
|
|
521
|
+
*/
|
|
522
|
+
interface LlmProviderConfig {
|
|
523
|
+
/** Provider API key */
|
|
524
|
+
apiKey?: string;
|
|
525
|
+
/** Model identifier */
|
|
526
|
+
model?: string;
|
|
527
|
+
/** Provider base URL override */
|
|
528
|
+
baseUrl?: string;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Per-channel model ids that share root apiKey / baseUrl.
|
|
532
|
+
*/
|
|
533
|
+
interface LlmModelsConfig {
|
|
534
|
+
/** Text / planning model id */
|
|
535
|
+
text?: string;
|
|
536
|
+
/** Vision / VLM model id */
|
|
537
|
+
vision?: string;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Bring-your-own-key LLM configuration.
|
|
541
|
+
*
|
|
542
|
+
* Flat root (`apiKey` / `model` / `baseUrl`) applies to both channels.
|
|
543
|
+
* Use `models` for different model ids on the same endpoint, or `text` /
|
|
544
|
+
* `vision` objects for different provider endpoints.
|
|
545
|
+
*/
|
|
546
|
+
interface LlmConfig {
|
|
547
|
+
/** Default provider API key (with model/models + baseUrl) */
|
|
548
|
+
apiKey?: string;
|
|
549
|
+
/** Default model for both channels (overridden by models.*) */
|
|
550
|
+
model?: string;
|
|
551
|
+
/** Default OpenAI-compatible base URL */
|
|
552
|
+
baseUrl?: string;
|
|
553
|
+
/** Per-channel model ids sharing root apiKey / baseUrl */
|
|
554
|
+
models?: LlmModelsConfig;
|
|
555
|
+
/** Text / chat credentials (replaces root for text) */
|
|
556
|
+
text?: LlmProviderConfig;
|
|
557
|
+
/** Vision / VLM credentials (replaces root for vision) */
|
|
558
|
+
vision?: LlmProviderConfig;
|
|
559
|
+
}
|
|
519
560
|
/**
|
|
520
561
|
* Client-provided display metadata copied onto the published document.
|
|
521
562
|
*/
|
|
@@ -540,6 +581,8 @@ interface CreateJobParams {
|
|
|
540
581
|
documentMetadata?: DocumentMetadata;
|
|
541
582
|
/** Parsing configuration */
|
|
542
583
|
parsingParams?: ParsingParams;
|
|
584
|
+
/** Bring-your-own-key LLM credentials for this job */
|
|
585
|
+
llmConfig?: LlmConfig;
|
|
543
586
|
/** Webhook configuration */
|
|
544
587
|
webhook?: WebhookConfig;
|
|
545
588
|
}
|
|
@@ -621,6 +664,8 @@ interface ParseParams {
|
|
|
621
664
|
* assets into application-owned storage before the result is returned.
|
|
622
665
|
*/
|
|
623
666
|
storageAdapter?: KnowhereAssetStorageOptions;
|
|
667
|
+
/** Bring-your-own-key LLM credentials for this parse */
|
|
668
|
+
llmConfig?: LlmConfig;
|
|
624
669
|
/** Webhook configuration */
|
|
625
670
|
webhook?: WebhookConfig;
|
|
626
671
|
/** Upload progress callback */
|
|
@@ -733,7 +778,10 @@ declare abstract class BaseResource {
|
|
|
733
778
|
declare class Jobs extends BaseResource {
|
|
734
779
|
private pendingUploadJobs;
|
|
735
780
|
/**
|
|
736
|
-
* Create a new parsing job
|
|
781
|
+
* Create a new parsing job.
|
|
782
|
+
*
|
|
783
|
+
* Auto-attaches `documentMetadata.createdByClient` / `clientVersion` for
|
|
784
|
+
* OSS telemetry. Caller-provided metadata keys win; defaults fill gaps only.
|
|
737
785
|
*/
|
|
738
786
|
create(params: CreateJobParams): Promise<Job>;
|
|
739
787
|
/**
|
|
@@ -815,6 +863,8 @@ interface RetrievalQueryParams {
|
|
|
815
863
|
excludeDocumentIds?: string[];
|
|
816
864
|
/** Document sections to exclude for this request only */
|
|
817
865
|
excludeSections?: RetrievalSectionExclusion[];
|
|
866
|
+
/** Bring-your-own-key LLM credentials for this query */
|
|
867
|
+
llmConfig?: LlmConfig;
|
|
818
868
|
}
|
|
819
869
|
/**
|
|
820
870
|
* Caller-facing source reference attached to a retrieval result.
|
|
@@ -1488,7 +1538,26 @@ declare class Knowhere {
|
|
|
1488
1538
|
startParse(params: ParseParams): Promise<Job>;
|
|
1489
1539
|
}
|
|
1490
1540
|
|
|
1491
|
-
declare const VERSION = "
|
|
1541
|
+
declare const VERSION = "2.1.3";
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* Official Knowhere client identity written into job `document_metadata`.
|
|
1545
|
+
*
|
|
1546
|
+
* Wire format (snake_case on the wire after HTTP serialization):
|
|
1547
|
+
* `{ created_by_client, client_version }`.
|
|
1548
|
+
*
|
|
1549
|
+
* Merge rule used by every official client: caller-provided keys win;
|
|
1550
|
+
* defaults only fill keys that are missing.
|
|
1551
|
+
*/
|
|
1552
|
+
declare const NODE_SDK_DOCUMENT_METADATA_DEFAULTS: {
|
|
1553
|
+
readonly createdByClient: "node-sdk";
|
|
1554
|
+
readonly clientVersion: "2.1.3";
|
|
1555
|
+
};
|
|
1556
|
+
/**
|
|
1557
|
+
* Merge official-client defaults under caller-provided document metadata.
|
|
1558
|
+
* Existing keys on `provided` are preserved; defaults fill gaps only.
|
|
1559
|
+
*/
|
|
1560
|
+
declare function mergeDocumentMetadataDefaults(defaults: DocumentMetadata, provided?: DocumentMetadata | null): DocumentMetadata;
|
|
1492
1561
|
|
|
1493
1562
|
declare function storeParseResultAssets(result: ParseResult, options?: KnowhereAssetStorageOptions): Promise<KnowhereAssetStorageResult>;
|
|
1494
1563
|
|
|
@@ -1651,4 +1720,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1651
1720
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1652
1721
|
}
|
|
1653
1722
|
|
|
1654
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, DiskParsedDocumentStorage, 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, type DocumentPageCitationSource, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, type KnowhereAssetStorageAdapter, type KnowhereAssetStorageBody, type KnowhereAssetStorageHead, type KnowhereAssetStorageObject, type KnowhereAssetStorageOptions, type KnowhereAssetStorageResult, type KnowhereAssetStorageWriteResult, 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 KnowledgeImportJobResultParams, type KnowledgeJobResultResponse, type KnowledgeLoadJobResultParams, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeParsedStorageOptions, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type KnowledgeSyncParsedDocumentParams, type KnowledgeSyncParsedDocumentResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type PageChunk, type PageCitationAsset, type PageCitationAssetContentType, type PageCitationAssetSource, type ParseParams, type ParseResult, type ParsedDocumentCommit, type ParsedDocumentCommitSource, type ParsedDocumentObject, type ParsedDocumentObjectHead, type ParsedDocumentObjectParams, type ParsedDocumentRevisionParams, type ParsedDocumentStorage, type ParsedDocumentStorageConfig, type ParsedDocumentStorageDocument, type ParsedDocumentStorageLimits, type ParsedDocumentSyncProgress, type ParsedDocumentSyncScheduler, type ParsedDocumentWriteObjectParams, type ParsedDocumentWriteObjectResult, 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, storeParseResultAssets, syncParseResultToParsedDocumentStorage };
|
|
1723
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, DiskParsedDocumentStorage, 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, type DocumentPageCitationSource, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, type KnowhereAssetStorageAdapter, type KnowhereAssetStorageBody, type KnowhereAssetStorageHead, type KnowhereAssetStorageObject, type KnowhereAssetStorageOptions, type KnowhereAssetStorageResult, type KnowhereAssetStorageWriteResult, 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 KnowledgeImportJobResultParams, type KnowledgeJobResultResponse, type KnowledgeLoadJobResultParams, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeParsedStorageOptions, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type KnowledgeSyncParsedDocumentParams, type KnowledgeSyncParsedDocumentResponse, type LlmConfig, type LlmModelsConfig, type LlmProviderConfig, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NODE_SDK_DOCUMENT_METADATA_DEFAULTS, NetworkError, NotFoundError, type PageChunk, type PageCitationAsset, type PageCitationAssetContentType, type PageCitationAssetSource, type ParseParams, type ParseResult, type ParsedDocumentCommit, type ParsedDocumentCommitSource, type ParsedDocumentObject, type ParsedDocumentObjectHead, type ParsedDocumentObjectParams, type ParsedDocumentRevisionParams, type ParsedDocumentStorage, type ParsedDocumentStorageConfig, type ParsedDocumentStorageDocument, type ParsedDocumentStorageLimits, type ParsedDocumentSyncProgress, type ParsedDocumentSyncScheduler, type ParsedDocumentWriteObjectParams, type ParsedDocumentWriteObjectResult, 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, mergeDocumentMetadataDefaults, storeParseResultAssets, syncParseResultToParsedDocumentStorage };
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(index_exports, {
|
|
|
46
46
|
KnowhereError: () => KnowhereError,
|
|
47
47
|
Knowledge: () => Knowledge,
|
|
48
48
|
LocalKnowledgeStore: () => LocalKnowledgeStore,
|
|
49
|
+
NODE_SDK_DOCUMENT_METADATA_DEFAULTS: () => NODE_SDK_DOCUMENT_METADATA_DEFAULTS,
|
|
49
50
|
NetworkError: () => NetworkError,
|
|
50
51
|
NotFoundError: () => NotFoundError,
|
|
51
52
|
PaymentRequiredError: () => PaymentRequiredError,
|
|
@@ -58,6 +59,7 @@ __export(index_exports, {
|
|
|
58
59
|
VERSION: () => VERSION,
|
|
59
60
|
ValidationError: () => ValidationError,
|
|
60
61
|
default: () => Knowhere,
|
|
62
|
+
mergeDocumentMetadataDefaults: () => mergeDocumentMetadataDefaults,
|
|
61
63
|
storeParseResultAssets: () => storeParseResultAssets,
|
|
62
64
|
syncParseResultToParsedDocumentStorage: () => syncParseResultToParsedDocumentStorage
|
|
63
65
|
});
|
|
@@ -70,7 +72,7 @@ var import_path3 = __toESM(require("path"));
|
|
|
70
72
|
var import_axios = __toESM(require("axios"));
|
|
71
73
|
|
|
72
74
|
// src/version.ts
|
|
73
|
-
var VERSION = "
|
|
75
|
+
var VERSION = "2.1.3";
|
|
74
76
|
|
|
75
77
|
// src/constants.ts
|
|
76
78
|
var DEFAULT_BASE_URL = "https://api.knowhereto.ai";
|
|
@@ -764,6 +766,18 @@ var BaseResource = class {
|
|
|
764
766
|
}
|
|
765
767
|
};
|
|
766
768
|
|
|
769
|
+
// src/lib/document-metadata.ts
|
|
770
|
+
var NODE_SDK_DOCUMENT_METADATA_DEFAULTS = {
|
|
771
|
+
createdByClient: "node-sdk",
|
|
772
|
+
clientVersion: VERSION
|
|
773
|
+
};
|
|
774
|
+
function mergeDocumentMetadataDefaults(defaults, provided) {
|
|
775
|
+
if (!provided) {
|
|
776
|
+
return { ...defaults };
|
|
777
|
+
}
|
|
778
|
+
return { ...defaults, ...provided };
|
|
779
|
+
}
|
|
780
|
+
|
|
767
781
|
// src/lib/upload.ts
|
|
768
782
|
var import_fs = require("fs");
|
|
769
783
|
async function uploadFile(httpClient, uploadUrl, file, options) {
|
|
@@ -1356,10 +1370,20 @@ function isMissingFileError(error) {
|
|
|
1356
1370
|
var Jobs = class extends BaseResource {
|
|
1357
1371
|
pendingUploadJobs = /* @__PURE__ */ new Map();
|
|
1358
1372
|
/**
|
|
1359
|
-
* Create a new parsing job
|
|
1373
|
+
* Create a new parsing job.
|
|
1374
|
+
*
|
|
1375
|
+
* Auto-attaches `documentMetadata.createdByClient` / `clientVersion` for
|
|
1376
|
+
* OSS telemetry. Caller-provided metadata keys win; defaults fill gaps only.
|
|
1360
1377
|
*/
|
|
1361
1378
|
async create(params) {
|
|
1362
|
-
const
|
|
1379
|
+
const documentMetadata = mergeDocumentMetadataDefaults(
|
|
1380
|
+
NODE_SDK_DOCUMENT_METADATA_DEFAULTS,
|
|
1381
|
+
params.documentMetadata
|
|
1382
|
+
);
|
|
1383
|
+
const job = await this.httpClient.post(this.endpoint("/jobs"), {
|
|
1384
|
+
...params,
|
|
1385
|
+
documentMetadata
|
|
1386
|
+
});
|
|
1363
1387
|
if (job.uploadUrl) {
|
|
1364
1388
|
this.pendingUploadJobs.set(job.jobId, job);
|
|
1365
1389
|
}
|
|
@@ -3099,16 +3123,23 @@ var Knowledge = class _Knowledge {
|
|
|
3099
3123
|
if (!commit) {
|
|
3100
3124
|
return null;
|
|
3101
3125
|
}
|
|
3102
|
-
const manifestObject = await
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3126
|
+
const [manifestObject, chunksObject, docNavObject] = await Promise.all([
|
|
3127
|
+
parsedStorageConfig.storage.readObject({
|
|
3128
|
+
documentId,
|
|
3129
|
+
revisionKey,
|
|
3130
|
+
path: "manifest.json"
|
|
3131
|
+
}),
|
|
3132
|
+
parsedStorageConfig.storage.readObject({
|
|
3133
|
+
documentId,
|
|
3134
|
+
revisionKey,
|
|
3135
|
+
path: "chunks.json"
|
|
3136
|
+
}),
|
|
3137
|
+
parsedStorageConfig.storage.readObject({
|
|
3138
|
+
documentId,
|
|
3139
|
+
revisionKey,
|
|
3140
|
+
path: "doc_nav.json"
|
|
3141
|
+
})
|
|
3142
|
+
]);
|
|
3112
3143
|
if (!manifestObject || !chunksObject) {
|
|
3113
3144
|
return null;
|
|
3114
3145
|
}
|
|
@@ -3117,11 +3148,6 @@ var Knowledge = class _Knowledge {
|
|
|
3117
3148
|
payload: readJsonObject(chunksObject),
|
|
3118
3149
|
sourceFileName: manifest.sourceFileName
|
|
3119
3150
|
});
|
|
3120
|
-
const docNavObject = await parsedStorageConfig.storage.readObject({
|
|
3121
|
-
documentId,
|
|
3122
|
-
revisionKey,
|
|
3123
|
-
path: "doc_nav.json"
|
|
3124
|
-
});
|
|
3125
3151
|
const docNav = docNavObject ? readJsonObject(docNavObject) : void 0;
|
|
3126
3152
|
return {
|
|
3127
3153
|
commit,
|
|
@@ -4265,6 +4291,7 @@ var Knowhere = class {
|
|
|
4265
4291
|
documentId: params.documentId,
|
|
4266
4292
|
documentMetadata: params.documentMetadata,
|
|
4267
4293
|
parsingParams: buildParsingParams(params),
|
|
4294
|
+
llmConfig: params.llmConfig,
|
|
4268
4295
|
webhook
|
|
4269
4296
|
});
|
|
4270
4297
|
if (params.file) {
|
|
@@ -4449,6 +4476,7 @@ function isMissingFileError3(error) {
|
|
|
4449
4476
|
KnowhereError,
|
|
4450
4477
|
Knowledge,
|
|
4451
4478
|
LocalKnowledgeStore,
|
|
4479
|
+
NODE_SDK_DOCUMENT_METADATA_DEFAULTS,
|
|
4452
4480
|
NetworkError,
|
|
4453
4481
|
NotFoundError,
|
|
4454
4482
|
PaymentRequiredError,
|
|
@@ -4460,6 +4488,7 @@ function isMissingFileError3(error) {
|
|
|
4460
4488
|
TimeoutError,
|
|
4461
4489
|
VERSION,
|
|
4462
4490
|
ValidationError,
|
|
4491
|
+
mergeDocumentMetadataDefaults,
|
|
4463
4492
|
storeParseResultAssets,
|
|
4464
4493
|
syncParseResultToParsedDocumentStorage
|
|
4465
4494
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import axios, {
|
|
|
7
7
|
} from "axios";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = "
|
|
10
|
+
var VERSION = "2.1.3";
|
|
11
11
|
|
|
12
12
|
// src/constants.ts
|
|
13
13
|
var DEFAULT_BASE_URL = "https://api.knowhereto.ai";
|
|
@@ -701,6 +701,18 @@ var BaseResource = class {
|
|
|
701
701
|
}
|
|
702
702
|
};
|
|
703
703
|
|
|
704
|
+
// src/lib/document-metadata.ts
|
|
705
|
+
var NODE_SDK_DOCUMENT_METADATA_DEFAULTS = {
|
|
706
|
+
createdByClient: "node-sdk",
|
|
707
|
+
clientVersion: VERSION
|
|
708
|
+
};
|
|
709
|
+
function mergeDocumentMetadataDefaults(defaults, provided) {
|
|
710
|
+
if (!provided) {
|
|
711
|
+
return { ...defaults };
|
|
712
|
+
}
|
|
713
|
+
return { ...defaults, ...provided };
|
|
714
|
+
}
|
|
715
|
+
|
|
704
716
|
// src/lib/upload.ts
|
|
705
717
|
import { createReadStream, promises as fs } from "fs";
|
|
706
718
|
async function uploadFile(httpClient, uploadUrl, file, options) {
|
|
@@ -1293,10 +1305,20 @@ function isMissingFileError(error) {
|
|
|
1293
1305
|
var Jobs = class extends BaseResource {
|
|
1294
1306
|
pendingUploadJobs = /* @__PURE__ */ new Map();
|
|
1295
1307
|
/**
|
|
1296
|
-
* Create a new parsing job
|
|
1308
|
+
* Create a new parsing job.
|
|
1309
|
+
*
|
|
1310
|
+
* Auto-attaches `documentMetadata.createdByClient` / `clientVersion` for
|
|
1311
|
+
* OSS telemetry. Caller-provided metadata keys win; defaults fill gaps only.
|
|
1297
1312
|
*/
|
|
1298
1313
|
async create(params) {
|
|
1299
|
-
const
|
|
1314
|
+
const documentMetadata = mergeDocumentMetadataDefaults(
|
|
1315
|
+
NODE_SDK_DOCUMENT_METADATA_DEFAULTS,
|
|
1316
|
+
params.documentMetadata
|
|
1317
|
+
);
|
|
1318
|
+
const job = await this.httpClient.post(this.endpoint("/jobs"), {
|
|
1319
|
+
...params,
|
|
1320
|
+
documentMetadata
|
|
1321
|
+
});
|
|
1300
1322
|
if (job.uploadUrl) {
|
|
1301
1323
|
this.pendingUploadJobs.set(job.jobId, job);
|
|
1302
1324
|
}
|
|
@@ -3036,16 +3058,23 @@ var Knowledge = class _Knowledge {
|
|
|
3036
3058
|
if (!commit) {
|
|
3037
3059
|
return null;
|
|
3038
3060
|
}
|
|
3039
|
-
const manifestObject = await
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3061
|
+
const [manifestObject, chunksObject, docNavObject] = await Promise.all([
|
|
3062
|
+
parsedStorageConfig.storage.readObject({
|
|
3063
|
+
documentId,
|
|
3064
|
+
revisionKey,
|
|
3065
|
+
path: "manifest.json"
|
|
3066
|
+
}),
|
|
3067
|
+
parsedStorageConfig.storage.readObject({
|
|
3068
|
+
documentId,
|
|
3069
|
+
revisionKey,
|
|
3070
|
+
path: "chunks.json"
|
|
3071
|
+
}),
|
|
3072
|
+
parsedStorageConfig.storage.readObject({
|
|
3073
|
+
documentId,
|
|
3074
|
+
revisionKey,
|
|
3075
|
+
path: "doc_nav.json"
|
|
3076
|
+
})
|
|
3077
|
+
]);
|
|
3049
3078
|
if (!manifestObject || !chunksObject) {
|
|
3050
3079
|
return null;
|
|
3051
3080
|
}
|
|
@@ -3054,11 +3083,6 @@ var Knowledge = class _Knowledge {
|
|
|
3054
3083
|
payload: readJsonObject(chunksObject),
|
|
3055
3084
|
sourceFileName: manifest.sourceFileName
|
|
3056
3085
|
});
|
|
3057
|
-
const docNavObject = await parsedStorageConfig.storage.readObject({
|
|
3058
|
-
documentId,
|
|
3059
|
-
revisionKey,
|
|
3060
|
-
path: "doc_nav.json"
|
|
3061
|
-
});
|
|
3062
3086
|
const docNav = docNavObject ? readJsonObject(docNavObject) : void 0;
|
|
3063
3087
|
return {
|
|
3064
3088
|
commit,
|
|
@@ -4202,6 +4226,7 @@ var Knowhere = class {
|
|
|
4202
4226
|
documentId: params.documentId,
|
|
4203
4227
|
documentMetadata: params.documentMetadata,
|
|
4204
4228
|
parsingParams: buildParsingParams(params),
|
|
4229
|
+
llmConfig: params.llmConfig,
|
|
4205
4230
|
webhook
|
|
4206
4231
|
});
|
|
4207
4232
|
if (params.file) {
|
|
@@ -4385,6 +4410,7 @@ export {
|
|
|
4385
4410
|
KnowhereError,
|
|
4386
4411
|
Knowledge,
|
|
4387
4412
|
LocalKnowledgeStore,
|
|
4413
|
+
NODE_SDK_DOCUMENT_METADATA_DEFAULTS,
|
|
4388
4414
|
NetworkError,
|
|
4389
4415
|
NotFoundError,
|
|
4390
4416
|
PaymentRequiredError,
|
|
@@ -4397,6 +4423,7 @@ export {
|
|
|
4397
4423
|
VERSION,
|
|
4398
4424
|
ValidationError,
|
|
4399
4425
|
Knowhere as default,
|
|
4426
|
+
mergeDocumentMetadataDefaults,
|
|
4400
4427
|
storeParseResultAssets,
|
|
4401
4428
|
syncParseResultToParsedDocumentStorage
|
|
4402
4429
|
};
|