-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
67 lines (55 loc) · 1.72 KB
/
Copy pathbase.py
File metadata and controls
67 lines (55 loc) · 1.72 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from abc import ABC, abstractmethod
from typing import List, Protocol
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
class BaseVectorDB(ABC):
@abstractmethod
def init_collection(self, vector_size: int) -> None:
"""
Initialize the vector collection with the specified vector size.
Args:
vector_size (int): The dimensionality of the vectors to be stored.
"""
pass
@abstractmethod
def get_client(self) -> object:
"""
Return the underlying database client.
Returns:
object: The database-specific client instance.
"""
pass
@abstractmethod
def get_collection_name(self) -> str:
"""
Return the name of the vector collection.
Returns:
str: The name of the collection.
"""
pass
@abstractmethod
def insert_documents(
self,
documents: List[Document],
embedding_function: Embeddings
) -> None:
"""
Insert documents into the vector store after embedding them.
Args:
documents (List[Document]): List of documents to insert.
embedding_function (Embeddings): Embedding model to use for vector generation.
"""
pass
@abstractmethod
def as_langchain_vectorstore(
self,
embedding_function: Embeddings
) -> object:
"""
Return the vector store as a LangChain-compatible vector store.
Args:
embedding_function (Embeddings): Embedding model to use for vector generation.
Returns:
object: LangChain-compatible vector store instance.
"""
pass