Skip to content

Commit 5990c51

Browse files
committed
chore: format
1 parent 3c986ad commit 5990c51

File tree

13 files changed

+83
-25
lines changed

13 files changed

+83
-25
lines changed

backend/open_webui/retrieval/vector/dbs/chroma.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ def delete_collection(self, collection_name: str):
6969
return self.client.delete_collection(name=collection_name)
7070

7171
def search(
72-
self, collection_name: str, vectors: list[list[float | int]], filter: Optional[dict] = None, limit: int = 10
72+
self,
73+
collection_name: str,
74+
vectors: list[list[float | int]],
75+
filter: Optional[dict] = None,
76+
limit: int = 10,
7377
) -> Optional[SearchResult]:
7478
# Search for the nearest neighbor items based on the vectors and return 'limit' number of results.
7579
try:

backend/open_webui/retrieval/vector/dbs/elasticsearch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ def delete_collection(self, collection_name: str):
153153

154154
# Status: works
155155
def search(
156-
self, collection_name: str, vectors: list[list[float]], filter: Optional[dict] = None, limit: int = 10
156+
self,
157+
collection_name: str,
158+
vectors: list[list[float]],
159+
filter: Optional[dict] = None,
160+
limit: int = 10,
157161
) -> Optional[SearchResult]:
158162
query = {
159163
"size": limit,

backend/open_webui/retrieval/vector/dbs/milvus.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ def delete_collection(self, collection_name: str):
179179
)
180180

181181
def search(
182-
self, collection_name: str, vectors: list[list[float | int]], filter: Optional[dict] = None, limit: int = 10
182+
self,
183+
collection_name: str,
184+
vectors: list[list[float | int]],
185+
filter: Optional[dict] = None,
186+
limit: int = 10,
183187
) -> Optional[SearchResult]:
184188
# Search for the nearest neighbor items based on the vectors and return 'limit' number of results.
185189
collection_name = collection_name.replace("-", "_")

backend/open_webui/retrieval/vector/dbs/milvus_multitenancy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ def upsert(self, collection_name: str, items: List[VectorItem]):
157157
collection.insert(entities)
158158

159159
def search(
160-
self, collection_name: str, vectors: List[List[float]], filter: Optional[Dict] = None, limit: int = 10
160+
self,
161+
collection_name: str,
162+
vectors: List[List[float]],
163+
filter: Optional[Dict] = None,
164+
limit: int = 10,
161165
) -> Optional[SearchResult]:
162166
if not vectors:
163167
return None

backend/open_webui/retrieval/vector/dbs/opensearch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ def delete_collection(self, collection_name: str):
113113
self.client.indices.delete(index=self._get_index_name(collection_name))
114114

115115
def search(
116-
self, collection_name: str, vectors: list[list[float | int]], filter: Optional[dict] = None, limit: int = 10
116+
self,
117+
collection_name: str,
118+
vectors: list[list[float | int]],
119+
filter: Optional[dict] = None,
120+
limit: int = 10,
117121
) -> Optional[SearchResult]:
118122
try:
119123
if not self.has_collection(collection_name):

backend/open_webui/retrieval/vector/dbs/oracle23ai.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ def upsert(self, collection_name: str, items: List[VectorItem]) -> None:
521521
raise
522522

523523
def search(
524-
self, collection_name: str, vectors: List[List[Union[float, int]]], filter: Optional[dict] = None, limit: int = 10
524+
self,
525+
collection_name: str,
526+
vectors: List[List[Union[float, int]]],
527+
filter: Optional[dict] = None,
528+
limit: int = 10,
525529
) -> Optional[SearchResult]:
526530
"""
527531
Search for similar vectors in the database.

backend/open_webui/retrieval/vector/dbs/pgvector.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def vector_expr(vector):
477477

478478
# Build the lateral subquery for each query vector
479479
where_clauses = [DocumentChunk.collection_name == collection_name]
480-
480+
481481
# Apply metadata filter if provided
482482
if filter:
483483
for key, value in filter.items():
@@ -487,20 +487,27 @@ def vector_expr(vector):
487487
if PGVECTOR_PGCRYPTO:
488488
where_clauses.append(
489489
pgcrypto_decrypt(
490-
DocumentChunk.vmetadata, PGVECTOR_PGCRYPTO_KEY, JSONB
490+
DocumentChunk.vmetadata,
491+
PGVECTOR_PGCRYPTO_KEY,
492+
JSONB,
491493
)[key].astext.in_([str(v) for v in in_values])
492494
)
493495
else:
494496
where_clauses.append(
495-
DocumentChunk.vmetadata[key].astext.in_([str(v) for v in in_values])
497+
DocumentChunk.vmetadata[key].astext.in_(
498+
[str(v) for v in in_values]
499+
)
496500
)
497501
else:
498502
# Handle simple equality: {"field": "value"}
499503
if PGVECTOR_PGCRYPTO:
500504
where_clauses.append(
501505
pgcrypto_decrypt(
502-
DocumentChunk.vmetadata, PGVECTOR_PGCRYPTO_KEY, JSONB
503-
)[key].astext == str(value)
506+
DocumentChunk.vmetadata,
507+
PGVECTOR_PGCRYPTO_KEY,
508+
JSONB,
509+
)[key].astext
510+
== str(value)
504511
)
505512
else:
506513
where_clauses.append(

backend/open_webui/retrieval/vector/dbs/pinecone.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ async def upsert_async(self, collection_name: str, items: List[VectorItem]) -> N
391391
)
392392

393393
def search(
394-
self, collection_name: str, vectors: List[List[Union[float, int]]], filter: Optional[dict] = None, limit: int = 10
394+
self,
395+
collection_name: str,
396+
vectors: List[List[Union[float, int]]],
397+
filter: Optional[dict] = None,
398+
limit: int = 10,
395399
) -> Optional[SearchResult]:
396400
"""Search for similar vectors in a collection."""
397401
if not vectors or not vectors[0]:

backend/open_webui/retrieval/vector/dbs/qdrant.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ def delete_collection(self, collection_name: str):
145145
)
146146

147147
def search(
148-
self, collection_name: str, vectors: list[list[float | int]], filter: Optional[dict] = None, limit: int = 10
148+
self,
149+
collection_name: str,
150+
vectors: list[list[float | int]],
151+
filter: Optional[dict] = None,
152+
limit: int = 10,
149153
) -> Optional[SearchResult]:
150154
# Search for the nearest neighbor items based on the vectors and return 'limit' number of results.
151155
if limit is None:

backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ def delete(
254254
)
255255

256256
def search(
257-
self, collection_name: str, vectors: List[List[float | int]], filter: Optional[Dict] = None, limit: int = 10
257+
self,
258+
collection_name: str,
259+
vectors: List[List[float | int]],
260+
filter: Optional[Dict] = None,
261+
limit: int = 10,
258262
) -> Optional[SearchResult]:
259263
"""
260264
Search for the nearest neighbor items based on the vectors with tenant isolation.

0 commit comments

Comments
 (0)