huggingface_endpoint.py — langchain Source File
Architecture documentation for huggingface_endpoint.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c1887c37_473a_ad4a_0b65_5396f3ad7d3f["huggingface_endpoint.py"] 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3 f4d905c6_a2b2_eb8f_be9b_7808b72f6a16["langchain_core.utils"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> f4d905c6_a2b2_eb8f_be9b_7808b72f6a16 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> 91721f45_4909_e489_8c1f_084f8bd87145 be4d43fb_de74_de45_f3c6_e9caae1c1da3["huggingface_hub"] c1887c37_473a_ad4a_0b65_5396f3ad7d3f --> be4d43fb_de74_de45_f3c6_e9caae1c1da3 style c1887c37_473a_ad4a_0b65_5396f3ad7d3f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import os
from typing import Any
from langchain_core.embeddings import Embeddings
from langchain_core.utils import from_env
from pydantic import BaseModel, ConfigDict, Field, model_validator
from typing_extensions import Self
DEFAULT_MODEL = "sentence-transformers/all-mpnet-base-v2"
VALID_TASKS = ("feature-extraction",)
class HuggingFaceEndpointEmbeddings(BaseModel, Embeddings):
"""HuggingFaceHub embedding models.
To use, you should have the `huggingface_hub` python package installed, and the
environment variable `HUGGINGFACEHUB_API_TOKEN` set with your API token, or pass
it as a named parameter to the constructor.
Example:
```python
from langchain_huggingface import HuggingFaceEndpointEmbeddings
model = "sentence-transformers/all-mpnet-base-v2"
hf = HuggingFaceEndpointEmbeddings(
model=model,
task="feature-extraction",
huggingfacehub_api_token="my-api-key",
)
```
"""
client: Any = None
async_client: Any = None
model: str | None = None
"""Model name to use."""
provider: str | None = None
"""Name of the provider to use for inference with the model specified in
`repo_id`. e.g. "sambanova". if not specified, defaults to HF Inference API.
available providers can be found in the [huggingface_hub documentation](https://huggingface.co/docs/huggingface_hub/guides/inference#supported-providers-and-tasks)."""
repo_id: str | None = None
"""Huggingfacehub repository id, for backward compatibility."""
task: str | None = "feature-extraction"
"""Task to call the model with."""
model_kwargs: dict | None = None
"""Keyword arguments to pass to the model."""
huggingfacehub_api_token: str | None = Field(
default_factory=from_env("HUGGINGFACEHUB_API_TOKEN", default=None)
)
model_config = ConfigDict(
// ... (113 more lines)
Domain
Subdomains
Classes
Dependencies
- huggingface_hub
- langchain_core.embeddings
- langchain_core.utils
- os
- pydantic
- typing
- typing_extensions
Source
Frequently Asked Questions
What does huggingface_endpoint.py do?
huggingface_endpoint.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What does huggingface_endpoint.py depend on?
huggingface_endpoint.py imports 7 module(s): huggingface_hub, langchain_core.embeddings, langchain_core.utils, os, pydantic, typing, typing_extensions.
Where is huggingface_endpoint.py in the architecture?
huggingface_endpoint.py is located at libs/partners/huggingface/langchain_huggingface/embeddings/huggingface_endpoint.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/partners/huggingface/langchain_huggingface/embeddings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free