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

opem_ai方式启动传递get_current_weather function call,如何在open_ai.py内部调用到get_current_weather方法,这个方法如何定义有什么要求吗?请提供例子说明,网上找不到实例 #1137

Closed Andy1018 closed 5 months ago

Andy1018 commented 6 months ago

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

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

当前行为 | Current Behavior

No response

期望行为 | Expected Behavior

No response

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

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

备注 | Anything else?

opem_ai方式启动传递get_current_weather function call,如何在open_ai.py内部调用到get_current_weather方法,这个方法如何定义有什么要求吗?请提供例子说明,网上找不到实例

JianxinMa commented 6 months ago

function calling的使用方式是参考openai官方的设计的,按这个设计,open_ai.py内部并不能调用get_current_weather方法,这个方法需要由用户自己调用。例子:https://github.com/QwenLM/Qwen-Agent/blob/main/examples/function_calling.py

但如果您是想要类似 assistant api 或 langchain 的接口,让框架也把get_current_weather这个方法帮忙调用了,那可以参考 https://github.com/QwenLM/Qwen-Agent 的 README 或 examples 目录(注意该项目目前默认要求 qwen1.5,不再为 qwen1 维护了)。

Andy1018 commented 6 months ago

非常感谢你的回答,也就是说不能像chatglm3 @register_tool那样自定义工具是吧?

JianxinMa commented 6 months ago

非常感谢你的回答,也就是说不能像chatglm3 @register_tool那样自定义工具是吧?

可以支持自定义工具的。请看下qwen-agent的readme。

github-actions[bot] commented 5 months ago

This issue has been automatically marked as inactive due to lack of recent activity. Should you believe it remains unresolved and warrants attention, kindly leave a comment on this thread. 此问题由于长期未有新进展而被系统自动标记为不活跃。如果您认为它仍有待解决,请在此帖下方留言以补充信息。