[Bug fix] Fix typos, static methods and other sanity improvements in the package (#1129)
This commit is contained in:
@@ -49,7 +49,7 @@ class BaseVectorDB(JSONSerializable):
|
||||
raise NotImplementedError
|
||||
|
||||
def query(self):
|
||||
"""Query contents from vector data base based on vector similarity"""
|
||||
"""Query contents from vector database based on vector similarity"""
|
||||
raise NotImplementedError
|
||||
|
||||
def count(self) -> int:
|
||||
|
||||
@@ -75,7 +75,8 @@ class ChromaDB(BaseVectorDB):
|
||||
"""Called during initialization"""
|
||||
return self.client
|
||||
|
||||
def _generate_where_clause(self, where: Dict[str, any]) -> str:
|
||||
@staticmethod
|
||||
def _generate_where_clause(where: Dict[str, any]) -> Dict[str, any]:
|
||||
# If only one filter is supplied, return it as is
|
||||
# (no need to wrap in $and based on chroma docs)
|
||||
if len(where.keys()) <= 1:
|
||||
@@ -160,7 +161,8 @@ class ChromaDB(BaseVectorDB):
|
||||
ids=ids[i : i + self.BATCH_SIZE],
|
||||
)
|
||||
|
||||
def _format_result(self, results: QueryResult) -> list[tuple[Document, float]]:
|
||||
@staticmethod
|
||||
def _format_result(results: QueryResult) -> list[tuple[Document, float]]:
|
||||
"""
|
||||
Format Chroma results
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class ElasticsearchDB(BaseVectorDB):
|
||||
"""
|
||||
Get existing doc ids present in vector database
|
||||
|
||||
:param ids: _list of doc ids to check for existance
|
||||
:param ids: _list of doc ids to check for existence
|
||||
:type ids: List[str]
|
||||
:param where: to filter data
|
||||
:type where: Dict[str, any]
|
||||
@@ -161,7 +161,7 @@ class ElasticsearchDB(BaseVectorDB):
|
||||
**kwargs: Optional[Dict[str, Any]],
|
||||
) -> Union[List[Tuple[str, Dict]], List[str]]:
|
||||
"""
|
||||
query contents from vector data base based on vector similarity
|
||||
query contents from vector database based on vector similarity
|
||||
|
||||
:param input_query: list of query string
|
||||
:type input_query: List[str]
|
||||
|
||||
@@ -163,7 +163,7 @@ class OpenSearchDB(BaseVectorDB):
|
||||
**kwargs: Optional[Dict[str, Any]],
|
||||
) -> Union[List[Tuple[str, Dict]], List[str]]:
|
||||
"""
|
||||
query contents from vector data base based on vector similarity
|
||||
query contents from vector database based on vector similarity
|
||||
|
||||
:param input_query: list of query string
|
||||
:type input_query: List[str]
|
||||
|
||||
@@ -305,7 +305,8 @@ class WeaviateDB(BaseVectorDB):
|
||||
"""
|
||||
return f"{self.config.collection_name}_{self.embedder.vector_dimension}".capitalize()
|
||||
|
||||
def _query_with_cursor(self, query, cursor):
|
||||
@staticmethod
|
||||
def _query_with_cursor(query, cursor):
|
||||
if cursor is not None:
|
||||
query.with_after(cursor)
|
||||
results = query.do()
|
||||
|
||||
@@ -6,8 +6,7 @@ from embedchain.helpers.json_serializable import register_deserializable
|
||||
from embedchain.vectordb.base import BaseVectorDB
|
||||
|
||||
try:
|
||||
from pymilvus import (Collection, CollectionSchema, DataType, FieldSchema,
|
||||
MilvusClient, connections, utility)
|
||||
from pymilvus import Collection, CollectionSchema, DataType, FieldSchema, MilvusClient, connections, utility
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Zilliz requires extra dependencies. Install with `pip install --upgrade embedchain[milvus]`"
|
||||
@@ -97,10 +96,10 @@ class ZillizVectorDB(BaseVectorDB):
|
||||
if ids is None or len(ids) == 0 or self.collection.num_entities == 0:
|
||||
return {"ids": []}
|
||||
|
||||
if not (self.collection.is_empty):
|
||||
filter = f"id in {ids}"
|
||||
if not self.collection.is_empty:
|
||||
filter_ = f"id in {ids}"
|
||||
results = self.client.query(
|
||||
collection_name=self.config.collection_name, filter=filter, output_fields=["id"]
|
||||
collection_name=self.config.collection_name, filter=filter_, output_fields=["id"]
|
||||
)
|
||||
results = [res["id"] for res in results]
|
||||
|
||||
@@ -134,7 +133,7 @@ class ZillizVectorDB(BaseVectorDB):
|
||||
**kwargs: Optional[Dict[str, Any]],
|
||||
) -> Union[List[Tuple[str, Dict]], List[str]]:
|
||||
"""
|
||||
Query contents from vector data base based on vector similarity
|
||||
Query contents from vector database based on vector similarity
|
||||
|
||||
:param input_query: list of query string
|
||||
:type input_query: List[str]
|
||||
|
||||
Reference in New Issue
Block a user