llama-index-llms-bedrock-converse 0.12.5__py3-none-any.whl → 0.12.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,10 +12,12 @@ from typing import (
12
12
  Literal,
13
13
  Union,
14
14
  )
15
+ from botocore.exceptions import ClientError
15
16
  from typing_extensions import TypedDict
16
17
  from tenacity import (
17
18
  before_sleep_log,
18
19
  retry,
20
+ retry_if_exception,
19
21
  retry_if_exception_type,
20
22
  stop_after_attempt,
21
23
  wait_exponential,
@@ -566,11 +568,38 @@ def _create_retry_decorator(client: Any, max_retries: int) -> Callable[[Any], An
566
568
  reraise=True,
567
569
  stop=stop_after_attempt(max_retries),
568
570
  wait=wait_exponential(multiplier=1, min=min_seconds, max=max_seconds),
569
- retry=(retry_if_exception_type(client.exceptions.ThrottlingException)),
571
+ retry=(
572
+ retry_if_exception_type(
573
+ (
574
+ client.exceptions.ThrottlingException,
575
+ client.exceptions.InternalServerException,
576
+ client.exceptions.ServiceUnavailableException,
577
+ client.exceptions.ModelTimeoutException,
578
+ )
579
+ )
580
+ ),
570
581
  before_sleep=before_sleep_log(logger, logging.WARNING),
571
582
  )
572
583
 
573
584
 
585
+ RETRYABLE_ERROR_CODES = frozenset(
586
+ {
587
+ "ThrottlingException",
588
+ "InternalServerException",
589
+ "ServiceUnavailableException",
590
+ "ModelTimeoutException",
591
+ }
592
+ )
593
+
594
+
595
+ def _is_retryable_client_error(exception: BaseException) -> bool:
596
+ """Check if an exception is a retryable ClientError from botocore."""
597
+ if isinstance(exception, ClientError):
598
+ error_code = exception.response.get("Error", {}).get("Code", "")
599
+ return error_code in RETRYABLE_ERROR_CODES
600
+ return False
601
+
602
+
574
603
  def _create_retry_decorator_async(max_retries: int) -> Callable[[Any], Any]:
575
604
  min_seconds = 4
576
605
  max_seconds = 10
@@ -588,9 +617,7 @@ def _create_retry_decorator_async(max_retries: int) -> Callable[[Any], Any]:
588
617
  reraise=True,
589
618
  stop=stop_after_attempt(max_retries),
590
619
  wait=wait_exponential(multiplier=1, min=min_seconds, max=max_seconds),
591
- retry=(
592
- retry_if_exception_type()
593
- ), # TODO: Add throttling exception in async version
620
+ retry=retry_if_exception(_is_retryable_client_error),
594
621
  before_sleep=before_sleep_log(logger, logging.WARNING),
595
622
  )
596
623
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-index-llms-bedrock-converse
3
- Version: 0.12.5
3
+ Version: 0.12.6
4
4
  Summary: llama-index llms bedrock converse integration
5
5
  Author-email: Your Name <you@example.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,7 @@
1
+ llama_index/llms/bedrock_converse/__init__.py,sha256=xE3ZHLXqFr7TTTgQlYH9bLLPRZAV3dJyiz_iUFXBfak,98
2
+ llama_index/llms/bedrock_converse/base.py,sha256=uQ2pD0SwSqbjLdDB9A5O0REky5y6LL3E3UWNIHvKVu8,46074
3
+ llama_index/llms/bedrock_converse/utils.py,sha256=6vbD4TwsG2TPEKgsQ95xOKRZdvLugCxD8CvgveXF4nE,30895
4
+ llama_index_llms_bedrock_converse-0.12.6.dist-info/METADATA,sha256=fvG81GVy7fmKikCM4KzxELutlOd4MqlxZ3NTBnHq2D8,7834
5
+ llama_index_llms_bedrock_converse-0.12.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ llama_index_llms_bedrock_converse-0.12.6.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
7
+ llama_index_llms_bedrock_converse-0.12.6.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- llama_index/llms/bedrock_converse/__init__.py,sha256=xE3ZHLXqFr7TTTgQlYH9bLLPRZAV3dJyiz_iUFXBfak,98
2
- llama_index/llms/bedrock_converse/base.py,sha256=uQ2pD0SwSqbjLdDB9A5O0REky5y6LL3E3UWNIHvKVu8,46074
3
- llama_index/llms/bedrock_converse/utils.py,sha256=FLmQH9k5vYdAW9VzE3fyIh29edBYxQHhx2ovgUoEO7w,30082
4
- llama_index_llms_bedrock_converse-0.12.5.dist-info/METADATA,sha256=ndWUOdGz6co5YzGLUs_rMFz8peUdB-7LsyHJBqP6UUQ,7834
5
- llama_index_llms_bedrock_converse-0.12.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- llama_index_llms_bedrock_converse-0.12.5.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
7
- llama_index_llms_bedrock_converse-0.12.5.dist-info/RECORD,,