Skip to content

Commit dc9d228

Browse files
Adding the missing super() for open_ai_client
Signed-off-by: Sunish Sheth <[email protected]>
1 parent ee136e2 commit dc9d228

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

databricks/sdk/mixins/open_ai_client.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import json as js
22
from typing import Dict, Optional
33

4+
from dataclasses import dataclass
45
from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod,
5-
ExternalFunctionResponse,
6+
ExternalFunctionResponse as ExternalFunctionResponseAPI,
67
ServingEndpointsAPI)
78

89

10+
@dataclass
11+
class ExternalFunctionResponse(ExternalFunctionResponseAPI):
12+
text: Dict[str, any] = None
13+
"""The content of the response"""
14+
15+
@classmethod
16+
def from_dict(cls, d: Dict[str, any]) -> 'ExternalFunctionResponse':
17+
"""Deserializes the ExternalFunctionResponse from a dictionary."""
18+
return cls(status_code=200, text=d)
19+
20+
921
class ServingEndpointsExt(ServingEndpointsAPI):
1022

1123
# Using the HTTP Client to pass in the databricks authorization
@@ -82,10 +94,14 @@ def http_request(self,
8294
:returns: :class:`ExternalFunctionResponse`
8395
"""
8496

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-
)
97+
body = {}
98+
if conn is not None: body['connection_name'] = conn
99+
if headers is not None: body['headers'] = js.dumps(headers)
100+
if json is not None: body['json'] = js.dumps(json)
101+
if method is not None: body['method'] = method.value
102+
if params is not None: body['params'] = js.dumps(params)
103+
if path is not None: body['path'] = path
104+
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
105+
106+
res = self._api.do('POST', '/api/2.0/external-function', body=body, headers=headers)
107+
return ExternalFunctionResponse.from_dict(res)

0 commit comments

Comments
 (0)