-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd724ec
commit a597eec
Showing
8 changed files
with
285 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# python garbage | ||
__pycache__ | ||
.pytest_cache | ||
*.egg-info | ||
build | ||
|
||
# python virtual environment | ||
env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Coroutine, List, Optional, Tuple | ||
|
||
from pandas import DataFrame | ||
|
||
# TODO: make this less Pinecone specific | ||
class VectorDatabase(ABC): | ||
""" | ||
Base class for all vector databases | ||
""" | ||
|
||
@abstractmethod | ||
async def fetch( | ||
self, ids: List[str], namespace: Optional[str] = None | ||
) -> List[dict]: | ||
""" | ||
:param ids: list of ids | ||
:param namespace: namespace | ||
:return: list of vectors | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
async def update( | ||
self, | ||
df: DataFrame, | ||
namespace: Optional[str] = None, | ||
batch_size: Optional[int] = 100, | ||
) -> Coroutine: | ||
""" | ||
:param vectors: list of vectors | ||
:param namespace: namespace | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
async def delete(self, ids: List[str], namespace: Optional[str] = None) -> None: | ||
""" | ||
:param ids: list of ids | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
async def search( | ||
self, vector: List[float], top_k: Optional[int], namespace: Optional[str] = None | ||
) -> List[dict]: | ||
""" | ||
:param vector: vector | ||
:param top_k: top k | ||
:param namespace: namespace | ||
:return: list of vectors | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
async def clear(self, namespace: Optional[str] = None) -> None: | ||
""" | ||
:param namespace: namespace | ||
""" | ||
raise NotImplementedError |
Oops, something went wrong.