completion_with_retry() — langchain Function Reference
Architecture documentation for the completion_with_retry() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c["completion_with_retry()"] 24cf3ac3_ed46_66ab_27f4_5b5d67f0b7f0["ChatMistralAI"] b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c -->|defined in| 24cf3ac3_ed46_66ab_27f4_5b5d67f0b7f0 c1f04843_2b34_321d_f754_b18729e7e176["_generate()"] c1f04843_2b34_321d_f754_b18729e7e176 -->|calls| b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c f625aace_a365_9a0c_afa8_4757741f35c8["_stream()"] f625aace_a365_9a0c_afa8_4757741f35c8 -->|calls| b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c 60ceccfa_ae6a_23d0_4fb3_9a70af912074["_create_retry_decorator()"] b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c -->|calls| 60ceccfa_ae6a_23d0_4fb3_9a70af912074 180f621a_22ca_acd4_fa6a_bd5ca142e8b0["_raise_on_error()"] b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c -->|calls| 180f621a_22ca_acd4_fa6a_bd5ca142e8b0 style b8aa7601_1d62_2c3d_dff3_a3d1739e2d8c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/mistralai/langchain_mistralai/chat_models.py lines 555–583
def completion_with_retry(
self, run_manager: CallbackManagerForLLMRun | None = None, **kwargs: Any
) -> Any:
"""Use tenacity to retry the completion call."""
retry_decorator = _create_retry_decorator(self, run_manager=run_manager)
@retry_decorator
def _completion_with_retry(**kwargs: Any) -> Any:
if "stream" not in kwargs:
kwargs["stream"] = False
stream = kwargs["stream"]
if stream:
def iter_sse() -> Iterator[dict]:
with connect_sse(
self.client, "POST", "/chat/completions", json=kwargs
) as event_source:
_raise_on_error(event_source.response)
for event in event_source.iter_sse():
if event.data == "[DONE]":
return
yield event.json()
return iter_sse()
response = self.client.post(url="/chat/completions", json=kwargs)
_raise_on_error(response)
return response.json()
return _completion_with_retry(**kwargs)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does completion_with_retry() do?
completion_with_retry() is a function in the langchain codebase, defined in libs/partners/mistralai/langchain_mistralai/chat_models.py.
Where is completion_with_retry() defined?
completion_with_retry() is defined in libs/partners/mistralai/langchain_mistralai/chat_models.py at line 555.
What does completion_with_retry() call?
completion_with_retry() calls 2 function(s): _create_retry_decorator, _raise_on_error.
What calls completion_with_retry()?
completion_with_retry() is called by 2 function(s): _generate, _stream.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free