Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .codegen/_openapi_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58905570a9928fc9ed31fba14a2edaf9a7c55b08
840c660106f820a1a5dff931d51fa5f65cd9fdd9
592 changes: 268 additions & 324 deletions databricks/sdk/__init__.py

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions databricks/sdk/mixins/open_ai_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json as js
from typing import Dict, Optional

from requests import Response

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


Expand Down Expand Up @@ -63,7 +64,7 @@ def http_request(self,
*,
headers: Optional[Dict[str, str]] = None,
json: Optional[Dict[str, str]] = None,
params: Optional[Dict[str, str]] = None) -> ExternalFunctionResponse:
params: Optional[Dict[str, str]] = None) -> Response:
"""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
Expand All @@ -79,13 +80,27 @@ def http_request(self,
JSON payload for the request.
:param params: Dict[str,str] (optional)
Query parameters for the request.
:returns: :class:`ExternalFunctionResponse`
:returns: :class:`Response`
"""
response = Response()
response.status_code = 200
server_response = super().http_request(connection_name=conn,
method=method,
path=path,
headers=js.dumps(headers) if headers is not None else None,
json=js.dumps(json) if json is not None else None,
params=js.dumps(params) if params is not None else None)

# Read the content from the HttpRequestResponse object
if hasattr(server_response, "contents") and hasattr(server_response.contents, "read"):
raw_content = server_response.contents.read() # Read the bytes
else:
raise ValueError("Invalid response from the server.")

# Set the raw content
if isinstance(raw_content, bytes):
response._content = raw_content
else:
raise ValueError("Contents must be bytes.")

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