|
4 | 4 |
|
5 | 5 | from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
6 | 6 |
|
7 |
| -from haystack import DeserializationError, Pipeline, default_from_dict, default_to_dict, logging, super_component |
| 7 | +from haystack import Pipeline, default_from_dict, default_to_dict, logging, super_component |
8 | 8 | from haystack.components.embedders.types import TextEmbedder
|
9 | 9 | from haystack.components.joiners import DocumentJoiner
|
10 | 10 | from haystack.components.joiners.document_joiner import JoinMode
|
11 |
| -from haystack.core.serialization import component_from_dict, component_to_dict, import_class_by_name |
| 11 | +from haystack.core.serialization import component_to_dict |
12 | 12 | from haystack.document_stores.types import FilterPolicy
|
| 13 | +from haystack.utils import deserialize_chatgenerator_inplace |
13 | 14 |
|
14 | 15 | from haystack_integrations.components.retrievers.opensearch import OpenSearchBM25Retriever, OpenSearchEmbeddingRetriever
|
15 | 16 | from haystack_integrations.document_stores.opensearch import OpenSearchDocumentStore
|
@@ -307,15 +308,8 @@ def from_dict(cls, data):
|
307 | 308 | data["init_parameters"]["document_store"] = doc_store
|
308 | 309 |
|
309 | 310 | # deserialize the embedder
|
310 |
| - try: |
311 |
| - text_embedder_class = import_class_by_name(data["init_parameters"]["embedder"]["type"]) |
312 |
| - except ImportError as e: |
313 |
| - msg = f"Class '{data['init_parameters']['embedder']['type']}' not correctly imported" |
314 |
| - raise DeserializationError(msg) from e |
315 |
| - |
316 |
| - data["init_parameters"]["embedder"] = component_from_dict( |
317 |
| - cls=text_embedder_class, data=data["init_parameters"]["embedder"], name="embedder" |
318 |
| - ) |
| 311 | + # ToDo: in the future we should use the upcoming generic `deserialize_component_inplace` function |
| 312 | + deserialize_chatgenerator_inplace(data["init_parameters"], key="embedder") |
319 | 313 |
|
320 | 314 | # deserialize the embedders filtering policy
|
321 | 315 | if "filter_policy_bm25" in data["init_parameters"]:
|
|
0 commit comments