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

Anthropic: TypeError: Client.__init__() got an unexpected keyword argument 'proxies' #102

Closed
moyefuse opened this issue Dec 9, 2024 · 4 comments

Comments

@moyefuse
Copy link

moyefuse commented Dec 9, 2024

Environment

> python --version                                                     
Python 3.11.9

> pip list --format freeze
anthropic==0.39.0
anyio==4.7.0
attrs==24.2.0
black==24.10.0
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
cohere==5.11.4
distro==1.9.0
fastavro==1.9.7
filelock==3.16.1
fsspec==2024.10.0
google-ai-generativelanguage==0.6.6
google-api-core==2.23.0
google-api-python-client==2.154.0
google-auth==2.36.0
google-auth-httplib2==0.2.0
google-generativeai==0.7.2
googleapis-common-protos==1.66.0
gpt-command-line==0.3.0
grpcio==1.68.1
grpcio-status==1.62.3
h11==0.14.0
httpcore==1.0.7
httplib2==0.22.0
httpx==0.28.1
httpx-sse==0.4.0
huggingface-hub==0.26.5
idna==3.10
iniconfig==2.0.0
jiter==0.8.0
markdown-it-py==3.0.0
mdurl==0.1.2
mypy-extensions==1.0.0
openai==1.54.5
packaging==24.2
parameterized==0.9.0
pathspec==0.12.1
pip==24.0
platformdirs==4.3.6
pluggy==1.5.0
prompt_toolkit==3.0.48
proto-plus==1.25.0
protobuf==4.25.5
pyasn1==0.6.1
pyasn1_modules==0.4.1
pydantic==1.10.19
pydantic_core==2.27.1
Pygments==2.18.0
pyparsing==3.2.0
pytest==8.3.4
PyYAML==6.0.2
requests==2.32.3
rich==13.9.4
rsa==4.9
setuptools==69.5.1
sniffio==1.3.1
tokenizers==0.21.0
tqdm==4.67.1
types-requests==2.32.0.20241016
typing_extensions==4.12.2
uritemplate==4.1.1
urllib3==2.2.3
wcwidth==0.2.13
wheel==0.43.0

~/.config/gpt-cli/gpt.yaml

default_assistant: claude
markdown: True
anthropic_api_key: <<REDACTED>>
assistants:
  claude:
    model: claude-3-haiku-20240307
    temperature: 1.0
    messages:
      - role: system
        content: "Please provide brief responses unless explicitly asked for elaboration on a topic."

  sonnet:
    model: claude-3-5-sonnet-20240620
    temperature: 1.0
    messages:
      - role: system
        content: "Please provide brief responses unless explicitly asked for elaboration on a topic."

  dev:
    model: claude-3-5-sonnet-20240620
    temperature: 1.0
    messages:
      - role: system
        content: "You are a software engineering expert. Your job is to respond accurately and thoughtfully, but succinctly."

  meta:
    model: claude-3-5-sonnet-20240620
    temperature: 1.0
    messages:
      - role: system
        content: "You are a propmt engineering expert. Your job is to provide the best prompt to achieve the requested goal if asked to an LLM."

  crazy:
    model: claude-3-5-sonnet-20240620
    temperature: 1.0
    messages:
      - role: system
        content: "You are mostly normal but a little weird. You respond to the question answered in a thoughtful but quirky way."

Traceback

TypeError: Client.__init__() got an unexpected keyword argument 'proxies'
An uncaught exception occurred. Please report this issue on GitHub.
Traceback (most recent call last):
  File "/Users/moye/Code/gpt-cli/.venv/bin/gpt", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/moye/Code/gpt-cli/gptcli/gpt.py", line 206, in main
    run_interactive(args, assistant)
  File "/Users/moye/Code/gpt-cli/gptcli/gpt.py", line 254, in run_interactive
    session.loop(input_provider)
  File "/Users/moye/Code/gpt-cli/gptcli/session.py", line 180, in loop
    while self.process_input(input_provider.get_user_input()):
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/moye/Code/gpt-cli/gptcli/session.py", line 172, in process_input
    response_saved = self._respond()
                     ^^^^^^^^^^^^^^^
  File "/Users/moye/Code/gpt-cli/gptcli/session.py", line 117, in _respond
    for event in completion_iter:
  File "/Users/moye/Code/gpt-cli/gptcli/providers/anthropic.py", line 47, in complete
    client = get_client()
             ^^^^^^^^^^^^
  File "/Users/moye/Code/gpt-cli/gptcli/providers/anthropic.py", line 23, in get_client
    return anthropic.Anthropic(api_key=api_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/moye/Code/gpt-cli/.venv/lib/python3.11/site-packages/anthropic/_client.py", line 117, in __init__
    super().__init__(
  File "/Users/moye/Code/gpt-cli/.venv/lib/python3.11/site-packages/anthropic/_base_client.py", line 856, in __init__
    self._client = http_client or SyncHttpxClientWrapper(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/moye/Code/gpt-cli/.venv/lib/python3.11/site-packages/anthropic/_base_client.py", line 754, in __init__
    super().__init__(**kwargs)
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'
@jkovacevic
Copy link

I have the same error - I am unable to use the library. I downgraded openai to 1.54.4, but same error occurs.

@jwickers
Copy link

Same, as a workaround I just commented out the proxies= in openai/_base_client.py in the method self._client = http_client or SyncHttpxClientWrapper(.... around line 857

@vsevolod-oparin
Copy link

vsevolod-oparin commented Jan 21, 2025

I managed to fix it with downgrading httpx and upgrading openai. Not sure, if it won't break anything else, but here is my recipe.

git clone https://github.com/kharvd/gpt-cli.git
cd gpt-cli

Update dependencies in pyproject.toml

dependencies = [
    "anthropic~=0.39.0",
    "attrs~=24.2.0",
    "black~=24.10.0",
    "cohere~=5.11.4",
    "httpx~=0.27.2",
    "google-generativeai==0.7.2",
    "openai~=1.56.1",
    "prompt-toolkit~=3.0.48",
    "pytest~=8.3.3",
    "PyYAML~=6.0.2",
    "rich~=13.9.4",
    "typing_extensions~=4.12.2",
    "pydantic<2",
]

Install the package from repo:

pip install .

Also, see the problem with OpenAI client: https://community.openai.com/t/error-with-openai-1-56-0-client-init-got-an-unexpected-keyword-argument-proxies/1040332/8

@kharvd
Copy link
Owner

kharvd commented Jan 23, 2025

upgraded openai (and other deps) 0cf6a34. let me know if this is still an issue

@kharvd kharvd closed this as completed Jan 23, 2025
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

5 participants