Export (de)serialize_callable and (de)serialize_type in haystack.utils (#7069)

* Export (de)serialize_callable and (de)serialize_type in haystack.utils

* Group imports where possible
This commit is contained in:
Vladimir Blagojevic 2024-02-22 17:07:07 +01:00 committed by GitHub
parent 0507fce256
commit 08e97d874e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 18 additions and 18 deletions

View File

@ -6,8 +6,7 @@ from jinja2.nativetypes import NativeEnvironment
from typing_extensions import TypeAlias
from haystack import component, default_to_dict, default_from_dict
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils.type_serialization import serialize_type, deserialize_type
from haystack.utils import serialize_callable, deserialize_callable, serialize_type, deserialize_type
class OutputAdaptationException(Exception):

View File

@ -8,8 +8,7 @@ from openai.lib.azure import AzureOpenAI
from haystack import default_to_dict, default_from_dict
from haystack.components.generators import OpenAIGenerator
from haystack.dataclasses import StreamingChunk
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import Secret, deserialize_secrets_inplace, serialize_callable, deserialize_callable
logger = logging.getLogger(__name__)

View File

@ -8,8 +8,7 @@ from openai.lib.azure import AzureOpenAI
from haystack import default_to_dict, default_from_dict
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import StreamingChunk
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import Secret, deserialize_secrets_inplace, serialize_callable, deserialize_callable
logger = logging.getLogger(__name__)

View File

@ -6,8 +6,7 @@ from haystack import component, default_to_dict, default_from_dict
from haystack.dataclasses import ChatMessage, StreamingChunk
from haystack.lazy_imports import LazyImport
from haystack.utils import ComponentDevice
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import Secret, deserialize_secrets_inplace, serialize_callable, deserialize_callable
logger = logging.getLogger(__name__)

View File

@ -7,7 +7,7 @@ from haystack import component, default_to_dict, default_from_dict
from haystack.dataclasses import ChatMessage, StreamingChunk
from haystack.lazy_imports import LazyImport
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import serialize_callable, deserialize_callable
from haystack.utils.hf import check_valid_model, HFModelType, check_generation_params, list_inference_deployed_models
with LazyImport(message="Run 'pip install transformers'") as transformers_import:

View File

@ -12,8 +12,7 @@ from openai.types.chat.chat_completion_chunk import Choice as ChunkChoice
from haystack import component, default_from_dict, default_to_dict
from haystack.dataclasses import StreamingChunk, ChatMessage
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import Secret, deserialize_secrets_inplace, serialize_callable, deserialize_callable
logger = logging.getLogger(__name__)

View File

@ -6,8 +6,7 @@ from urllib.parse import urlparse
from haystack import component, default_to_dict, default_from_dict
from haystack.dataclasses import StreamingChunk
from haystack.lazy_imports import LazyImport
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import Secret, deserialize_secrets_inplace, serialize_callable, deserialize_callable
from haystack.utils.hf import check_valid_model, HFModelType, check_generation_params, list_inference_deployed_models
with LazyImport(message="Run 'pip install transformers'") as transformers_import:

View File

@ -9,7 +9,7 @@ from openai.types.chat import ChatCompletionChunk, ChatCompletion
from haystack import component, default_from_dict, default_to_dict
from haystack.dataclasses import StreamingChunk, ChatMessage
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import serialize_callable, deserialize_callable
logger = logging.getLogger(__name__)

View File

@ -1,7 +1,7 @@
from typing import Optional, Callable
from haystack.dataclasses import StreamingChunk
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import serialize_callable, deserialize_callable
def print_streaming_chunk(chunk: StreamingChunk) -> None:

View File

@ -4,7 +4,7 @@ from typing import Any, Dict
from haystack import component, default_from_dict, default_to_dict
from haystack.core.component.types import Variadic
from haystack.utils.type_serialization import deserialize_type, serialize_type
from haystack.utils import deserialize_type, serialize_type
if sys.version_info < (3, 10):
from typing_extensions import TypeAlias

View File

@ -5,7 +5,7 @@ from jinja2 import meta, Environment, TemplateSyntaxError
from jinja2.nativetypes import NativeEnvironment
from haystack import component, default_from_dict, default_to_dict
from haystack.utils.type_serialization import serialize_type, deserialize_type
from haystack.utils import serialize_type, deserialize_type
logger = logging.getLogger(__name__)

View File

@ -4,6 +4,8 @@ from .expit import expit
from .filters import document_matches_filter
from .jupyter import is_in_jupyter
from .requests_utils import request_with_retry
from .callable_serialization import serialize_callable, deserialize_callable
from .type_serialization import serialize_type, deserialize_type
__all__ = [
"Secret",
@ -16,4 +18,8 @@ __all__ = [
"document_matches_filter",
"is_in_jupyter",
"request_with_retry",
"serialize_callable",
"deserialize_callable",
"serialize_type",
"deserialize_type",
]

View File

@ -1,7 +1,7 @@
import requests
from haystack.components.generators.utils import print_streaming_chunk
from haystack.utils.callable_serialization import serialize_callable, deserialize_callable
from haystack.utils import serialize_callable, deserialize_callable
def some_random_callable_for_testing(some_ignored_arg: str):