_call() — langchain Function Reference
Architecture documentation for the _call() function in huggingface_endpoint.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 477387e3_0b93_4ca4_57d9_1d292e64d8f9["_call()"] e6b830e0_e492_47f6_6d0a_65d69c36da10["HuggingFaceEndpoint"] 477387e3_0b93_4ca4_57d9_1d292e64d8f9 -->|defined in| e6b830e0_e492_47f6_6d0a_65d69c36da10 d3d02905_01f3_3fb8_f596_5694650af72c["_invocation_params()"] 477387e3_0b93_4ca4_57d9_1d292e64d8f9 -->|calls| d3d02905_01f3_3fb8_f596_5694650af72c 5b897346_9859_18d1_14ba_55cddb3d7da7["_stream()"] 477387e3_0b93_4ca4_57d9_1d292e64d8f9 -->|calls| 5b897346_9859_18d1_14ba_55cddb3d7da7 style 477387e3_0b93_4ca4_57d9_1d292e64d8f9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py lines 324–352
def _call(
self,
prompt: str,
stop: list[str] | None = None,
run_manager: CallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> str:
"""Call out to HuggingFace Hub's inference endpoint."""
invocation_params = self._invocation_params(stop, **kwargs)
if self.streaming:
completion = ""
for chunk in self._stream(
prompt, run_manager=run_manager, **invocation_params
):
completion += chunk.text
return completion
response_text = self.client.text_generation(
prompt=prompt,
model=self.model,
**invocation_params,
)
# Maybe the generation has stopped at one of the stop sequences:
# then we 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
Source
Frequently Asked Questions
What does _call() do?
_call() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py.
Where is _call() defined?
_call() is defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py at line 324.
What does _call() call?
_call() calls 2 function(s): _invocation_params, _stream.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free