-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Nvidia integration to support new endpoints (#701)
* Add support for Nvidia catalog API for generator * Add support for Nvidia catalog API for embedders * Add NVIDIA_CATALOG_API_KEY in Nvidia integration workflow * Enable ruff auto formatting for tests * Fix linting * Simplify Secret import and enhance docstring Co-authored-by: Madeesh Kannan <[email protected]> * Add deprecation warnings for NvcfBackend * Add truncate parameter for embedders * Fix linting * Use enum for truncate mode in embedders * Change how truncate argument is handled * Fix truncate conversion * Update truncate docstring --------- Co-authored-by: Madeesh Kannan <[email protected]>
- Loading branch information
1 parent
975e0e5
commit 3c14c52
Showing
14 changed files
with
224 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
from .document_embedder import NvidiaDocumentEmbedder | ||
from .text_embedder import NvidiaTextEmbedder | ||
from .truncate import EmbeddingTruncateMode | ||
|
||
__all__ = [ | ||
"NvidiaDocumentEmbedder", | ||
"NvidiaTextEmbedder", | ||
] | ||
__all__ = ["NvidiaDocumentEmbedder", "NvidiaTextEmbedder", "EmbeddingTruncateMode"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
integrations/nvidia/src/haystack_integrations/components/embedders/nvidia/truncate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from enum import Enum | ||
|
||
|
||
class EmbeddingTruncateMode(Enum): | ||
""" | ||
Specifies how inputs to the NVIDIA embedding components are truncated. | ||
If START, the input will be truncated from the start. | ||
If END, the input will be truncated from the end. | ||
""" | ||
|
||
START = "START" | ||
END = "END" | ||
|
||
def __str__(self): | ||
return self.value | ||
|
||
@classmethod | ||
def from_str(cls, string: str) -> "EmbeddingTruncateMode": | ||
""" | ||
Create an truncate mode from a string. | ||
:param string: | ||
String to convert. | ||
:returns: | ||
Truncate mode. | ||
""" | ||
enum_map = {e.value: e for e in EmbeddingTruncateMode} | ||
opt_mode = enum_map.get(string) | ||
if opt_mode is None: | ||
msg = f"Unknown truncate mode '{string}'. Supported modes are: {list(enum_map.keys())}" | ||
raise ValueError(msg) | ||
return opt_mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.