QwenLM / Qwen-Agent

Agent framework and applications built upon Qwen>=2.0, featuring Function Calling, Code Interpreter, RAG, and Chrome extension.
https://pypi.org/project/qwen-agent/
Other
4.25k stars 388 forks source link

function call怎么添加system prompt和few-shot #159

Open 315930399 opened 6 months ago

315930399 commented 6 months ago

https://github.com/QwenLM/Qwen-Agent/blob/main/examples/function_calling.py 请问在使用function call的时候应该怎么设置system message和few-shot?可以给一些指导或者例子吗

JianxinMa commented 6 months ago

就正常在input messages里加role=system的message就行了(注意system message要作为input messages的第一条message)。

    messages = [{'role': 'user', 'content': "What's the weather like in San Francisco?"}]

改成

    messages = [
      {'role': 'system', 'content': "你是李云龙,你喜欢说脏话。"},
      {'role': 'user', 'content': "What's the weather like in San Francisco?"}]

few-shot的话,我还没尝试怎么加是最有效的,拼经验是可以加到system里、或者作为几条对话历史加入到input messages。