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

Error: Client.__init__() got an unexpected keyword argument 'proxies' #709

Closed
simonw opened this issue Jan 18, 2025 · 8 comments
Closed
Labels
bug Something isn't working ci GitHub Actions failures

Comments

@simonw
Copy link
Owner

simonw commented Jan 18, 2025

Getting this error from the test suite, but only if I upgrade httpx to 0.28.1.

Error: Client.__init__() got an unexpected keyword argument 'proxies'

@simonw simonw added the bug Something isn't working label Jan 18, 2025
@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

https://github.com/encode/httpx/releases/tag/0.28.0 says:

The deprecated proxies argument has now been removed.

I'm not using that myself, maybe the test framework is? pytest-httpx

Upgrading to pytest-httpx==0.35.0 (the latest version) did not fix the error, despite that version promising compatibility with httpx==0.28.0:

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

This is hard to debug because the exception is being swallowed somewhere and turned into a system exit.

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

This change helps with debugging:

diff --git a/llm/cli.py b/llm/cli.py
index 86954ab..b577b9b 100644
--- a/llm/cli.py
+++ b/llm/cli.py
@@ -450,7 +450,12 @@ def prompt(
                 if extract:
                     text = extract_first_fenced_code_block(text) or text
                 print(text)
+    except ValueError as ex:
+        raise click.ClickException(str(ex))
     except Exception as ex:
+        # Other exceptions should raise in pytest
+        if getattr(sys, "_called_from_test", False):
+            raise
         raise click.ClickException(str(ex))
 
     if isinstance(response, AsyncResponse):

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

Got me this traceback, maybe the problem is in the openai client library?

self = <openai._base_client.SyncHttpxClientWrapper object at 0x122765d20>, kwargs = {'base_url': 'https://api.openai.com/v1', 'follow_redirects': True, 'limits': Limits(max_connections=1000, max_keepalive_connections=100, keepalive_expiry=5.0), 'proxies': None, ...}

    def __init__(self, **kwargs: Any) -> None:
        kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
        kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
        kwargs.setdefault("follow_redirects", True)
>       super().__init__(**kwargs)
E       TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

I upgraded my local environment from openai==1.37.0 to openai==1.59.8 and now all but one of the tests pass - it definitely fixed this problem.

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

... that other test failure was because of my new debugging code. The solution here is to upgrade openai.

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

Here's where OpenAI fixed this problem:

@simonw
Copy link
Owner Author

simonw commented Jan 18, 2025

And they shipped the release here:

So depending on openai>=1.55.3 will fix the problem.

simonw added a commit that referenced this issue Jan 18, 2025
@simonw simonw closed this as completed Jan 18, 2025
@simonw simonw added the ci GitHub Actions failures label Jan 18, 2025
simonw added a commit that referenced this issue Jan 18, 2025
Found this pattern while working on #709
simonw added a commit that referenced this issue Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci GitHub Actions failures
Projects
None yet
Development

No branches or pull requests

1 participant