Skip to content

Conversation

@miri-bar
Copy link
Contributor

@miri-bar miri-bar commented Jun 6, 2024

No description provided.

@miri-bar miri-bar requested a review from Josephasafg June 6, 2024 11:22

return await self._client.send(request=request, stream=stream)

data = self._get_data(files=files, method=method, params=params)
Copy link
Contributor

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
Copy link
Contributor

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 :)

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()
Copy link
Contributor

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

@miri-bar miri-bar changed the base branch from rc_async_client to main June 10, 2024 14:30
@miri-bar miri-bar merged commit d1933e4 into main Jun 10, 2024
@miri-bar miri-bar deleted the async branch June 10, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants