Merge pull request #1320 from Tymec/master

Add ability to use local embeddings model
This commit is contained in:
Richard Beales
2023-04-15 18:13:16 +01:00
committed by GitHub
8 changed files with 86 additions and 31 deletions

26
tests/embedder_test.py Normal file
View File

@@ -0,0 +1,26 @@
import os
import sys
from autogpt.config import Config
from autogpt.memory.base import get_embedding
# Required, because the get_embedding function uses it
cfg = Config()
class TestMemoryEmbedder(unittest.TestCase):
def test_ada(self):
cfg.memory_embedder = "ada"
text = "Sample text"
result = get_embedding(text)
self.assertEqual(len(result), 1536)
def test_sbert(self):
cfg.memory_embedder = "sbert"
text = "Sample text"
result = get_embedding(text)
self.assertEqual(len(result), 768)
if __name__ == '__main__':
unittest.main()