Skip to content

Overview / RabbitHole

RabbitHole

Accessors

fileParsers

get fileParsers(): object

Get the file parsers

Returns

object


textSplitter

get textSplitter(): TextSplitter

Returns

TextSplitter


webParsers

get webParsers(): WebParser[]

Get the web parsers

Returns

WebParser[]

Methods

ingestContent()

ingestContent(stray, content, source, metadata?): Promise<void>

Ingests textual content into the memory.

Parameters

ParameterTypeDefault valueDescription
strayStrayCatundefinedThe StrayCat instance.
contentstring | string[]undefinedThe textual content to ingest.
sourcestring'unknown'The source of the content (default: 'unknown').
metadata?Record<string, any>undefinedAdditional metadata to store with the content.

Returns

Promise<void>


ingestFile()

ingestFile(stray, file, chunkSize?, chunkOverlap?, metadata?): Promise<void>

Ingests a file and processes its content.

Parameters

ParameterTypeDescription
strayStrayCatThe StrayCat instance.
fileFileThe file to ingest.
chunkSize?numberThe size of each chunk for splitting the content.
chunkOverlap?numberThe overlap between chunks.
metadata?Record<string, any>Additional metadata to store with the content.

Returns

Promise<void>

Throws

An error if the file type is not supported.


ingestMemory()

ingestMemory(json): Promise<void>

Upload memories to the declarative memory from a JSON file. When doing this, please, make sure the embedder used to export the memories is the same as the one used when uploading. The method also performs a check on the dimensionality of the embeddings (i.e. length of each vector).

Parameters

ParameterTypeDescription
jsonMemoryJson | Filethe json object containing the memories to be ingested.

Returns

Promise<void>


ingestPathOrURL()

ingestPathOrURL(stray, path, chunkSize?, chunkOverlap?, metadata?): Promise<void>

Ingests a path or URL and processes the content. If the input is a URL, it uses a web handler to load the content. If the input is a file system path, it reads the file and processes the content.

Parameters

ParameterTypeDescription
strayStrayCatThe StrayCat instance.
pathstringThe path or URL to ingest.
chunkSize?numberThe size of each chunk for splitting the content.
chunkOverlap?numberThe overlap between chunks.
metadata?Record<string, any>Additional metadata to store with the content.

Returns

Promise<void>

Throws

If the URL doesn't match any web handler or the path doesn't exist.


splitDocs()

splitDocs(stray, docs, chunkSize?, chunkOverlap?): Promise<Document<Record<string, any>>[]>

Splits an array of texts into smaller chunks and creates documents. The method also executes the beforeSplitTexts and afterSplitTexts hooks.

Parameters

ParameterTypeDescription
strayStrayCatThe StrayCat instance.
docsDocument<Record<string, any>>[]The array of documents to be split.
chunkSize?numberThe size of each chunk for splitting the content (default: 256).
chunkOverlap?numberThe overlap between chunks (default: 64).

Returns

Promise<Document<Record<string, any>>[]>

An array of documents.


storeDocuments()

storeDocuments(stray, docs, source, metadata?): Promise<void>

Stores the given documents in memory. The method also executes the beforeStoreDocuments and beforeInsertInMemory hooks. It sends a websocket notification of the progress and when the reading process is completed

Parameters

ParameterTypeDescription
strayStrayCatThe StrayCat instance.
docsDocument<Record<string, any>>[]An array of documents to store.
sourcestringThe source of the documents.
metadata?Record<string, any>Additional metadata to store with the content.

Returns

Promise<void>


getInstance()

static getInstance(): Promise<RabbitHole>

Get the Rabbit Hole instance

Returns

Promise<RabbitHole>

The Rabbit Hole class as a singleton

Released under the GPL-3.0 License.