Add Databricks provider#15
Open
blairj09 wants to merge 2 commits into
Open
Conversation
…covery + OpenAI-compatible chat Ported from posit-dev/ai-provider-bridge feature/databricks-provider and adapted to the ai-lib monorepo split: - ai-provider-bridge: databricks provider (gateway probe with per-host caching, serving-endpoints and foundation-models discovery, chat URL rewriting), capability inference helpers, PROVIDER_IDS/PROVIDER_MAP/ registrar entries - ai-credentials: normalizeDatabricksHost, CredentialConfig.getDatabricks + apikey shaping branch, vscode credential config reader, DATABRICKS_TOKEN env mapping - ai-config: databricks built-in provider id + client kind (shape guard), DATABRICKS_HOST connection env mapping, authentication.databricks host fragment read kind
…, not baseUrl
Per-model endpoint resolution falls back to the provider baseUrl, so putting
the workspace host there routed chat requests to https://<host>/chat/completions
(bypassing the serving-endpoints path and the AI Gateway rewrite) and returned
404. Follow the snowflake pattern instead: a strict databricks: { host } section
on the databricks provider block, folded in from
authentication.databricks.credentials and the DATABRICKS_HOST env var, and read
by consumers via connection.databricks.host. Also update the hard-coded
built-in provider counts in ai-config tests (14 -> 15).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds Databricks as a built-in provider across all three packages, giving Posit Assistant access to models on Databricks Model Serving (foundation models, external models, and custom serving endpoints).
Part of posit-dev/assistant#1110.
ai-provider-bridge
providers/databricks-provider.ts— model discovery and chat:GET /api/2.0/serving-endpoints(READY +llm/v1/chat, including external-model entities). When the workspace has Unity AI Gateway enabled, discovery switches toGET /api/2.0/serving-endpoints:foundation-models, filtered to gateway-v2 chat-capable models./api/ai-gateway/v2/endpointsis cached per workspace host (definitive 200/404/403 results only; transient failures fall back to model serving without poisoning the cache). The cache is shared between discovery and chat so both route consistently, and clears with the model cache.OpenAIClientagainst{host}/serving-endpoints, with a fetch wrapper that rewrites requests to{host}/ai-gateway/mlflow/v1when the gateway is available. Credentials are bearer-tokenapikeycredentials (PAT or OAuth access token — the host application decides which) with the workspace host asbaseUrl.model-capabilities/databricks-helpers.ts— capability inference from the underlying model identity (foundation-model / external-model / endpoint name), reusing the Anthropic and OpenAI helpers after strippingdatabricks-/system.ai.prefixes. Thinking-effort levels are deliberately dropped for v1; unrecognized models get conservative defaults.PROVIDER_IDS,PROVIDER_MAP(auth providerdatabricks, apikey),PROVIDER_REGISTRARS, and the public exports.customHeadersare supported on both discovery (additive) and chat paths.ai-credentials
CredentialConfig.getDatabricks()+ a Databricks branch inshapeCredentialsthat resolves the workspace host into the credentialbaseUrlvia a newnormalizeDatabricksHosthelper (accepts scheme-less hosts and trailing slashes).authentication.databricks.credentials.DATABRICKS_HOSTwith aprocess.env.DATABRICKS_HOSTfallback for managed environments (e.g. Posit Workbench injecting it into sessions).DATABRICKS_TOKENadded to the secret env mappings (store-backend).ai-config
databricksadded toBUILTIN_PROVIDER_IDSandCLIENT_KIND_VALUES(identity mapping; not offered as a custom-provider type), keeping the cross-package shape guard green.databricks: { host }connection section — notbaseUrl. Per-model endpoint resolution falls back to the providerbaseUrl, so storing the host there routed chat tohttps://<host>/chat/completions(404) and bypassed the gateway rewrite; the section keeps the host available to the credential shaper without entering endpoint resolution. This mirrors how Snowflake stores host/account.authentication.*host fragment gains a"databricks"read kind (host + customHeaders → thedatabrickssection), and theDATABRICKS_HOSTenv var overlays the section in the catalog builder.Testing
npm run build,check-types(including the shape guard),test,lint, andformat:checkall pass.Merge ordering
This PR should land before posit-dev/assistant#1809, whose
packages/ai-libsubmodule pin references this branch.