openai 包运行报错TypeError: Client.__init__() got an unexpected keyword argument ‘proxies‘

TypeError: Client.init() got an unexpected keyword argument ‘proxies’

现象:

在使用openai包时出现错误 openai.OpenAI(**client_params, **sync_specific)

报错信息:

Traceback (most recent call last):
  File "/Users/greg/Documents/Work/browser-use/browser-use/examples/try.py", line 45, in <module>
    llm = get_llm(args.provider)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greg/Documents/Work/browser-use/browser-use/examples/try.py", line 28, in get_llm
    return ChatOpenAI(model='gpt-4o', temperature=0.0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/langchain_core/load/serializable.py", line 125, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/pydantic/main.py", line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/langchain_openai/chat_models/base.py", line 551, in validate_environment
    self.root_client = openai.OpenAI(**client_params, **sync_specific)  # type: ignore[arg-type]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/openai/_client.py", line 123, in __init__
    super().__init__(
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 857, in __init__
    self._client = http_client or SyncHttpxClientWrapper(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/greg/Documents/Work/browser-use/browser-use/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 755, in __init__
    super().__init__(**kwargs)
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

Python版本

python 3.8

openai版本

openai 1.9.0

原因

安装openai包时没指定httpx包版本,httpx包在11.28进行更新,安装了httpx 0.28.0 版本的包导致报错

解决方法

1、指定httpx包版本为0.27.2

pip install httpx==0.27.2

2、安装openai包>=1.55.3版本

说明:在2024.11.28httpx更新新版本后出现异常,在2024.11.29 openai发布新版本修复,参考:1.55.3版本更新说明

pip install openai>=1.55.3

参考内容

https://github.com/openai/openai-python/issues/1902

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无糖可乐·

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值