Added generic memstore

pull/5165/head
SwiftyOS 2023-09-06 16:29:31 +02:00
parent d3fe982e27
commit e364804615
2 changed files with 40 additions and 3 deletions

View File

@ -1,10 +1,47 @@
import abc
import hashlib
import chromadb
from chromadb.config import Settings
class MemStore:
class MemStore(abc.ABC):
"""
An abstract class that represents a Memory Store
"""
@abc.abstractmethod
def __init__(self, store_path: str):
pass
@abc.abstractmethod
def add(self, task_id: str, document: str, metadatas: dict) -> None:
pass
@abc.abstractmethod
def query(
self,
task_id: str,
query: str,
filters: dict = None,
document_search: dict = None,
) -> dict:
pass
@abc.abstractmethod
def get(self, task_id: str, doc_ids: list = None, filters: dict = None) -> dict:
pass
@abc.abstractmethod
def update(self, task_id: str, doc_ids: list, documents: list, metadatas: list):
pass
@abc.abstractmethod
def delete(self, task_id: str, doc_id: str):
pass
class ChromaMemStore(MemStore):
"""
A class used to represent a Memory Store
"""

View File

@ -3,12 +3,12 @@ import shutil
import pytest
from autogpt.sdk.memory.memstore import MemStore
from autogpt.sdk.memory.memstore import ChromaMemStore
@pytest.fixture
def memstore():
mem = MemStore(".test_mem_store")
mem = ChromaMemStore(".test_mem_store")
yield mem
shutil.rmtree(".test_mem_store")