Skip to content

Commit 9fd5643

Browse files
authored
fix: Lazy-import botocore exception to avoid unnecessary dependency for using vectorize module (#457)
PR #452 imports an exception from botocore outside of the function where it is needed, which unintentionally adds a dependency on botocore for the package. This PR fixes this issue to avoid importing from botocore outside of the function that needs the exception.
1 parent ff415fb commit 9fd5643

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

redisvl/utils/vectorize/bedrock.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union
77

8-
from botocore.exceptions import ValidationError
98
from pydantic import ConfigDict
109
from tenacity import retry, stop_after_attempt, wait_random_exponential
1110
from tenacity.retry import retry_if_not_exception_type
@@ -221,6 +220,8 @@ def _embed(self, content: Any, **kwargs) -> List[float]:
221220
ValueError: If attempting to embed an image with a text model
222221
ValueError: If embedding fails
223222
"""
223+
from botocore.exceptions import ValidationError
224+
224225
body = self._serialize_request_body(content)
225226

226227
try:
@@ -261,6 +262,8 @@ def _embed_many(
261262
ValueError: If attempting to embed an image with a text model
262263
ValueError: If embedding fails
263264
"""
265+
from botocore.exceptions import ValidationError
266+
264267
if not isinstance(contents, list):
265268
raise TypeError("`contents` must be a list")
266269

0 commit comments

Comments
 (0)