MemoStore

MemoStore(
    verbosity: int | None = 0,
    reset: bool | None = False,
    path_to_db_dir: str | None = './tmp/teachable_agent_db'
)

Provides memory storage and retrieval for a teachable agent, using a vector database.
Each DB entry (called a memo) is a pair of strings: an input text and an output text.
The input text might be a question, or a task to perform.
The output text might be an answer to the question, or advice on how to perform the task.
Vector embeddings are currently supplied by Chroma’s default Sentence Transformers.

Parameters:
NameDescription
verbosityType: int | None

Default: 0
resetType: bool | None

Default: False
path_to_db_dirType: str | None

Default: ’./tmp/teachable_agent_db’

Instance Methods

add_input_output_pair

add_input_output_pair(
    self,
    input_text: str,
    output_text: str
) -> 

Adds an input-output pair to the vector DB.

Parameters:
NameDescription
input_textType: str
output_textType: str

get_nearest_memo

get_nearest_memo(self, query_text: str) -> 

Retrieves the nearest memo to the given query text.

Parameters:
NameDescription
query_textType: str

get_related_memos(
    self,
    query_text: str,
    n_results: int,
    threshold: int | float
) -> 

Retrieves memos that are related to the given query text within the specified distance threshold.

Parameters:
NameDescription
query_textType: str
n_resultsType: int
thresholdType: int | float

list_memos

list_memos(self) -> 

Prints the contents of MemoStore.


prepopulate

prepopulate(self) -> 

Adds a few arbitrary examples to the vector DB, just to make retrieval less trivial.


reset_db

reset_db(self) -> 

Forces immediate deletion of the DB’s contents, in memory and on disk.