Skip to main content

Class: LoadableLangchainCorpus<DocumentMetadata, ChunkMetadata>

batteries/docs.LoadableLangchainCorpus

A LoadableCorpus backed by a LangChain VectorStore.

Type parameters

NameType
DocumentMetadataextends Jsonifiable = Jsonifiable
ChunkMetadataextends Jsonifiable & Record<string, any> = Record<string, any>

Hierarchy

  • BaseLoadableCorpus<DocumentMetadata, ChunkMetadata>

    LoadableLangchainCorpus

Constructors

constructor

new LoadableLangchainCorpus<DocumentMetadata, ChunkMetadata>(vectorstore, loader, chunker)

Type parameters

NameType
DocumentMetadataextends Jsonifiable = Jsonifiable
ChunkMetadataextends Object = Record<string, any>

Parameters

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

Overrides

BaseLoadableCorpus<DocumentMetadata, ChunkMetadata\>.constructor

Defined in

packages/ai-jsx/src/batteries/docs.tsx:684

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

packages/ai-jsx/src/batteries/docs.tsx:467


chunker

Readonly chunker: Chunker<DocumentMetadata, ChunkMetadata>

Defined in

packages/ai-jsx/src/batteries/docs.tsx:687


loader

Readonly loader: Loader<DocumentMetadata>

Inherited from

BaseLoadableCorpus.loader

Defined in

packages/ai-jsx/src/batteries/docs.tsx:686


vectorizer

Readonly vectorizer: Vectorizer<DocumentMetadata, ChunkMetadata>

Inherited from

BaseLoadableCorpus.vectorizer

Defined in

packages/ai-jsx/src/batteries/docs.tsx:466


vectorstore

Readonly vectorstore: VectorStore

Defined in

packages/ai-jsx/src/batteries/docs.tsx:685

Methods

getStats

getStats(): CorpusStats

Reveals statistics about this corpus, including its LoadingState.

Returns

CorpusStats

Inherited from

BaseLoadableCorpus.getStats

Defined in

packages/ai-jsx/src/batteries/docs.tsx:498


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

packages/ai-jsx/src/batteries/docs.tsx:480


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

packages/ai-jsx/src/batteries/docs.tsx:701


checkReady

Protected checkReady(): void

Returns

void

Inherited from

BaseLoadableCorpus.checkReady

Defined in

packages/ai-jsx/src/batteries/docs.tsx:502