Spaces:
Sleeping
Sleeping
Commit
·
4278112
1
Parent(s):
1c516fb
clean: remove useless methods
Browse files- vector_store.py +1 -56
vector_store.py
CHANGED
@@ -102,62 +102,6 @@ class CustomVectorStore(VectorStore):
|
|
102 |
"""Create a context manager for the session, bind to _conn string."""
|
103 |
yield Session(self._conn)
|
104 |
|
105 |
-
def delete(
|
106 |
-
self,
|
107 |
-
ids: Optional[List[str]] = None,
|
108 |
-
**kwargs: Any,
|
109 |
-
) -> None:
|
110 |
-
"""Delete vectors by ids.
|
111 |
-
|
112 |
-
Args:
|
113 |
-
ids: List of ids to delete.
|
114 |
-
"""
|
115 |
-
with Session(self._conn) as session:
|
116 |
-
if ids is not None:
|
117 |
-
self.logger.debug(
|
118 |
-
"Trying to delete vectors by ids (represented by the model "
|
119 |
-
"using the custom ids field)"
|
120 |
-
)
|
121 |
-
stmt = delete(self.EmbeddingStore).where(
|
122 |
-
self.EmbeddingStore.custom_id.in_(ids)
|
123 |
-
)
|
124 |
-
session.execute(stmt)
|
125 |
-
session.commit()
|
126 |
-
|
127 |
-
@classmethod
|
128 |
-
def __from(
|
129 |
-
cls,
|
130 |
-
texts: List[str],
|
131 |
-
embeddings: List[List[float]],
|
132 |
-
embedding: Embeddings,
|
133 |
-
metadatas: Optional[List[dict]] = None,
|
134 |
-
ids: Optional[List[str]] = None,
|
135 |
-
table_name: str = "article",
|
136 |
-
distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY,
|
137 |
-
connection_string: Optional[str] = None,
|
138 |
-
pre_delete_collection: bool = False,
|
139 |
-
**kwargs: Any,
|
140 |
-
) -> CustomVectorStore:
|
141 |
-
if not metadatas:
|
142 |
-
metadatas = [{} for _ in texts]
|
143 |
-
if connection_string is None:
|
144 |
-
connection_string = cls.get_connection_string(kwargs)
|
145 |
-
|
146 |
-
store = cls(
|
147 |
-
connection_string=connection_string,
|
148 |
-
table_name=table_name,
|
149 |
-
embedding_function=embedding,
|
150 |
-
distance_strategy=distance_strategy,
|
151 |
-
pre_delete_collection=pre_delete_collection,
|
152 |
-
**kwargs,
|
153 |
-
)
|
154 |
-
|
155 |
-
store.add_embeddings(
|
156 |
-
texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs
|
157 |
-
)
|
158 |
-
|
159 |
-
return store
|
160 |
-
|
161 |
def add_embeddings(
|
162 |
self,
|
163 |
texts: Iterable[str],
|
@@ -302,6 +246,7 @@ class CustomVectorStore(VectorStore):
|
|
302 |
]
|
303 |
return docs
|
304 |
|
|
|
305 |
def __query_collection(
|
306 |
self,
|
307 |
embedding: List[float],
|
|
|
102 |
"""Create a context manager for the session, bind to _conn string."""
|
103 |
yield Session(self._conn)
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
def add_embeddings(
|
106 |
self,
|
107 |
texts: Iterable[str],
|
|
|
246 |
]
|
247 |
return docs
|
248 |
|
249 |
+
|
250 |
def __query_collection(
|
251 |
self,
|
252 |
embedding: List[float],
|