Skip to content

Function Call 完整示例

完整代码

python
from dashscope import Generation
import json

def call_qwen_with_function_call(user_query: str):
    messages = [{"role": "user", "content": user_query}]
    
    response = Generation.call(
        model="qwen-max",
        messages=messages,
        tools=tools,
        result_format="message"
    )
    
    return response.output.choices[0].message.content

运行示例

bash
python example.py

Released under the MIT License.