mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
32 lines
659 B
Python
32 lines
659 B
Python
"""Base class for memory providers."""
|
|
import abc
|
|
from config import AbstractSingleton
|
|
import openai
|
|
|
|
|
|
def get_ada_embedding(text):
|
|
text = text.replace("\n", " ")
|
|
return openai.Embedding.create(input=[text], model="text-embedding-ada-002")["data"][0]["embedding"]
|
|
|
|
|
|
class MemoryProviderSingleton(AbstractSingleton):
|
|
@abc.abstractmethod
|
|
def add(self, data):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get(self, data):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def clear(self):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_relevant(self, data, num_relevant=5):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_stats(self):
|
|
pass
|