[BUG]: HuggingFace embedder remote mode fails to initialize (endpoint_url rejected as model and timeout dropped)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
Start in packages/nvidia_nat_langchain/src/nat/plugins/langchain/embedder.py at the huggingface_langchain branch that builds HuggingFaceEndpointEmbeddings when endpoint_url is set, and check the timeout field in packages/nvidia_nat_core/src/nat/embedder/huggingface_embedder.py. Done means the remote branch passes timeout through and does not feed the URL into model. The issue already has an open linked pull request (#2542), so coordinate with it before starting.
Written by the indexing model from the issue text.
Description
Version
develop at commit 15fa7b6e0de923a6f535351720d4ab6353d78ef3
Which installation method(s) does this occur on?
- Source
- PyPi
Describe the bug.
In packages/nvidia_nat_langchain/src/nat/plugins/langchain/embedder.py, huggingface_langchain attempts to initialize HuggingFaceEndpointEmbeddings when embedder_config.endpoint_url is set:
if embedder_config.endpoint_url:
from langchain_huggingface import HuggingFaceEndpointEmbeddings
client = HuggingFaceEndpointEmbeddings(
model=embedder_config.endpoint_url,
huggingfacehub_api_token=get_secret_value(embedder_config.api_key),
)
This causes two bugs during remote embedder initialization:
endpoint_urlrejected asmodel:HuggingFaceEndpointEmbeddings(fromlangchain-huggingface) expectsmodelto be a Hugging Face Hub repository ID (e.g.,BAAI/bge-small-en-v1.5), not an HTTP/HTTPS URL. Passingmodel=embedder_config.endpoint_urlraises a validation error fromhuggingface_hub(HFValidationError: Repo id must use alphanumeric chars... ':' is forbidden: 'http...'). As a result, remote mode fails at startup for any valid TEI or Hugging Face Inference Endpoint URL.timeoutis dropped:HuggingFaceEmbedderConfiginpackages/nvidia_nat_core/src/nat/embedder/huggingface_embedder.pydefinestimeout: float = Field(default=120.0, ge=1.0), buttimeoutis never forwarded toHuggingFaceEndpointEmbeddings(timeout=...), ignoring user-configured network timeouts.model_nameis discarded in remote mode: If a user supplies both a model identifier and anendpoint_url(e.g., when targeting a multi-model TEI gateway or HuggingFace inference endpoint),model_nameis completely ignored.
Minimum reproducible example
import asyncio
from pydantic import SecretStr
from nat.embedder.huggingface_embedder import HuggingFaceEmbedderConfig
from nat.plugins.langchain.embedder import huggingface_langchain
async def reproduce():
config = HuggingFaceEmbedderConfig(
endpoint_url="https://api-inference.huggingface.co/models/BAAI/bge-small-en-v1.5",
api_key=SecretStr("hf_dummy_token"),
timeout=60.0,
)
# Attempting to yield client
async for client in huggingface_langchain(config, None):
print(client)
asyncio.run(reproduce())
Equivalent workflow YAML:
embedders:
remote_tei:
_type: huggingface
endpoint_url: "https://api-inference.huggingface.co/models/BAAI/bge-small-en-v1.5"
api_key: "${HF_API_KEY}"
timeout: 60.0
Relevant log output
Click here to see error details
huggingface_hub.utils.validators.HFValidationError: Repo id must use alphanumeric chars or '-', '', '.', '--' and '..' are forbidden, ':' is forbidden: 'https://api-inference.huggingface.co/models/BAAI/bge-small-en-v1.5'. Use
repo_typeargument if needed.
Other/Misc.
- Previously noted in discussion on #2528 / PR #2529, where local HuggingFace embeddings were fixed, but remote
endpoint_urlsupport was excluded from scope. - Suggested direction:
- If using
HuggingFaceEndpointEmbeddings, provide the model repo ID viaembedder_config.model_name(or deduce repo ID if endpoint follows Hub URL pattern), and forwardtimeout=embedder_config.timeout. - For custom self-hosted TEI servers running with an OpenAI-compatible endpoint, document or route through the OpenAI embedder client pointing to TEI's
/v1endpoint.
- If using
Code of Conduct
- I agree to follow the NeMo Agent Toolkit Code of Conduct
- I have searched the open bugs and have found no duplicates for this bug report
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 814
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 131
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/NeMo-Agent-Toolkit
-
Alert triage agent: the HTTP server (run.py) starts every triage with a config file that does not existPossibly taken @trackoor claimed this 1 day ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/NeMo-Agent-Toolkit#2536 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
NVIDIA/NeMo-Agent-Toolkit#2534 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
NVIDIA/NeMo-Agent-Toolkit#2539 ·
Maintainers usually reply within 1 day
-
[FEA] Add a Future AGI OTLP telemetry exporter (futureagi)Possibly taken @nik13 claimed this 4 days ago. Open
NVIDIA/NeMo-Agent-Toolkit#2489 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
MCP client: let tool errors reach agent error handling, and keep structured-only resultsPossibly taken @Sushmit404 claimed this 17 days ago. Openfeature request Needs Triage
Difficulty 4/5 3-5 days Newbie friendliness 25/100
NVIDIA/NeMo-Agent-Toolkit#2362 ·
Maintainers usually reply within 1 day
All issues in NVIDIA/NeMo-Agent-Toolkit
Similar issues
-
cost:cheap practicality:seen-in-the-wild severity:medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
fairagro/m4.2_advanced_middleware_api#620 ·
Maintainers usually reply within 1 day
-
area:security effort:S priority:P2 provider:local-libvirt status:ready type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
randomparity/kdive#3495 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/markitdown#2820 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days