Skip to content

Commit

Permalink
fix chroma linting; rm numpy (#1063)
Browse files Browse the repository at this point in the history
Co-authored-by: Silvano Cerza <[email protected]>
  • Loading branch information
anakin87 and silvanocerza authored Sep 9, 2024
1 parent 2fd6d1a commit ee61033
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Any, Dict, List, Literal, Optional, Tuple

import chromadb
import numpy as np
from chromadb.api.types import GetResult, QueryResult, validate_where, validate_where_document
from haystack import default_from_dict, default_to_dict
from haystack.dataclasses import Document
Expand Down Expand Up @@ -465,7 +464,7 @@ def _query_result_to_documents(result: QueryResult) -> List[List[Document]]:
pass

if embeddings := result.get("embeddings"):
document_dict["embedding"] = np.array(embeddings[i][j])
document_dict["embedding"] = embeddings[i][j]

if distances := result.get("distances"):
document_dict["score"] = distances[i][j]
Expand Down
7 changes: 6 additions & 1 deletion integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def test_search(self):

# Assertions to verify correctness
assert len(result) == 1
assert result[0][0].content == "Third document"
doc = result[0][0]
assert doc.content == "Third document"
assert doc.meta == {"author": "Author2"}
assert doc.embedding
assert isinstance(doc.embedding, list)
assert all(isinstance(el, float) for el in doc.embedding)

def test_write_documents_unsupported_meta_values(self, document_store: ChromaDocumentStore):
"""
Expand Down

0 comments on commit ee61033

Please sign in to comment.