repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | from embedchain.config.vector_db.base import BaseVectorDbConfig |
| #2 | from embedchain.embedder.base import BaseEmbedder |
| #3 | from embedchain.helpers.json_serializable import JSONSerializable |
| #4 | |
| #5 | |
| #6 | class BaseVectorDB(JSONSerializable): |
| #7 | """Base class for vector database.""" |
| #8 | |
| #9 | def __init__(self, config: BaseVectorDbConfig): |
| #10 | """Initialize the database. Save the config and client as an attribute. |
| #11 | |
| #12 | :param config: Database configuration class instance. |
| #13 | :type config: BaseVectorDbConfig |
| #14 | """ |
| #15 | self.client = self._get_or_create_db() |
| #16 | self.config: BaseVectorDbConfig = config |
| #17 | |
| #18 | def _initialize(self): |
| #19 | """ |
| #20 | This method is needed because `embedder` attribute needs to be set externally before it can be initialized. |
| #21 | |
| #22 | So it's can't be done in __init__ in one step. |
| #23 | """ |
| #24 | raise NotImplementedError |
| #25 | |
| #26 | def _get_or_create_db(self): |
| #27 | """Get or create the database.""" |
| #28 | raise NotImplementedError |
| #29 | |
| #30 | def _get_or_create_collection(self): |
| #31 | """Get or create a named collection.""" |
| #32 | raise NotImplementedError |
| #33 | |
| #34 | def _set_embedder(self, embedder: BaseEmbedder): |
| #35 | """ |
| #36 | The database needs to access the embedder sometimes, with this method you can persistently set it. |
| #37 | |
| #38 | :param embedder: Embedder to be set as the embedder for this database. |
| #39 | :type embedder: BaseEmbedder |
| #40 | """ |
| #41 | self.embedder = embedder |
| #42 | |
| #43 | def get(self): |
| #44 | """Get database embeddings by id.""" |
| #45 | raise NotImplementedError |
| #46 | |
| #47 | def add(self): |
| #48 | """Add to database""" |
| #49 | raise NotImplementedError |
| #50 | |
| #51 | def query(self): |
| #52 | """Query contents from vector database based on vector similarity""" |
| #53 | raise NotImplementedError |
| #54 | |
| #55 | def count(self) -> int: |
| #56 | """ |
| #57 | Count number of documents/chunks embedded in the database. |
| #58 | |
| #59 | :return: number of documents |
| #60 | :rtype: int |
| #61 | """ |
| #62 | raise NotImplementedError |
| #63 | |
| #64 | def reset(self): |
| #65 | """ |
| #66 | Resets the database. Deletes all embeddings irreversibly. |
| #67 | """ |
| #68 | raise NotImplementedError |
| #69 | |
| #70 | def set_collection_name(self, name: str): |
| #71 | """ |
| #72 | Set the name of the collection. A collection is an isolated space for vectors. |
| #73 | |
| #74 | :param name: Name of the collection. |
| #75 | :type name: str |
| #76 | """ |
| #77 | raise NotImplementedError |
| #78 | |
| #79 | def delete(self): |
| #80 | """Delete from database.""" |
| #81 | |
| #82 | raise NotImplementedError |
| #83 |