-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add support for studio async client #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| return await self._client.send(request=request, stream=stream) | ||
|
|
||
| data = self._get_data(files=files, method=method, params=params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also mutates the headers which is weird and un-expectable don't you think?
| @@ -0,0 +1,6 @@ | |||
| CHAT_DEFAULT_NUM_RESULTS = 1 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since its under the studio package, no need to call the file studio_constants.py - constants.py should suffice :)
ai21/http_client/base_http_client.py
Outdated
| return json.dumps(body).encode() if body else None | ||
|
|
||
| def _get_request_headers(self, files: Optional[Dict[str, BinaryIO]]) -> Dict[str, Any]: | ||
| headers = self._headers.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mutating the dict, a better way to do this is to create a new header object. Something like -
def _get_request_headers(self, files: Optional[Dict[str, BinaryIO]]) -> Dict[str, Any]:
if files is not None and "Content-Type" in self._headers:
return {key: value for key, value in self._headers.items() if key != "Content-Type"}
return self._headers
No description provided.