Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion databricks/sdk/mixins/open_ai_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from databricks.sdk.service.serving import ServingEndpointsAPI
import json as js
from typing import Dict, Optional

from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod,
ExternalFunctionResponse,
ServingEndpointsAPI)


class ServingEndpointsExt(ServingEndpointsAPI):
Expand Down Expand Up @@ -50,3 +55,40 @@ def get_langchain_chat_open_ai_client(self, model):
openai_api_base=self._api._cfg.host + "/serving-endpoints",
api_key="no-token", # Passing in a placeholder to pass validations, this will not be used
http_client=self._get_authorized_http_client())

def http_request(self,
conn: str,
method: ExternalFunctionRequestHttpMethod,
path: str,
*,
headers: Optional[Dict[str, str]] = None,
json: Optional[Dict[str, str]] = None,
params: Optional[Dict[str, str]] = None) -> ExternalFunctionResponse:
"""Make external services call using the credentials stored in UC Connection.

**NOTE:** Experimental: This API may change or be removed in a future release without warning.

:param conn: str
The connection name to use. This is required to identify the external connection.
:param method: :class:`ExternalFunctionRequestHttpMethod`
The HTTP method to use (e.g., 'GET', 'POST'). This is required.
:param path: str
The relative path for the API endpoint. This is required.
:param headers: Dict[str,str] (optional)
Additional headers for the request. If not provided, only auth headers from connections would be
passed.
:param json: Dict[str,str] (optional)
JSON payload for the request.
:param params: Dict[str,str] (optional)
Query parameters for the request.

:returns: :class:`ExternalFunctionResponse`
"""

return super.http_request(connection_name=conn,
method=method,
path=path,
headers=js.dumps(headers),
json=js.dumps(json),
params=js.dumps(params),
)
Loading
Loading