Skip to content

Commit

Permalink
serialize the path to the local db
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 29, 2024
1 parent e5ee06e commit 108f46d
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from typing import Any, Dict, List, Optional, Tuple

import chromadb
import numpy as np
from chromadb.api.types import GetResult, QueryResult, validate_where, validate_where_document
import numpy as np
from haystack import default_from_dict, default_to_dict
from haystack.dataclasses import Document
from haystack.document_stores.types import DuplicatePolicy

Expand Down Expand Up @@ -50,6 +51,7 @@ def __init__(
self._collection_name = collection_name
self._embedding_function = embedding_function
self._embedding_function_params = embedding_function_params
self._persist_path = persist_path
# Create the client instance
if persist_path is None:
self._chroma_client = chromadb.Client()
Expand Down Expand Up @@ -244,20 +246,22 @@ def from_dict(cls, data: Dict[str, Any]) -> "ChromaDocumentStore":
:returns:
Deserialized component.
"""
return ChromaDocumentStore(**data)
return default_from_dict(cls, data)

def to_dict(self) -> Dict[str, Any]:
"""
Serializes the component to a dictionary.
:returns:
Dictionary with serialized data.
Dictionary with serialized data.
"""
return {
"collection_name": self._collection_name,
"embedding_function": self._embedding_function,
return default_to_dict(
self,
collection_name=self._collection_name,
embedding_function=self._embedding_function,
persist_path=self._persist_path,
**self._embedding_function_params,
}
)

@staticmethod
def _normalize_filters(filters: Dict[str, Any]) -> Tuple[List[str], Dict[str, Any], Dict[str, Any]]:
Expand Down

0 comments on commit 108f46d

Please sign in to comment.