_acall() — langchain Function Reference
Architecture documentation for the _acall() function in llms.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 40512e45_7b9d_dbee_2106_59fc9edca16c["_acall()"] c95a497f_938f_2be9_842e_087a0766cf00["AnthropicLLM"] 40512e45_7b9d_dbee_2106_59fc9edca16c -->|defined in| c95a497f_938f_2be9_842e_087a0766cf00 3f0a5215_29d7_44ca_e135_a3f37294ae0c["_astream()"] 40512e45_7b9d_dbee_2106_59fc9edca16c -->|calls| 3f0a5215_29d7_44ca_e135_a3f37294ae0c 5b0cfa0b_130d_960a_411e_cc97a2c28a93["_get_anthropic_stop()"] 40512e45_7b9d_dbee_2106_59fc9edca16c -->|calls| 5b0cfa0b_130d_960a_411e_cc97a2c28a93 04edfbcc_f913_d95a_6261_c2a81f9f570e["_format_messages()"] 40512e45_7b9d_dbee_2106_59fc9edca16c -->|calls| 04edfbcc_f913_d95a_6261_c2a81f9f570e style 40512e45_7b9d_dbee_2106_59fc9edca16c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/llms.py lines 302–332
async def _acall(
self,
prompt: str,
stop: list[str] | None = None,
run_manager: AsyncCallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> str:
"""Call out to Anthropic's completion endpoint asynchronously."""
if self.streaming:
completion = ""
async for chunk in self._astream(
prompt=prompt,
stop=stop,
run_manager=run_manager,
**kwargs,
):
completion += chunk.text
return completion
stop = self._get_anthropic_stop(stop)
params = {**self._default_params, **kwargs}
# Remove parameters not supported by Messages API
params = {k: v for k, v in params.items() if k != "max_tokens_to_sample"}
response = await self.async_client.messages.create(
messages=self._format_messages(prompt),
stop_sequences=stop if stop else None,
**params,
)
return response.content[0].text
Domain
Subdomains
Source
Frequently Asked Questions
What does _acall() do?
_acall() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/llms.py.
Where is _acall() defined?
_acall() is defined in libs/partners/anthropic/langchain_anthropic/llms.py at line 302.
What does _acall() call?
_acall() calls 3 function(s): _astream, _format_messages, _get_anthropic_stop.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free