Skip to content

Commit 083c202

Browse files
pieternsunishsheth2009
authored andcommitted
Adding http_request to serving to call external-function
Signed-off-by: Sunish Sheth <[email protected]>
1 parent 6d6923e commit 083c202

File tree

2 files changed

+206
-5
lines changed

2 files changed

+206
-5
lines changed

databricks/sdk/mixins/open_ai_client.py

Lines changed: 44 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 (ExternalFunctionRequestMethod,
5+
ExternalFunctionResponse,
6+
ServingEndpointsAPI)
27

38

49
class ServingEndpointsExt(ServingEndpointsAPI):
@@ -50,3 +55,41 @@ 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: ExternalFunctionRequestMethod,
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+
69+
**NOTE:** Experimental: This API may change or be removed in a future release without warning.
70+
71+
:param conn: str
72+
The connection name to use. This is required to identify the external connection.
73+
:param method: :class:`ExternalFunctionRequestMethod`
74+
The HTTP method to use (e.g., 'GET', 'POST'). This is required.
75+
:param path: str
76+
The relative path for the API endpoint. This is required.
77+
:param headers: Dict[str,str] (optional)
78+
Additional headers for the request. If not provided, only auth headers from connections would be
79+
passed.
80+
:param json: Dict[str,str] (optional)
81+
JSON payload for the request.
82+
:param params: Dict[str,str] (optional)
83+
Query parameters for the request.
84+
85+
:returns: :class:`ExternalFunctionResponse`
86+
"""
87+
88+
return super.http_request(
89+
connection_name=conn,
90+
method=method,
91+
path=path,
92+
headers=headers,
93+
json=js.dumps(json),
94+
params=js.dumps(params),
95+
)

databricks/sdk/service/serving.py

Lines changed: 162 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)