Skip to content

Add embed model name prefix for LiteLLM proxy compatability#2293

Open
ChrisJar wants to merge 1 commit into
NVIDIA:mainfrom
ChrisJar:inf-hub
Open

Add embed model name prefix for LiteLLM proxy compatability#2293
ChrisJar wants to merge 1 commit into
NVIDIA:mainfrom
ChrisJar:inf-hub

Conversation

@ChrisJar

@ChrisJar ChrisJar commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@ChrisJar ChrisJar requested review from a team as code owners July 2, 2026 14:33
@ChrisJar ChrisJar requested a review from charlesbluca July 2, 2026 14:33
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an embed_model_name_prefix feature that prepends a LiteLLM route/org prefix to the embedding model name when using remote endpoints. It is a targeted fix to allow deployment with namespaced model IDs (e.g. "team/model/provider") required by LiteLLM proxies.

  • New prepend_model_name_prefix utility in string_processing/__init__.py applies the prefix once, respecting None/empty-string guards and stripping leading slashes from the model name.
  • normalize_embed_kwargs is now the single normalization point: it eagerly applies and removes embed_model_name_prefix from the task kwargs dict, ensuring the prefix propagates correctly through the EmbedParams → build_embed_kwargs path without double-application.
  • Helm, CLI, service config, vectordb app, runtime, and agentic paths all receive the new parameter with consistent forwarding and correct remote-only semantics (prefix is silently dropped when no remote endpoint is configured).

Confidence Score: 5/5

Safe to merge — the prefix feature follows a clear remote-only contract and the three distinct application points (normalize_embed_kwargs, infer_microservice, _http_embed_openai_compat) are non-overlapping, so no double-prefix can occur.

The change is additive: all new parameters default to None/'' and produce identical behavior when unset. The normalization logic correctly pops embed_model_name_prefix before it can be applied a second time in any downstream path. Tests cover the key normalization scenarios, CLI paths, and the vectordb flow. The one untested path (agentic) is plumbing-only and has no novel logic.

The agentic embedding path in nemo_retriever/src/nemo_retriever/query/agentic.py has no test verifying that the new prefix reaches the actual HTTP embedding call.

Important Files Changed

Filename Overview
nemo_retriever/src/nemo_retriever/common/api/util/string_processing/init.py Adds prepend_model_name_prefix — correctly handles None/empty prefix and strips leading slashes from the model name.
nemo_retriever/src/nemo_retriever/common/params/utils.py Extends normalize_embed_kwargs to pop and eagerly apply embed_model_name_prefix when a remote endpoint is present; build_embed_option_kwargs now plumbs through the new parameter.
nemo_retriever/src/nemo_retriever/models/inference/main_text_embed.py Threads model_name_prefix through _async_runner → _async_request_handler → _make_async_request → _http_embed_openai_compat; prefix applied once just before the HTTP call.
nemo_retriever/src/nemo_retriever/models/nim/util/init.py Adds model_name_prefix parameter to infer_microservice; prefix is applied via prepend_model_name_prefix on the HTTP branch only — correct, single-application point.
nemo_retriever/src/nemo_retriever/service/vectordb_app.py Adds embed_model_name_prefix to _embed_queries_remote, VectorDBState, create_vectordb_app, and the argparse CLI entry point; --embed-model-name-prefix '' is correctly normalized to None.
nemo_retriever/src/nemo_retriever/query/agentic.py Adds query_embedder_prefix to AgenticRetrievalConfig and forwards it as embed_model_name_prefix in embed_kwargs; no dedicated test for this path with the prefix feature.
nemo_retriever/tests/test_embed_params.py Five new unit tests cover remote-only, bare-name, other-vendor-namespace, no-prefix, and prefix-applied scenarios for build_embed_option_kwargs.
nemo_retriever/tests/test_service_local_models.py Extended test_build_embed_params_from_nim_config to assert embed_model_name_prefix is stored in EmbedParams — correct for lazy normalization, but downstream prefix application is not verified in this file.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["User / Helm config\n(embed_model_name_prefix)"] --> B{Code path}

    B -->|"CLI / service / query"| C["build_embed_option_kwargs\nor build_embed_params"]
    C --> D["normalize_embed_kwargs\n(pops embed_model_name_prefix,\neagerly prefixes model_name\nif remote endpoint present)"]
    D --> E["EmbedParams / task_config\n(model_name already prefixed;\nno embed_model_name_prefix key)"]
    E --> F["Pipeline / HTTP call\n(model_name used as-is,\nno further prefix applied)"]

    B -->|"Library runtime\n(_embed_group)"| G["embed_text_main_text_embed\n(embed_model_name_prefix passed through)"]
    G --> H["_embed_group\n(sets task_config embed_model_name_prefix\nand TextEmbeddingConfig.embedding_model_prefix)"]
    H --> I["create_text_embeddings_for_df\n(resolves model_name_prefix from task_config)"]
    I --> J["_http_embed_openai_compat\n(calls prepend_model_name_prefix once,\nmodel_name still un-prefixed at this point)"]

    B -->|"VectorDB query"| K["_embed_queries_remote\n(embed_model_name_prefix passed)"]
    K --> L["infer_microservice\n(calls prepend_model_name_prefix once\non HTTP branch only)"]

    B -->|"Agentic query"| M["AgenticRetriever\n(embed_kwargs includes\nembed_model_name_prefix — untested)"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["User / Helm config\n(embed_model_name_prefix)"] --> B{Code path}

    B -->|"CLI / service / query"| C["build_embed_option_kwargs\nor build_embed_params"]
    C --> D["normalize_embed_kwargs\n(pops embed_model_name_prefix,\neagerly prefixes model_name\nif remote endpoint present)"]
    D --> E["EmbedParams / task_config\n(model_name already prefixed;\nno embed_model_name_prefix key)"]
    E --> F["Pipeline / HTTP call\n(model_name used as-is,\nno further prefix applied)"]

    B -->|"Library runtime\n(_embed_group)"| G["embed_text_main_text_embed\n(embed_model_name_prefix passed through)"]
    G --> H["_embed_group\n(sets task_config embed_model_name_prefix\nand TextEmbeddingConfig.embedding_model_prefix)"]
    H --> I["create_text_embeddings_for_df\n(resolves model_name_prefix from task_config)"]
    I --> J["_http_embed_openai_compat\n(calls prepend_model_name_prefix once,\nmodel_name still un-prefixed at this point)"]

    B -->|"VectorDB query"| K["_embed_queries_remote\n(embed_model_name_prefix passed)"]
    K --> L["infer_microservice\n(calls prepend_model_name_prefix once\non HTTP branch only)"]

    B -->|"Agentic query"| M["AgenticRetriever\n(embed_kwargs includes\nembed_model_name_prefix — untested)"]
Loading

Reviews (3): Last reviewed commit: "Add embed model name prefix for LiteLLM ..." | Re-trigger Greptile

Comment thread nemo_retriever/src/nemo_retriever/service/vectordb_app.py
Comment thread nemo_retriever/src/nemo_retriever/common/api/util/string_processing/__init__.py Outdated
Comment thread nemo_retriever/src/nemo_retriever/common/api/util/string_processing/__init__.py Outdated
@ChrisJar ChrisJar changed the title Fix Inference Hub embedding model names Add embed model name prefix for LiteLLM proxy compatability Jul 2, 2026
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.

1 participant