Deprecate WorkspaceClient().serving_endpoints.get_open_ai_client() and WorkspaceClient().serving_endpoints.get_langchain_chat_open_ai_client() methods#1238
Conversation
…thods These methods are now deprecated in favor of the databricks-openai package. Users should install databricks-openai and use: - DatabricksOpenAI instead of get_open_ai_client() - AsyncDatabricksOpenAI instead of get_langchain_chat_open_ai_client() Changes: - Added DeprecationWarning to both methods with clear migration instructions - Added tests to verify deprecation warnings are raised correctly - Updated docstrings with deprecation notices Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…cks_langchain Changed the deprecation warning for get_langchain_chat_open_ai_client() to recommend ChatDatabricks from databricks_langchain instead of AsyncDatabricksOpenAI from databricks_openai, as ChatDatabricks is the proper LangChain integration for Databricks. Updated tests to verify the new deprecation message. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated both langchain tests to mock the langchain_openai module import, preventing ImportError when the package is not installed. This allows the tests to verify deprecation warnings and functionality without requiring optional dependencies. All tests now pass successfully. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document the deprecation of get_open_ai_client() and get_langchain_chat_open_ai_client() methods in NEXT_CHANGELOG.md. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| from IPython.core.display_functions import display | ||
| from ipywidgets.widgets import (ValueWidget, Widget, widget_box, | ||
| widget_selection, widget_string) | ||
| from ipywidgets.widgets import ValueWidget, Widget, widget_box, widget_selection, widget_string |
There was a problem hiding this comment.
Undo noop formatting change
databricks/sdk/errors/parser.py
Outdated
| from .deserializer import (_EmptyDeserializer, _ErrorDeserializer, | ||
| _HtmlErrorDeserializer, _StandardErrorDeserializer, | ||
| _StringErrorDeserializer) | ||
| from .deserializer import ( |
There was a problem hiding this comment.
Undo noop formatting change in this file
databricks/sdk/mixins/files.py
Outdated
| from types import TracebackType | ||
| from typing import (TYPE_CHECKING, AnyStr, BinaryIO, Callable, Generator, | ||
| Iterable, Optional, Type, Union) | ||
| from typing import TYPE_CHECKING, AnyStr, BinaryIO, Callable, Generator, Iterable, Optional, Type, Union |
There was a problem hiding this comment.
Undo noop formatting change
| from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod, | ||
| HttpRequestResponse, | ||
| ServingEndpointsAPI) | ||
| from databricks.sdk.service.serving import ExternalFunctionRequestHttpMethod, HttpRequestResponse, ServingEndpointsAPI |
There was a problem hiding this comment.
Undo this noop formatting change
9f0cf80 to
802e95c
Compare
Signed-off-by: Siddharth Murching <smurching@gmail.com>
Signed-off-by: Siddharth Murching <smurching@gmail.com>
| warnings.warn( | ||
| "get_open_ai_client() is deprecated. Please install the databricks-openai package " | ||
| "and use 'from databricks_openai import DatabricksOpenAI' instead. " | ||
| "See https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_openai.html for more information.", |
There was a problem hiding this comment.
nit: we should probably also update databricks-openai homepage to include this as the first item
currently, https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_openai.html doesn't talk about our custom client
bbqiu
left a comment
There was a problem hiding this comment.
lgtm since we're gonna address followups from https://databricks.slack.com/archives/C09PZFZQEMV/p1770055997113559?thread_ts=1770052601.029949&cid=C09PZFZQEMV
Signed-off-by: Siddharth Murching <smurching@gmail.com>
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
| .. deprecated:: | ||
| This method is deprecated. Please install the `databricks-openai` package | ||
| and use `from databricks_openai import DatabricksOpenAI` instead. | ||
| See https://pypi.org/project/databricks-openai/ for more information. |
There was a problem hiding this comment.
nit: should we link to the same thing in the warning message / docstring?
Deprecate get_open_ai_client and get_langchain_chat_open_ai_client methods
These methods are now deprecated in favor of the databricks-openai and databricks-langchain package.
Instead of
We now recommend
What changes are proposed in this pull request?
WHAT:
This PR deprecates two OpenAI client helper methods in the Databricks SDK:
ServingEndpointsExt.get_open_ai_client()ServingEndpointsExt.get_langchain_chat_open_ai_client()The changes include:
DeprecationWarningmessages that are raised when either method is called, with clear instructions to migrate to thedatabricks-openaipackage.. deprecated::directives pointing users to the new packageWHY:
These helper methods were originally added to the Databricks SDK to make it easier to use OpenAI-compatible clients with Databricks Model Serving. However,
maintaining OpenAI client integration directly in the SDK creates several issues:
changes
databricks-openai) can provide more comprehensive OpenAI compatibility features without bloating the core SDKdatabricks-openaipackage provides a more standard OpenAI-compatible interface that users familiar with the OpenAI SDK willfind more intuitive
By deprecating these methods now, we give users a clear migration path while maintaining backward compatibility. The deprecation warnings will appear in users'
logs, guiding them to adopt the better-maintained
databricks-openaipackage.How is this tested?
Unit tests:
test_get_open_ai_client_deprecation_warning()which verifies that callingget_open_ai_client()raises aDeprecationWarningwith the correctmessage pointing to
databricks-openaiandDatabricksOpenAItest_get_langchain_chat_open_ai_client_deprecation_warning()which verifies that callingget_langchain_chat_open_ai_client()raises aDeprecationWarningwith the correct message pointing toAsyncDatabricksOpenAI. This test handles both cases wherelangchain_openaiis installed and notinstalled.
Manual verification:
All new tests pass locally:
pytest tests/test_open_ai_mixin.py::test_get_open_ai_client_deprecation_warning -v # PASSED
pytest tests/test_open_ai_mixin.py::test_get_langchain_chat_open_ai_client_deprecation_warning -v # PASSED
The deprecation warnings are correctly raised in all existing tests that use these methods, confirming the warnings will be visible to end users.