Skip to content

Commit ee3b922

Browse files
Adding the missing super() for open_ai_client
Signed-off-by: Sunish Sheth <sunishsheth2009@gmail.com>
1 parent ee136e2 commit ee3b922

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

databricks/sdk/mixins/open_ai_client.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import json as js
2+
from dataclasses import dataclass
23
from typing import Dict, Optional
34

4-
from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod,
5-
ExternalFunctionResponse,
6-
ServingEndpointsAPI)
5+
from databricks.sdk.service.serving import ExternalFunctionRequestHttpMethod
6+
from databricks.sdk.service.serving import \
7+
ExternalFunctionResponse as ExternalFunctionResponseAPI
8+
from databricks.sdk.service.serving import ServingEndpointsAPI
9+
10+
11+
@dataclass
12+
class ExternalFunctionResponse(ExternalFunctionResponseAPI):
13+
text: Dict[str, any] = None
14+
"""The content of the response"""
15+
16+
@classmethod
17+
def from_dict(cls, d: Dict[str, any]) -> 'ExternalFunctionResponse':
18+
"""Deserializes the ExternalFunctionResponse from a dictionary."""
19+
return cls(status_code=200, text=d)
720

821

922
class ServingEndpointsExt(ServingEndpointsAPI):
@@ -82,10 +95,14 @@ def http_request(self,
8295
:returns: :class:`ExternalFunctionResponse`
8396
"""
8497

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

0 commit comments

Comments
 (0)