Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nodes/test/mocks/chromadb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ def get(
if count < offset:
count += 1
continue


# Apply limit (must be checked before append so limit=0 returns zero items)
if limit is not None and len(results["ids"]) >= limit:
break

results["ids"].append(id)
if "metadatas" in include:
results["metadatas"].append(self._serialize_metadata(metadata))
Expand All @@ -197,11 +201,7 @@ def get(
results["embeddings"].append(data.get("embedding"))

count += 1

# Apply limit
if limit and len(results["ids"]) >= limit:
break


return results

def upsert(
Expand Down
4 changes: 2 additions & 2 deletions nodes/test/mocks/psycopg2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _handle_semantic_search(self, query: str, params: Tuple):
query_vector = p.tolist()
elif isinstance(p, (list, tuple)) and len(p) > 3:
query_vector = list(p)
elif isinstance(p, int) and p < 1000:
elif isinstance(p, int) and not isinstance(p, bool) and p < 1000:
limit = p
else:
filter_params.append(p)
Expand Down Expand Up @@ -305,7 +305,7 @@ def _extract_limit(self, query: str, params: Tuple) -> Optional[int]:
if "limit" in query.lower() and params:
# Last param is often the limit
for p in reversed(params):
if isinstance(p, int) and p < 10000:
if isinstance(p, int) and not isinstance(p, bool) and p < 10000:
return p
return None

Expand Down
2 changes: 1 addition & 1 deletion nodes/test/mocks/weaviate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def near_vector(
))

# Sort by distance (lower is better for cosine distance)
results.sort(key=lambda x: x.metadata.distance if x.metadata.distance else 1.0)
results.sort(key=lambda x: x.metadata.distance if x.metadata.distance is not None else 1.0)

return QueryResult(objects=results[:limit])

Expand Down
Loading