-
Notifications
You must be signed in to change notification settings - Fork 343
Reject mixed Nemotron Parse endpoint lists #2543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,11 +7,29 @@ | |||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| from typing import TYPE_CHECKING, Any, Dict | ||||||||||||||||||||||||||||||
| from urllib.parse import urlsplit | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if TYPE_CHECKING: | ||||||||||||||||||||||||||||||
| from nemo_retriever.common.params.models import BatchTuningParams | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def validate_nemotron_parse_endpoint_list(invoke_url: str | None) -> tuple[str, ...]: | ||||||||||||||||||||||||||||||
| """Normalize Parse endpoints and reject mixed NVIDIA Build/self-hosted lists.""" | ||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new public helper does not document its parameter, normalized tuple return value, or mixed-endpoint
Suggested change
Rule Used: Public modules, classes, and functions must have d... (source) Prompt To Fix With AIThis is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/common/params/utils.py
Line: 16-17
Comment:
**Validator contract lacks documentation**
The new public helper does not document its parameter, normalized tuple return value, or mixed-endpoint `ValueError`, leaving callers without the required public interface contract.
```suggestion
def validate_nemotron_parse_endpoint_list(invoke_url: str | None) -> tuple[str, ...]:
"""Normalize and validate a Nemotron Parse endpoint list.
Args:
invoke_url: A comma-separated endpoint list, or ``None``.
Returns:
The normalized, nonempty endpoints.
Raises:
ValueError: If the list mixes NVIDIA Build and self-hosted endpoints.
"""
```
**Rule Used:** Public modules, classes, and functions must have d... ([source](.greptile))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||||||
| invoke_urls = tuple(part.strip() for part in str(invoke_url or "").split(",") if part.strip()) | ||||||||||||||||||||||||||||||
| build_endpoints = tuple( | ||||||||||||||||||||||||||||||
| (urlsplit(endpoint).hostname or "").lower() == "integrate.api.nvidia.com" for endpoint in invoke_urls | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| if any(build_endpoints) and not all(build_endpoints): | ||||||||||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||||||||||
| "Nemotron Parse endpoint lists cannot mix NVIDIA Build and self-hosted endpoints. " | ||||||||||||||||||||||||||||||
| "One `nemotron_parse_model` and request contract apply to the entire endpoint list, but NVIDIA Build " | ||||||||||||||||||||||||||||||
| "requires `nvidia/nemotron-parse` with the hosted tool-call contract and self-hosted Parse requires a " | ||||||||||||||||||||||||||||||
| "versioned model with a tagged contract. Configure a homogeneous endpoint list or use separate " | ||||||||||||||||||||||||||||||
| "ingestors for NVIDIA Build and self-hosted Parse." | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| return invoke_urls | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def coerce_params[T](params: T | None, model_cls: type[T], kwargs: dict[str, Any]) -> T: | ||||||||||||||||||||||||||||||
| """Merge *params* and *kwargs* into an instance of *model_cls*. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
nemotron_parse_invoke_urlcontains only whitespace andinvoke_urlcontains mixed endpoints, raw truthiness validates the empty primary value instead of the effective fallback list, soExtractParamsconstruction succeeds instead of raising the required validation error.Knowledge Base Used:
Prompt To Fix With AI