QwenLM / Qwen

The official repo of Qwen (通义千问) chat & pretrained large language model proposed by Alibaba Cloud.
Apache License 2.0
13.59k stars 1.11k forks source link

[BUG] Function Calling 示例有错误,最新的 openai sdk 运行时提示 api 已经废弃 #1234

Closed henryyan closed 5 months ago

henryyan commented 5 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

Traceback (most recent call last):
  File "/xxxx/c1-func-call/qwen-func-call.py", line 244, in <module>
    test_1()
  File "/xxxx/c1-func-call/qwen-func-call.py", line 40, in test_1
    call_qwen(messages)
  File "/xxxx/c1-func-call/qwen-func-call.py", line 27, in call_qwen
    response = openai.ChatCompletion.create(model='Qwen',
  File "/Users/xxx/llm/abcd/.venv/lib/python3.9/site-packages/openai/lib/_old_api.py", line 39, in __call__
    raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1: 

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

期望行为 | Expected Behavior

使用官方最新的方式重写 function 调用prompt:https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models#basic-concepts

复现方法 | Steps To Reproduce

执行示例:https://github.com/QwenLM/Qwen/blob/main/examples/function_call_examples.py

运行环境 | Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA (`python -c 'import torch; print(torch.version.cuda)'`):

备注 | Anything else?

No response

jklj077 commented 5 months ago

Hi! As stated in README, you need "openai<1.0" to run with this project. Please also note that this project will not receive major functional updates anymore. You could try to migrate to Qwen1.5.

WangJianQ-cmd commented 4 months ago

感觉是用的是老的openai调用方法,换成1.0以上的openai调用方法就可以了