Skip to content
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

Kwargs of API client do not pass down correctly #28

Closed
bkiat1123 opened this issue Apr 30, 2023 · 2 comments
Closed

Kwargs of API client do not pass down correctly #28

bkiat1123 opened this issue Apr 30, 2023 · 2 comments

Comments

@bkiat1123
Copy link

Currently, kwargs are passed down as params, hence headers and request_timeout cannot be set.

Relevant code snippet.

def completion(self, **kwargs) -> dict:
        return self._request_as_json(
            "post",
            "/v1/complete",
            params=kwargs,
        )
	...

def _request_raw(
        self,
        method: str,
        path: str,
        params: dict,
        headers: Optional[Dict[str, str]] = None,
        request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
    ) -> requests.Response:
	...

As shown above, if users set headers or requesst_timeout in completion method, it will be pass down as params. Headers and request_timeout will remain None.

It can be handled like below instead.

def completion(self, **kwargs) -> dict:
        return self._request_as_json(
            "post",
            "/v1/complete",
            **kwargs,
        )

def _request_raw(
        self,
        method: str,
        path: str,
        headers: Optional[Dict[str, str]] = None,
        request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
        **params: dict,

    ) -> requests.Response:
@chitalian
Copy link

Trying to fix this here:

#39

@jenan-anthropic
Copy link
Contributor

We've just released an entirely new version of the SDK, which should address this. Please take a look!

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

No branches or pull requests

3 participants