modelscope / agentscope

Start building LLM-empowered multi-agent applications in an easier way.
https://doc.agentscope.io/
Apache License 2.0
5.34k stars 328 forks source link

[Bug]:TagNotFoundError: Failed to find tags #480

Closed lingbaishun closed 2 weeks ago

lingbaishun commented 2 weeks ago

assistant:

[
  {
    "role": "thought",
    "content": "用户询问深圳有什么好吃的粤菜,我可以使用食物搜索接口来获取相关信息。"
  },
  {
    "function": "food_search",
    "arguments": {
      "city": "深圳",
      "keywords": "粤菜"
    }
  }
]

system: TagNotFoundError: Failed to find tags: thought, function

请问,thought,function,arguments这些都有,为何还会一直报 Failed to find tags: thought, function

DavdGao commented 2 weeks ago

Could you provide more details about your code?

lingbaishun commented 2 weeks ago

就是定义了几个类似bing_search的函数,然后

service_toolkit = ServiceToolkit()
service_toolkit.add(food_search, api_key=FOOD_API_KEY)
service_toolkit.add(byd_web_search)
service_toolkit.add(hotel_search, api_key=FOOD_API_KEY)

agentscope.init(
    model_configs=model_configs,
    project="Conversation with ReActAgent",
    name="my_test",
    save_api_invoke=True,
    studio_url="http://10.167.155.84:8080"
)

# Create agents
agent = ReActAgent(
    name="assistant",
    sys_prompt='你是一个问答机器人,请根据根据用户话术思考调用工具,并根据工具返回结果进行总结回答',
    model_config_name=model_configs.get("config_name"),
    verbose=True,
    service_toolkit=service_toolkit,
)

user = UserAgent(name="User", input_hint="User Input ('exit' to quit): ")

对话过程中,我看日志打印已经有 thought,function,但是还是一直报failed to find

User: 深圳有什么好吃的粤菜
system: Respond with specific tags as outlined below:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>
...
assistant: 

{ "role": "thought", "content": "用户询问深圳有哪些好吃的粤菜,我可以使用食物搜索接口来获取相关信息。" }, { "function": "food_search", "arguments": { "city": "深圳", "keywords": "粤菜" } }

system: TagNotFoundError: Failed to find tags: thought, function
system: Respond with specific tags as outlined below:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>
...
assistant: 

{ "role": "thought", "content": "用户询问深圳有什么好吃的粤菜,我可以使用食物搜索接口来获取相关信息。" }, { "function": "food_search", "arguments": { "city": "深圳", "keywords": "粤菜" } }

system: TagNotFoundError: Failed to find tags: thought, function
system: Respond with specific tags as outlined below:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>
...
assistant: 

{ "role": "assistant", "content": "是的,特朗普在2024年美国总统大选中胜出了。根据多家美国媒体的报道,特朗普获得了277张选举人票,超过了当选所需的270张票。特朗普在佛罗里达州棕榈滩会议中心向支持者发表了胜选讲话。民主党总统候选人哈里斯得票数为224张。此外,共和党在参议院选举中赢得了51个席位,控制了参议院。" }

system: TagNotFoundError: Failed to find tags: thought, function
system: Respond with specific tags as outlined below:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>
DavdGao commented 2 weeks ago

As described in your logging, the required format is that the content should be tagged by <xxx> and </xxx>

system: Respond with specific tags as outlined below:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>

However, it seems like your model responded in JSON dictionary format directly. So that's the reason why "thought" and "function" tags are not found

{
"role": "thought",
"content": "用户询问深圳有哪些好吃的粤菜,我可以使用食物搜索接口来获取相关信息。"
},
{
"function": "food_search",
"arguments": {
"city": "深圳",
"keywords": "粤菜"
}
}

So which llm are you using and please provide your agentscope version by the following code:

import agentscope
print(agentscope.__version__)
lingbaishun commented 2 weeks ago

thank you.I understand