-
Notifications
You must be signed in to change notification settings - Fork 510
/
base.py
43 lines (30 loc) · 857 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Optional, Union
import numpy as np
@dataclass
class VectorData:
id: int
data: np.ndarray
class VectorBase(ABC):
"""VectorBase: base vector store interface"""
@abstractmethod
def mul_add(self, datas: List[VectorData]):
pass
@abstractmethod
def search(self, data: np.ndarray, top_k: int):
pass
@abstractmethod
def rebuild(self, ids=None) -> bool:
pass
@abstractmethod
def delete(self, ids) -> bool:
pass
def flush(self):
pass
def close(self):
pass
def get_embeddings(self, data_id: Union[int, str]) -> Optional[np.ndarray]:
raise NotImplementedError
def update_embeddings(self, data_id: Union[int, str], emb: np.ndarray):
pass