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:715

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:469


chunker

Readonly chunker: Chunker<DocumentMetadata, ChunkMetadata>

Defined in

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


loader

Readonly loader: Loader<DocumentMetadata>

Inherited from

BaseLoadableCorpus.loader

Defined in

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


vectorizer

Readonly vectorizer: Vectorizer<DocumentMetadata, ChunkMetadata>

Inherited from

BaseLoadableCorpus.vectorizer

Defined in

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


vectorstore

Readonly vectorstore: VectorStore

Defined in

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

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: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

packages/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

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


checkReady

Protected checkReady(): void

Returns

void

Inherited from

BaseLoadableCorpus.checkReady

Defined in

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