-
Notifications
You must be signed in to change notification settings - Fork 625
UN-3503 [FEAT] Add NVIDIA Build and OpenRouter OpenAI-compatible LLM and embedding adapters #2004
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eed8223
UN-3503 [FEAT] Add NVIDIA Build and OpenRouter OpenAI-compatible LLM …
chandrasekharan-zipstack e9cb517
UN-3503 [FEAT] Add NVIDIA Build embedding adapter
chandrasekharan-zipstack b655ffc
UN-3503 [FEAT] Expose API base override, add OpenAI Compatible embedd…
chandrasekharan-zipstack 8fa9405
UN-3503 [FEAT] Address review: pin branded api_base field defaults
chandrasekharan-zipstack 1f96699
UN-3503 [FEAT] Route OpenRouter natively, add doc links to help text
chandrasekharan-zipstack efaeb3c
UN-3503 [FIX] Default embedding encoding_format to float for NVIDIA B…
chandrasekharan-zipstack 3017466
UN-3503 [FIX] Stop forwarding embed_batch_size to litellm.embedding
chandrasekharan-zipstack 0970d1e
UN-3503 [FIX] Send input_type for NVIDIA Build asymmetric embeddings
chandrasekharan-zipstack f95eb40
UN-3503 [MISC] Drop inert embed_batch_size from embedding schemas
chandrasekharan-zipstack 69f7286
UN-3503 [MISC] Make code comments concise and generic
chandrasekharan-zipstack 78eddcb
UN-3503 [FIX] Address review: keyless compat embedding key, OpenRoute…
chandrasekharan-zipstack ca82251
Merge branch 'main' into feat/branded-openai-adapters
chandrasekharan-zipstack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
45 changes: 45 additions & 0 deletions
45
unstract/sdk1/src/unstract/sdk1/adapters/embedding1/nvidia_build.py
This file contains hidden or 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,45 @@ | ||
| from typing import Any | ||
|
|
||
| from unstract.sdk1.adapters.base1 import BaseAdapter, NvidiaBuildEmbeddingParameters | ||
| from unstract.sdk1.adapters.enums import AdapterTypes | ||
|
|
||
| DESCRIPTION = ( | ||
| "Adapter for NVIDIA's OpenAI-compatible embedding models (build.nvidia.com). " | ||
| "Supply a model name and your NVIDIA API key; the endpoint is preconfigured." | ||
| ) | ||
|
|
||
|
|
||
| class NvidiaBuildEmbeddingAdapter(NvidiaBuildEmbeddingParameters, BaseAdapter): | ||
| @staticmethod | ||
| def get_id() -> str: | ||
| return "nvidiabuild|2afcdf59-5323-4086-97fb-d9a0432e7795" | ||
|
|
||
| @staticmethod | ||
| def get_metadata() -> dict[str, Any]: | ||
| return { | ||
| "name": "NVIDIA Build", | ||
| "version": "1.0.0", | ||
| "adapter": NvidiaBuildEmbeddingAdapter, | ||
| "description": DESCRIPTION, | ||
| "is_active": True, | ||
| } | ||
|
|
||
| @staticmethod | ||
| def get_name() -> str: | ||
| return "NVIDIA Build" | ||
|
|
||
| @staticmethod | ||
| def get_description() -> str: | ||
| return DESCRIPTION | ||
|
|
||
| @staticmethod | ||
| def get_provider() -> str: | ||
| return "nvidia_build" | ||
|
|
||
| @staticmethod | ||
| def get_icon() -> str: | ||
| return "/icons/adapter-icons/NvidiaBuild.png" | ||
|
|
||
| @staticmethod | ||
| def get_adapter_type() -> AdapterTypes: | ||
| return AdapterTypes.EMBEDDING |
49 changes: 49 additions & 0 deletions
49
unstract/sdk1/src/unstract/sdk1/adapters/embedding1/openai_compatible.py
This file contains hidden or 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,49 @@ | ||
| from typing import Any | ||
|
|
||
| from unstract.sdk1.adapters.base1 import ( | ||
| BaseAdapter, | ||
| OpenAICompatibleEmbeddingParameters, | ||
| ) | ||
| from unstract.sdk1.adapters.enums import AdapterTypes | ||
|
|
||
| DESCRIPTION = ( | ||
| "Embedding adapter for servers that implement the OpenAI Embeddings API " | ||
| "(vLLM, self-hosted gateways, and third-party providers). " | ||
| "Use OpenAI for the official OpenAI service." | ||
| ) | ||
|
|
||
|
|
||
| class OpenAICompatibleEmbeddingAdapter(OpenAICompatibleEmbeddingParameters, BaseAdapter): | ||
| @staticmethod | ||
| def get_id() -> str: | ||
| return "openaicompatible|65573de7-2ea5-4631-bb49-492717972455" | ||
|
|
||
| @staticmethod | ||
| def get_metadata() -> dict[str, Any]: | ||
| return { | ||
| "name": "OpenAI Compatible", | ||
| "version": "1.0.0", | ||
| "adapter": OpenAICompatibleEmbeddingAdapter, | ||
| "description": DESCRIPTION, | ||
| "is_active": True, | ||
| } | ||
|
|
||
| @staticmethod | ||
| def get_name() -> str: | ||
| return "OpenAI Compatible" | ||
|
|
||
| @staticmethod | ||
| def get_description() -> str: | ||
| return DESCRIPTION | ||
|
|
||
| @staticmethod | ||
| def get_provider() -> str: | ||
| return "custom_openai" | ||
|
|
||
| @staticmethod | ||
| def get_icon() -> str: | ||
| return "/icons/adapter-icons/OpenAICompatible.png" | ||
|
|
||
| @staticmethod | ||
| def get_adapter_type() -> AdapterTypes: | ||
| return AdapterTypes.EMBEDDING |
This file contains hidden or 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
53 changes: 53 additions & 0 deletions
53
unstract/sdk1/src/unstract/sdk1/adapters/embedding1/static/custom_openai.json
This file contains hidden or 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,53 @@ | ||
| { | ||
| "title": "OpenAI Compatible Embedding", | ||
| "type": "object", | ||
| "required": [ | ||
| "adapter_name", | ||
| "model", | ||
| "api_base" | ||
| ], | ||
| "properties": { | ||
| "adapter_name": { | ||
| "type": "string", | ||
| "title": "Name", | ||
| "default": "", | ||
| "description": "Provide a unique name for this adapter instance. Example: compatible-emb-1" | ||
| }, | ||
| "model": { | ||
| "type": "string", | ||
| "title": "Model", | ||
| "description": "The embedding model name expected by your OpenAI-compatible endpoint. Examples: text-embedding-3-small, BAAI/bge-m3, nomic-embed-text" | ||
| }, | ||
| "api_key": { | ||
| "type": [ | ||
| "string", | ||
| "null" | ||
| ], | ||
| "title": "API Key", | ||
| "format": "password", | ||
| "description": "API key for your OpenAI-compatible endpoint. Leave empty if the endpoint does not require one." | ||
| }, | ||
| "api_base": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "title": "API Base", | ||
| "description": "Base URL for the OpenAI-compatible embeddings endpoint. Examples: https://gateway.example.com/v1, https://llm.example.net/openai/v1" | ||
| }, | ||
| "max_retries": { | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "multipleOf": 1, | ||
| "title": "Max Retries", | ||
| "default": 3, | ||
| "description": "The maximum number of times to retry a request if it fails." | ||
| }, | ||
| "timeout": { | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "multipleOf": 1, | ||
| "title": "Timeout", | ||
| "default": 240, | ||
| "description": "Timeout in seconds" | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.