Skip to content

corpus

Agent corpus reader module.

This client module reads a corpus file and calls the backend API to create memories. Effectively this builds a memory collection by “reading” the corpus into new memories.

Attributes

Classes

ChunkProcessingException

ChunkProcessingException(message: str, chunk_index: int)

Bases: Exception

Exception raised when a chunk processing error occurs

Attributes

chunk_index instance-attribute
chunk_index = chunk_index
message instance-attribute
message = message

Functions

Corpus

Corpus(config: str | None = None)

Bases: BaseCLI

EleanorAI Framework corpus reader

CLI base class

Warning

An odd behavior with Fire has been observed where subclasses of BaseCLI take override __init__ and take parameters caus Fire to incorrectly identify self as a required CLI argument.

Parameters:

  • config (str, default: None ) –

    Path to configuration file

Functions

name classmethod
name() -> str
read
read(
    corpus: str,
    collection: str,
    session: str,
    namespace: str | None = None,
    user: str | None = None,
    agent: str | None = None,
    truncate: bool = False,
    resume: int = 0,
)

Reads a corpus file and create memories in the Eleanor framework

Parameters:

  • corpus (str) –

    The path to the corpus file.

  • collection (str) –

    The name of the collection, will be created if it doesn’t exist

  • session (str) –

    The name of the session, will be created if it doesn’t exist

  • namespace (str, default: None ) –

    The namespace to use, when None the framework default namespace will be used.

  • user (str, default: None ) –

    Override the configured reader user, not recommended in most circumstances

  • agent (str, default: None ) –

    Override the reader agent, not recommended in most circumstances

  • truncate (bool, default: False ) –

    Whether to truncate (delete) all existing data in the memory collection before performing read operation.

  • resume (int, default: 0 ) –

    The chunk index to resume from, when None the operation will start from the beginning.

Returns:

  • None

Functions

load_spacy_model

load_spacy_model(model_name: str) -> Language

Load a spaCy model specified by its name. Automatically download the model if it is not installed.

Args: model_name (str): The name of the spaCy model to load.

Returns: Language: A spaCy Language object loaded with the specified model.