Home / Function/ acompletion_with_retry() — langchain Function Reference

acompletion_with_retry() — langchain Function Reference

Architecture documentation for the acompletion_with_retry() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8db35ed5_08a5_0e78_5859_838dd98768d9["acompletion_with_retry()"]
  cfb937d2_ce7f_5338_2b62_6452043ac78a["chat_models.py"]
  8db35ed5_08a5_0e78_5859_838dd98768d9 -->|defined in| cfb937d2_ce7f_5338_2b62_6452043ac78a
  2a12b41b_5f2f_1d13_ac98_5c73c67a29ff["_astream()"]
  2a12b41b_5f2f_1d13_ac98_5c73c67a29ff -->|calls| 8db35ed5_08a5_0e78_5859_838dd98768d9
  bffb747f_7e93_8a24_7256_48674e68bd78["_agenerate()"]
  bffb747f_7e93_8a24_7256_48674e68bd78 -->|calls| 8db35ed5_08a5_0e78_5859_838dd98768d9
  60ceccfa_ae6a_23d0_4fb3_9a70af912074["_create_retry_decorator()"]
  8db35ed5_08a5_0e78_5859_838dd98768d9 -->|calls| 60ceccfa_ae6a_23d0_4fb3_9a70af912074
  09d0f5ce_3c2f_d34c_f826_0393269f0685["_aiter_sse()"]
  8db35ed5_08a5_0e78_5859_838dd98768d9 -->|calls| 09d0f5ce_3c2f_d34c_f826_0393269f0685
  7e7a3965_93cb_5f0e_d0f9_9b939f2b27cc["_araise_on_error()"]
  8db35ed5_08a5_0e78_5859_838dd98768d9 -->|calls| 7e7a3965_93cb_5f0e_d0f9_9b939f2b27cc
  style 8db35ed5_08a5_0e78_5859_838dd98768d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/mistralai/langchain_mistralai/chat_models.py lines 220–242

async def acompletion_with_retry(
    llm: ChatMistralAI,
    run_manager: AsyncCallbackManagerForLLMRun | None = None,
    **kwargs: Any,
) -> Any:
    """Use tenacity to retry the async completion call."""
    retry_decorator = _create_retry_decorator(llm, run_manager=run_manager)

    @retry_decorator
    async def _completion_with_retry(**kwargs: Any) -> Any:
        if "stream" not in kwargs:
            kwargs["stream"] = False
        stream = kwargs["stream"]
        if stream:
            event_source = aconnect_sse(
                llm.async_client, "POST", "/chat/completions", json=kwargs
            )
            return _aiter_sse(event_source)
        response = await llm.async_client.post(url="/chat/completions", json=kwargs)
        await _araise_on_error(response)
        return response.json()

    return await _completion_with_retry(**kwargs)

Domain

Subdomains

Frequently Asked Questions

What does acompletion_with_retry() do?
acompletion_with_retry() is a function in the langchain codebase, defined in libs/partners/mistralai/langchain_mistralai/chat_models.py.
Where is acompletion_with_retry() defined?
acompletion_with_retry() is defined in libs/partners/mistralai/langchain_mistralai/chat_models.py at line 220.
What does acompletion_with_retry() call?
acompletion_with_retry() calls 3 function(s): _aiter_sse, _araise_on_error, _create_retry_decorator.
What calls acompletion_with_retry()?
acompletion_with_retry() is called by 2 function(s): _agenerate, _astream.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free