From b6097d66af74833af195dd801b873a02bf1b9073 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Wed, 28 Aug 2024 15:37:14 -0400 Subject: [PATCH] [FIXED IMPORT PATHS] --- pyproject.toml | 2 +- swarms_memory/{vector_dbs => dbs}/base_db.py | 0 swarms_memory/dbs/pg.py | 4 ++-- swarms_memory/dbs/pinecone.py | 17 ++++++++++++++--- swarms_memory/dbs/sqlite.py | 4 ++-- swarms_memory/utils/short_term_memory.py | 2 +- swarms_memory/vector_dbs/chroma_db_wrapper.py | 2 +- swarms_memory/vector_dbs/faiss_wrapper.py | 2 +- swarms_memory/vector_dbs/pinecone_wrapper.py | 3 +-- 9 files changed, 23 insertions(+), 13 deletions(-) rename swarms_memory/{vector_dbs => dbs}/base_db.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 0b80329..747a4f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms-memory" -version = "0.0.9" +version = "0.1.1" description = "Swarms Memory - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms_memory/vector_dbs/base_db.py b/swarms_memory/dbs/base_db.py similarity index 100% rename from swarms_memory/vector_dbs/base_db.py rename to swarms_memory/dbs/base_db.py diff --git a/swarms_memory/dbs/pg.py b/swarms_memory/dbs/pg.py index 957f5a1..aea69c7 100644 --- a/swarms_memory/dbs/pg.py +++ b/swarms_memory/dbs/pg.py @@ -5,10 +5,10 @@ from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import Session -from swarms_memory import BaseVectorDatabase +from swarms_memory.dbs.base_db import AbstractDatabase -class PostgresDB(BaseVectorDatabase): +class PostgresDB(AbstractDatabase): """ A class representing a Postgres database. diff --git a/swarms_memory/dbs/pinecone.py b/swarms_memory/dbs/pinecone.py index 534c603..ef916fb 100644 --- a/swarms_memory/dbs/pinecone.py +++ b/swarms_memory/dbs/pinecone.py @@ -3,12 +3,23 @@ import pinecone from attr import define, field -from swarms_memory import BaseVectorDatabase -from swarms.utils import str_to_hash +from swarms_memory.dbs.base_db import AbstractDatabase + + +def str_to_hash(s: str) -> str: + """Converts a string to a hash. + + Args: + s (str): The string to convert. + + Returns: + str: The hash of the string. + """ + return str(hash(s)) @define -class PineconeDB(BaseVectorDatabase): +class PineconeDB(AbstractDatabase): """ PineconeDB is a vector storage driver that uses Pinecone as the underlying storage engine. diff --git a/swarms_memory/dbs/sqlite.py b/swarms_memory/dbs/sqlite.py index 02c1348..9c2c839 100644 --- a/swarms_memory/dbs/sqlite.py +++ b/swarms_memory/dbs/sqlite.py @@ -1,6 +1,6 @@ from typing import Any, List, Optional, Tuple -from swarms_memory import BaseVectorDatabase +from swarms_memory.dbs.base_db import AbstractDatabase try: import sqlite3 @@ -10,7 +10,7 @@ ) -class SQLiteDB(BaseVectorDatabase): +class SQLiteDB(AbstractDatabase): """ A reusable class for SQLite database operations with methods for adding, deleting, updating, and querying data. diff --git a/swarms_memory/utils/short_term_memory.py b/swarms_memory/utils/short_term_memory.py index 5768957..06bed8e 100644 --- a/swarms_memory/utils/short_term_memory.py +++ b/swarms_memory/utils/short_term_memory.py @@ -14,7 +14,7 @@ class ShortTermMemory: Example: - >>> from swarms.memory.short_term_memory import ShortTermMemory + >>> from swarms_memory.short_term_memory import ShortTermMemory >>> stm = ShortTermMemory() >>> stm.add(role="agent", message="Hello world!") >>> stm.add(role="agent", message="How are you?") diff --git a/swarms_memory/vector_dbs/chroma_db_wrapper.py b/swarms_memory/vector_dbs/chroma_db_wrapper.py index b33d5dc..c03091f 100644 --- a/swarms_memory/vector_dbs/chroma_db_wrapper.py +++ b/swarms_memory/vector_dbs/chroma_db_wrapper.py @@ -5,7 +5,7 @@ import chromadb from dotenv import load_dotenv from loguru import logger -from swarms.memory.base_vectordb import BaseVectorDatabase +from swarms_memory.vector_dbs.base_vectordb import BaseVectorDatabase from swarms.utils.data_to_text import data_to_text # Load environment variables diff --git a/swarms_memory/vector_dbs/faiss_wrapper.py b/swarms_memory/vector_dbs/faiss_wrapper.py index 8a63bb0..b07788f 100644 --- a/swarms_memory/vector_dbs/faiss_wrapper.py +++ b/swarms_memory/vector_dbs/faiss_wrapper.py @@ -3,7 +3,7 @@ import numpy as np from loguru import logger from sentence_transformers import SentenceTransformer -from swarms.memory.base_vectordb import BaseVectorDatabase +from swarms_memory.vector_dbs.base_vectordb import BaseVectorDatabase class FAISSDB(BaseVectorDatabase): diff --git a/swarms_memory/vector_dbs/pinecone_wrapper.py b/swarms_memory/vector_dbs/pinecone_wrapper.py index e2f49c3..6da7229 100644 --- a/swarms_memory/vector_dbs/pinecone_wrapper.py +++ b/swarms_memory/vector_dbs/pinecone_wrapper.py @@ -3,8 +3,7 @@ import pinecone from loguru import logger from sentence_transformers import SentenceTransformer -from swarms.memory.base_vectordb import BaseVectorDatabase - +from swarms_memory.vector_dbs.base_vectordb import BaseVectorDatabase class PineconeMemory(BaseVectorDatabase): """