qwen-omni系列模型在设置modalities为含有语音回复时,将不再识别tools调用。

满心期待的全模态大模型qwen-omni系列(qwen-omni-7b或者qwen-omni-turbo),实际使用测试发现,当设置回复类型为:modalities: ['text', 'audio']时,将不会触发任何tools调用。测试代码如下:

import {ChatOpenAI} from "@langchain/openai";
import { Tool,tool } from "@langchain/core/tools";
import { z } from "zod";
import * as fs from "fs";
const llm = new ChatOpenAI({
    apiKey: "xxxxxx",
    model: "qwen-omni-turbo",
    configuration: {
        baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
    },
    streaming: true,
    modalities: ['text', 'audio'],//注释掉此行即可正常
});
const tools=[
    tool((args)=>{
        return "当前城市天气:温度26度,晴";
    },{
        name:"get_weather_by_location",
        description:"获取指定地点的天气",
        schema:z.object({
            location:z.string().describe("城市名称")
        })
    })
]
const llmWithTools=llm.bindTools(tools);

const completion = await llmWithTools.invoke([
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "获取杭州的天气" }
]);
fs.writeFileSync("completion.json", JSON.stringify(completion, null, 2));

回复内容:

"content": "嗯…我也不太清楚杭州现在的天气呢。你可以看看手机上的天气预报软件,像墨迹天气或者中国气象网之类的,那上面的信息很准的。不过你要是想了解下杭州天气的一般情况的话,杭州属于亚热带季风气候,夏季炎热多雨,冬季温和少雪。你要是打算出门的话,最好还是查一下具体的天气状况哈。有啥新消息也可以跟我说说呀。",

展开
收起
小小小包子 2025-04-06 14:00:10 50 分享 版权
1 条回答
写回答
取消 提交回答
  • 您好,辛苦您加入“阿里云百炼使用体验2群”群的钉钉群号: 77600022533,在钉钉群内反馈您的问题。

    2025-04-10 14:49:36
    赞同 125 展开评论

基于通义系列大模型和开源大模型的一站式大模型服务平台,提供「生成式大模型的全流程应用工具」和「企业大模型的全链路训练工具」。为大模型,也为小应用。 阿里云百炼官网网址:https://www.aliyun.com/product/bailian

还有其他疑问?
咨询AI助理