Fix: Enable max_retries Parameter in ChatMistralAI Class (#30448)

**partners: Enable max_retries in ChatMistralAI**

**Description**

- This pull request reactivates the retry logic in the
completion_with_retry method of the ChatMistralAI class, restoring the
intended functionality of the previously ineffective max_retries
parameter. New unit test that mocks failed/successful retry calls and an
integration test to confirm end-to-end functionality.

**Issue**
- Closes #30362

**Dependencies**
- No additional dependencies required

Co-authored-by: andrasfe <andrasf94@gmail.com>
This commit is contained in:
Andras L Ferenczi
2025-03-27 11:53:44 -04:00
committed by GitHub
parent 3aa080c2a8
commit 63673b765b
3 changed files with 86 additions and 3 deletions

View File

@@ -464,9 +464,9 @@ class ChatMistralAI(BaseChatModel):
self, run_manager: Optional[CallbackManagerForLLMRun] = None, **kwargs: Any
) -> Any:
"""Use tenacity to retry the completion call."""
# retry_decorator = _create_retry_decorator(self, run_manager=run_manager)
retry_decorator = _create_retry_decorator(self, run_manager=run_manager)
# @retry_decorator
@retry_decorator
def _completion_with_retry(**kwargs: Any) -> Any:
if "stream" not in kwargs:
kwargs["stream"] = False