Skip to content

fix: use input_type instead of task for NVIDIA NIM embeddings#219

Closed
vicjayjay wants to merge 1 commit intoCortexReach:masterfrom
vicjayjay:fix/nvidia-nim-embedding-task-field
Closed

fix: use input_type instead of task for NVIDIA NIM embeddings#219
vicjayjay wants to merge 1 commit intoCortexReach:masterfrom
vicjayjay:fix/nvidia-nim-embedding-task-field

Conversation

@vicjayjay
Copy link
Copy Markdown
Contributor

Summary

  • NVIDIA NIM API now strictly validates request bodies and rejects unknown fields
  • The task parameter causes a 400 error on NVIDIA endpoints
  • Fix routes by provider: NVIDIA endpoints get input_type, others get task

Root Cause

buildPayload() in embedder.ts was sending both task and input_type to all providers. NVIDIA rejects task as unknown.

Test plan

  • Verified with nvidia/llama-3.2-nemoretriever-1b-vlm-embed-v1
  • Non-NVIDIA providers still receive task parameter as before

NVIDIA NIM API now strictly validates request bodies and rejects unknown
fields. The task parameter (used by Jina and others) causes a 400 error:
"Extra inputs are not permitted, input: 'passage'".

Route by provider: NVIDIA endpoints get input_type, others get task.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Mar 15, 2026

This is pointing at a real compatibility problem, but I don’t think the current patch is complete enough to merge yet.

Two gaps need to be addressed:

  1. input_type value mapping is still wrong for existing config

    • This repo currently documents/configures taskQuery / taskPassage as retrieval.query / retrieval.passage
    • NVIDIA NIM expects input_type values like query / passage, not retrieval.query / retrieval.passage
    • So the current change appears to rename the field without translating the value, which likely still breaks existing NVIDIA configs
  2. Provider detection is too narrow

    • The current branch only switches behavior when baseURL matches nvidia.com
    • That misses self-hosted NIM, private gateways, reverse proxies, and other non-nvidia.com deployments
    • If the goal is “NVIDIA NIM compatibility”, URL substring matching alone is not robust enough

Please also add automated coverage for this.
At minimum, I want tests that prove:

  • NVIDIA-compatible requests send input_type
  • non-NVIDIA providers still send task
  • retrieval.query / retrieval.passage are mapped correctly for NVIDIA if that is the intended compatibility path

Once those pieces are in place, I’m happy to take another look.

@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Mar 18, 2026

感谢提交!NVIDIA NIM 拒绝 task 字段的问题是真实存在的。

不过这个 PR 基于的代码已经过时了 — #216 合并后,buildPayload 中的 if (task) payload.task = task; 已被替换为 provider profile 体系:

if (this._capabilities.taskField && task) {
  const value = cap.taskValueMap?.[task] ?? task;
  payload[cap.taskField] = value;
}

现在正确的做法是在 detectEmbeddingProviderProfile 中加一个 "nvidia" profile,然后在 getEmbeddingCapabilities 中设置 taskField: "input_type",与 Voyage 的处理方式一致。这样不需要在 buildPayload 中硬编码 URL 判断。

如果你有兴趣,欢迎基于最新 master 重新提交。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants