Loading...
Skip to main content

Class: LocalCorpus<DocumentMetadata, ChunkMetadata>

batteries/docs.LocalCorpus

A LoadableCorpus implementation that runs locally and stores chunks in memory.

This implementation doesn't make external requests except through the provided Loader, Chunker, and Embedding (but note that the default Embedding does make external requests).

Type parameters

NameType
DocumentMetadataextends Jsonifiable = Jsonifiable
ChunkMetadataextends Jsonifiable = Jsonifiable

Hierarchy

  • BaseLoadableCorpus<DocumentMetadata, ChunkMetadata>

    LocalCorpus

Constructors

constructor

new LocalCorpus<DocumentMetadata, ChunkMetadata>(loader, chunker, embedding?)

Type parameters

NameType
DocumentMetadataextends Jsonifiable = Jsonifiable
ChunkMetadataextends Jsonifiable = Jsonifiable

Parameters

NameType
loaderLoader<DocumentMetadata>
chunkerChunker<DocumentMetadata, ChunkMetadata>
embeddingEmbedding

Overrides

BaseLoadableCorpus<DocumentMetadata, ChunkMetadata\>.constructor

Defined in

ai-jsx/src/batteries/docs.tsx:582

Properties

chunkConsumer

Readonly chunkConsumer: (chunks: EmbeddedChunk<ChunkMetadata>[]) => Promise<void>

Type declaration

▸ (chunks): Promise<void>

Parameters
NameType
chunksEmbeddedChunk<ChunkMetadata>[]
Returns

Promise<void>

Inherited from

BaseLoadableCorpus.chunkConsumer

Defined in

ai-jsx/src/batteries/docs.tsx:469


chunker

Readonly chunker: Chunker<DocumentMetadata, ChunkMetadata>

Defined in

ai-jsx/src/batteries/docs.tsx:584


embedding

Readonly embedding: Embedding

Defined in

ai-jsx/src/batteries/docs.tsx:585


loader

Readonly loader: Loader<DocumentMetadata>

Inherited from

BaseLoadableCorpus.loader

Defined in

ai-jsx/src/batteries/docs.tsx:583


vectorizer

Readonly vectorizer: Vectorizer<DocumentMetadata, ChunkMetadata>

Inherited from

BaseLoadableCorpus.vectorizer

Defined in

ai-jsx/src/batteries/docs.tsx:468

Methods

getStats

getStats(): CorpusStats

Reveals statistics about this corpus, including its LoadingState.

Returns

CorpusStats

Inherited from

BaseLoadableCorpus.getStats

Defined in

ai-jsx/src/batteries/docs.tsx:500


load

load(): Promise<CorpusStats>

Loads documents into the corpus using a Loader, Chunker, and Embedding. If the returned promise resolves succesfully, the corpus will be in COMPLETED state. If it rejects, the corpus may be in FAILED state.

Note: Corpus loading may be quite time consuming. It's best to ensure loading is done prior to exposing this corpus to your users.

Note: This method is idempotent. Calling it multiple times will not result in multiple loads.

Returns

Promise<CorpusStats>

Inherited from

BaseLoadableCorpus.load

Defined in

ai-jsx/src/batteries/docs.tsx:482


search(query, params?): Promise<ScoredChunk<ChunkMetadata>[]>

Parameters

NameType
querystring
params?Object
params.limit?number
params.score_threshold?number

Returns

Promise<ScoredChunk<ChunkMetadata>[]>

Overrides

BaseLoadableCorpus.search

Defined in

ai-jsx/src/batteries/docs.tsx:594


checkReady

Protected checkReady(): void

Returns

void

Inherited from

BaseLoadableCorpus.checkReady

Defined in

ai-jsx/src/batteries/docs.tsx:504