Skip to content

Commit 12cece5

Browse files
Add model serving mixin
1 parent cc6d73d commit 12cece5

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

databricks/sdk/mixins/open_ai_client.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from databricks.sdk.service.serving import ServingEndpointsAPI
1+
import json as js
2+
from typing import Dict, Optional
3+
4+
from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod,
5+
ExternalFunctionResponse,
6+
ServingEndpointsAPI)
27

38

49
class ServingEndpointsExt(ServingEndpointsAPI):
@@ -50,3 +55,37 @@ def get_langchain_chat_open_ai_client(self, model):
5055
openai_api_base=self._api._cfg.host + "/serving-endpoints",
5156
api_key="no-token", # Passing in a placeholder to pass validations, this will not be used
5257
http_client=self._get_authorized_http_client())
58+
59+
def http_request(self,
60+
conn: str,
61+
method: ExternalFunctionRequestHttpMethod,
62+
path: str,
63+
*,
64+
headers: Optional[Dict[str, str]] = None,
65+
json: Optional[Dict[str, str]] = None,
66+
params: Optional[Dict[str, str]] = None) -> ExternalFunctionResponse:
67+
"""Make external services call using the credentials stored in UC Connection.
68+
**NOTE:** Experimental: This API may change or be removed in a future release without warning.
69+
:param conn: str
70+
The connection name to use. This is required to identify the external connection.
71+
:param method: :class:`ExternalFunctionRequestHttpMethod`
72+
The HTTP method to use (e.g., 'GET', 'POST'). This is required.
73+
:param path: str
74+
The relative path for the API endpoint. This is required.
75+
:param headers: Dict[str,str] (optional)
76+
Additional headers for the request. If not provided, only auth headers from connections would be
77+
passed.
78+
:param json: Dict[str,str] (optional)
79+
JSON payload for the request.
80+
:param params: Dict[str,str] (optional)
81+
Query parameters for the request.
82+
:returns: :class:`ExternalFunctionResponse`
83+
"""
84+
85+
return super.http_request(connection_name=conn,
86+
method=method,
87+
path=path,
88+
headers=js.dumps(headers),
89+
json=js.dumps(json),
90+
params=js.dumps(params),
91+
)

0 commit comments

Comments
 (0)