-
Notifications
You must be signed in to change notification settings - Fork 65
refactor: Decouple ModelFacade from LiteLLM via ModelClient adapter #373
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
49 commits
Select commit
Hold shift + click to select a range
ab30a2d
plans for model facade overhaul
nabinchha 43824ea
update plan
nabinchha 2a5f1e4
add review
johnnygreco f945d5b
address feedback + add more details after several self reviews
nabinchha dfa3817
update plan doc
nabinchha 5b18f74
Merge branch 'main' into nm/overhaul-model-facade-guts
nabinchha 0f449a7
address nits
nabinchha 37f092a
Merge branch 'nm/overhaul-model-facade-guts' into nm/overhaul-model-fβ¦
nabinchha 08e57f8
Add cannonical objects
nabinchha 3ab18ee
Merge branch 'main' into nm/overhaul-model-facade-guts-pr1
nabinchha 34349c7
self-review feedback + address
nabinchha 6aae4b6
add LiteLLMRouter protocol to strongly type bridge router param
nabinchha 2a53d37
simplify some things
nabinchha 4e2f3af
add a protol for http response like object
nabinchha b1c85f2
move HttpResponse
nabinchha f6dc769
update PR-1 architecture notes for lifecycle and router protocol
nabinchha ec5ed9b
Address PR #359 feedback: exception wrapping, shared parsing, test imβ¦
nabinchha b6b4028
Merge branch 'main' into nm/overhaul-model-facade-guts-pr1
nabinchha ba22397
Use contextlib to dry out some code
nabinchha aeac3b9
Address Greptile feedback: HTTP-date retry-after parsing, docstring cβ¦
nabinchha 55f3c96
Address Greptile feedback: FastAPI detail parsing, comment fixes
nabinchha c390912
Merge branch 'main' into nm/overhaul-model-facade-guts-pr1
nabinchha 828cc49
add PR-2 architecture notes for model facade overhaul
nabinchha 89a6d4e
save progress on pr2
nabinchha e527503
Merge branch 'main' into nm/overhaul-model-facade-guts-pr1
nabinchha f6fa447
Merge branch 'nm/overhaul-model-facade-guts-pr1' into nm/overhaul-modβ¦
nabinchha b8579c2
small refactor
nabinchha 61024c0
address feedback
nabinchha d47d508
Merge branch 'nm/overhaul-model-facade-guts-pr1' into nm/overhaul-modβ¦
nabinchha 49a45ba
Address greptile comment in pr1
nabinchha e8445cc
refactor ProviderError from dataclass to regular Exception
nabinchha 8a385ff
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha 521c1e4
Address greptile feedback
nabinchha a831d24
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha 4836e03
PR feedback
nabinchha ae1bf98
track usage tracking in finally block for images
nabinchha 18b9966
pr feedback
nabinchha 25650b0
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha 651813b
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha bfed5af
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha c9d6f4c
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha a084038
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha 632c7c6
wrap facade close in try/catch
nabinchha 40c05ae
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha c1d807c
clean up stray params
nabinchha 879b941
fix stray inclusion of metadata
nabinchha dcbbcba
small regression fix
nabinchha 462810c
address more feedback
nabinchha ac02f2c
Merge branch 'main' into nm/overhaul-model-facade-guts-pr2
nabinchha 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
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
288 changes: 59 additions & 229 deletions
288
packages/data-designer-engine/src/data_designer/engine/mcp/facade.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
50 changes: 50 additions & 0 deletions
50
packages/data-designer-engine/src/data_designer/engine/models/clients/factory.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,50 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import data_designer.lazy_heavy_imports as lazy | ||
| from data_designer.config.models import ModelConfig | ||
| from data_designer.engine.model_provider import ModelProviderRegistry | ||
| from data_designer.engine.models.clients.adapters.litellm_bridge import LiteLLMBridgeClient | ||
| from data_designer.engine.models.clients.base import ModelClient | ||
| from data_designer.engine.models.litellm_overrides import CustomRouter, LiteLLMRouterDefaultKwargs | ||
| from data_designer.engine.secret_resolver import SecretResolver | ||
|
|
||
|
|
||
| def create_model_client( | ||
| model_config: ModelConfig, | ||
| secret_resolver: SecretResolver, | ||
| model_provider_registry: ModelProviderRegistry, | ||
| ) -> ModelClient: | ||
| """Create a ModelClient for the given model configuration. | ||
|
|
||
| Resolves the provider, API key, and constructs a LiteLLM router wrapped in | ||
| a LiteLLMBridgeClient adapter. | ||
|
|
||
| Args: | ||
| model_config: The model configuration to create a client for. | ||
| secret_resolver: Resolver for secrets referenced in provider configs. | ||
| model_provider_registry: Registry of model provider configurations. | ||
|
|
||
| Returns: | ||
| A ModelClient instance ready for use. | ||
| """ | ||
| provider = model_provider_registry.get_provider(model_config.provider) | ||
| api_key = None | ||
| if provider.api_key: | ||
| api_key = secret_resolver.resolve(provider.api_key) | ||
| api_key = api_key or "not-used-but-required" | ||
|
|
||
| litellm_params = lazy.litellm.LiteLLM_Params( | ||
| model=f"{provider.provider_type}/{model_config.model}", | ||
| api_base=provider.endpoint, | ||
| api_key=api_key, | ||
| max_parallel_requests=model_config.inference_parameters.max_parallel_requests, | ||
| ) | ||
| deployment = { | ||
| "model_name": model_config.model, | ||
| "litellm_params": litellm_params.model_dump(), | ||
| } | ||
| router = CustomRouter([deployment], **LiteLLMRouterDefaultKwargs().model_dump()) | ||
| return LiteLLMBridgeClient(provider_name=provider.name, router=router) |
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.