Home / Function/ _acall() — langchain Function Reference

_acall() — langchain Function Reference

Architecture documentation for the _acall() function in huggingface_endpoint.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  56f985d3_9992_f0cb_ad40_e11190fde3bb["_acall()"]
  e6b830e0_e492_47f6_6d0a_65d69c36da10["HuggingFaceEndpoint"]
  56f985d3_9992_f0cb_ad40_e11190fde3bb -->|defined in| e6b830e0_e492_47f6_6d0a_65d69c36da10
  d3d02905_01f3_3fb8_f596_5694650af72c["_invocation_params()"]
  56f985d3_9992_f0cb_ad40_e11190fde3bb -->|calls| d3d02905_01f3_3fb8_f596_5694650af72c
  cde77cc5_1e1f_9bb4_ed01_e6c99050c598["_astream()"]
  56f985d3_9992_f0cb_ad40_e11190fde3bb -->|calls| cde77cc5_1e1f_9bb4_ed01_e6c99050c598
  style 56f985d3_9992_f0cb_ad40_e11190fde3bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py lines 354–382

    async def _acall(
        self,
        prompt: str,
        stop: list[str] | None = None,
        run_manager: AsyncCallbackManagerForLLMRun | None = None,
        **kwargs: Any,
    ) -> str:
        invocation_params = self._invocation_params(stop, **kwargs)
        if self.streaming:
            completion = ""
            async for chunk in self._astream(
                prompt, run_manager=run_manager, **invocation_params
            ):
                completion += chunk.text
            return completion

        response_text = await self.async_client.text_generation(
            prompt=prompt,
            **invocation_params,
            model=self.model,
            stream=False,
        )

        # Maybe the generation has stopped at one of the stop sequences:
        # then remove this stop sequence from the end of the generated text
        for stop_seq in invocation_params["stop"]:
            if response_text[-len(stop_seq) :] == stop_seq:
                response_text = response_text[: -len(stop_seq)]
        return response_text

Domain

Subdomains

Frequently Asked Questions

What does _acall() do?
_acall() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py.
Where is _acall() defined?
_acall() is defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py at line 354.
What does _acall() call?
_acall() calls 2 function(s): _astream, _invocation_params.

Analyze Your Own Codebase

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

Try Supermodel Free