dify 当在代理中使用"command-r-plus"模型来调用工具时,通常400错误表示客户端请求错误,

2guxujil  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(44)

自检

  • 仅用于提交错误报告,如果您想提问,请访问 Discussions
  • 我已在 search for existing issues 中搜索了现有问题,包括已关闭的问题。
  • 我确认我使用英语提交此报告(我已阅读并同意 Language Policy )。
  • 请不要修改此模板 :) 并填写所有必填字段。

Dify版本

0.6.11

云或自托管

自托管(Docker)

重现步骤

当在代理中使用“command-r-plus”模型调用工具时,通常会出现400错误,这表明客户端请求可能存在错误。这意味着请求的格式或内容可能不符合预期的标准,或者传递的参数可能存在错误:
[cohere] 错误请求,状态码:400,正文:{'message': '无效请求:无法在多步模式下同时指定消息和工具结果'}

✔️ 预期行为

期望正常使用工具调用。

❌ 实际行为

400错误

jyztefdp

jyztefdp1#

你好@vary!我在这里帮助你解决bug、问题以及成为贡献者。在我等待人工维护人员时,请告诉我如何协助你。
要解决在使用代理中的"command-r-plus"模型调用工具时出现的400错误,指示"无效请求:无法在多步模式中同时指定message和tool_results",请确保你的请求中没有同时指定messagetool_results。请求应包含messagetool_results,但不能同时使用。
以下是如何正确构建请求的示例:

model: command-r-plus
parameters:
  temperature: 0.7
  p: 0.75
  k: 50
  presence_penalty: 0.5
  frequency_penalty: 0.5
  max_tokens: 1024
# Ensure you only include either message or tool_results, not both
request:
  message: "Your message here"
  # tool_results: "Your tool results here"  # Comment this out or remove it

请根据您的具体用例调整参数和请求内容。

  • 要继续与Dosu交流,请提及@dosu。*
mm5n2pyu

mm5n2pyu2#

我遇到了同样的问题。目前,我只能通过设置force_single_step=True来避免这个问题。

slwdgvem

slwdgvem3#

遇到相同的问题。我与文档中所做的唯一不同之处是,我流式传输请求。
Cohere多步工具文档显示以下示例:

message = "Who is the mayor of the capital of Ontario?"
model = "command-r-plus"

# STEP 2: Check what tools the model wants to use and how

res = co.chat(model=model, message=message, force_single_step=False, tools=[web_search_tool])

# as long as the model sends back tool_calls,
# keep invoking tools and sending the results back to the model
while res.tool_calls:
  print(res.text) # This will be an observation and a plan with next steps
  tool_results = []
  for call in res.tool_calls:
    # use the `web_search` tool with the search query the model sent back
    web_search_results = {"call": call, "outputs": web_search(call.parameters["query"])}
    tool_results.append(web_search_results)

  res = co.chat(
    model="command-r-plus",
    chat_history=res.chat_history,
    message="",
    force_single_step=False,
    tools=[web_search_tool],
    tool_results=tool_results
  )

你是调用co.chat()还是co.chat_stream();当我流式传输请求时,我会得到这个错误。我相信多步流式传输尚未完全功能化。
使用chat_stream省略消息或给它一个空字符串将导致(至少应该有一个令牌)错误。在不更改源代码的情况下使其不可能。

相关问题