feat(models): support Databricks-hosted models#2464
Conversation
Wire Databricks PAT/key authentication into the LiteLLM handler so models served from Databricks (e.g. Azure Databricks serving endpoints) can be used as the PR-Agent model. DATABRICKS.API_KEY / DATABRICKS.API_BASE settings are exported to the DATABRICKS_API_KEY / DATABRICKS_API_BASE env vars that LiteLLM's Databricks provider reads. - Add provider block to LiteLLMAIHandler.__init__ - Add [databricks] section to .secrets_template.toml - Document usage in changing_a_model.md - Add unit tests for the provider wiring Closes #2246
PR Summary by QodoAdd Databricks-hosted model support via LiteLLM env-var credentials Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
This comment was marked as spam.
This comment was marked as spam.
Address AI review on #2464: - chat_completion no longer injects litellm.api_key for databricks/* models, so another provider's key can't override DATABRICKS_API_KEY env-var auth in multi-provider configs. - consolidate test_litellm_databricks_provider.py to a single import style (CodeQL: module imported with both 'import' and 'import from'). - add regression test covering the databricks key guard.
|
Code review by qodo was updated up to the latest commit 51be212 |
Address AI review on #2464: chat_completion always forwarded api_base=self.api_base, which another provider (OpenRouter/Ollama/Azure AD/OpenAI) may have set during __init__. For databricks/* models this could route requests to the wrong host and override DATABRICKS_API_BASE. Now uses the Databricks endpoint (env var, or None so LiteLLM reads it) for those models. Adds a regression test.
|
Code review by qodo was updated up to the latest commit 173df5a |
This comment was marked as spam.
This comment was marked as spam.
3 similar comments
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
When Azure is enabled in a multi-provider config (OPENAI.API_TYPE=azure or
AZURE_AD), chat_completion() prepended 'azure/' to every model. For a
databricks/* model that rewrote the prefix to 'azure/databricks/...', so the
subsequent startswith('databricks/') guards never triggered: the call could be
routed to Azure with a foreign api_key/api_base.
Compute is_databricks once before any rewriting, skip the azure/ prefix for
Databricks models, and reuse the flag for both the api_base selection and the
api_key forwarding guard. Adds a regression test.
|
Code review by qodo was updated up to the latest commit b74e88f |
…kage LiteLLMAIHandler.__init__ sets the global litellm.api_key to the dummy fallback when OPENAI_API_KEY is absent (as it is under this file's autouse fixture). Each LiteLLMAIHandler() instantiation in these tests therefore mutated litellm.api_key and never restored it, which could leak into and flake order-dependent later tests. Snapshot litellm.api_key in the autouse fixture and restore it on teardown, matching the cross-test-pollution handling the api_key guard tests already do.
Fixed in d590363. The autouse |
|
Code review by qodo was updated up to the latest commit d590363 |
What
Adds support for using models hosted on Databricks (including Azure Databricks serving endpoints) as the PR-Agent model, via LiteLLM's Databricks provider with PAT/key authentication.
Closes #2246.
Why
LiteLLM already supports Databricks with key auth, but PR-Agent never wired the credentials through, so users with a self-managed (Azure) Databricks instance couldn't point PR-Agent at their existing endpoint.
How
DATABRICKS.API_KEY/DATABRICKS.API_BASEsettings are exported to theDATABRICKS_API_KEY/DATABRICKS_API_BASEenvironment variables that LiteLLM's Databricks provider reads. This mirrors the existing env-var provider pattern (DeepSeek, Mistral, Codestral) and is provider-scoped, so it doesn't affect the globalapi_baseused by other providers.Usage
The name after
databricks/is your serving endpoint name.Changes
LiteLLMAIHandler.__init__: export Databricks credentials to LiteLLM's env vars.secrets_template.toml: add[databricks]sectiondocs/.../changing_a_model.md: add a Databricks sectionNotes