Skip to content

Commit

Permalink
just some more quick fixes (deepset-ai#7498)
Browse files Browse the repository at this point in the history
* just some more quick fixes

* Update haystack/utils/url_validation.py

Co-authored-by: Madeesh Kannan <[email protected]>

---------

Co-authored-by: Madeesh Kannan <[email protected]>
  • Loading branch information
davidsbatista and shadeMe authored Apr 8, 2024
1 parent b20a14d commit 3777f43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions haystack/utils/callable_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
def serialize_callable(callable_handle: Callable) -> str:
"""
Serializes a callable to its full path.
:param callable_handle: The callable to serialize
:return: The full path of the callable
"""
Expand All @@ -24,6 +25,7 @@ def serialize_callable(callable_handle: Callable) -> str:
def deserialize_callable(callable_handle: str) -> Optional[Callable]:
"""
Deserializes a callable given its full import path as a string.
:param callable_handle: The full path of the callable_handle
:return: The callable
:raises DeserializationError: If the callable cannot be found
Expand Down
7 changes: 7 additions & 0 deletions haystack/utils/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def __str__(self):

@staticmethod
def from_str(string: str) -> "HFGenerationAPIType":
"""
Convert a string to a HFGenerationAPIType enum.
:param string: The string to convert.
:return: The corresponding HFGenerationAPIType enum.
"""
enum_map = {e.value: e for e in HFGenerationAPIType}
mode = enum_map.get(string)
if mode is None:
Expand Down
3 changes: 2 additions & 1 deletion haystack/utils/url_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from urllib.parse import urlparse


def is_valid_http_url(url) -> bool:
def is_valid_http_url(url: str) -> bool:
"""Check if a URL is a valid HTTP/HTTPS URL."""
r = urlparse(url)
return all([r.scheme in ["http", "https"], r.netloc])

0 comments on commit 3777f43

Please sign in to comment.