⌘K

Tongyi Intent Detect V3

tongyi-intent-detect-v3

意图理解模型, 能够在百毫秒级时间内快速准确地解析用户意图, 并选择合适的工具来解决用户的问题。支持三种模式:意图+函数调用, 仅意图, 仅函数调用。

认证

authorization string required

所有 API 均使用 Bearer Token 鉴权

获取 API Key:

访问 API Key 管理页面 获取 API Key

用法:

将以下 Header 添加到请求中:

Authorization: Bearer YOUR_API_KEY

参数

model string required

用于请求的模型 ID

Value:tongyi-intent-detect-v3


messages array required

表示对话历史的消息对象数组

role string required

消息角色

可选值:user, assistant, system

content string required

消息内容。系统消息必须包含模式指令和配置


max_tokens integer

生成的最大 token 数量

范围:1 - 1024


temperature number

采样温度

默认值:1.0

范围:0.0 - 2.0


使用模式

意图 + 函数调用模式(INTENT_MODE)

同时输出意图标签和函数调用信息。系统消息格式:

You are Qwen, created by Alibaba Cloud. You are a helpful assistant. You may call one or more tools to assist with the user query. The tools you can use are as follows:
[JSON 格式的工具定义]
Response in INTENT_MODE.

响应格式

<tags>
[意图标签]
</tags><tool_call>
[函数调用数组]
</tool_call><content>
响应文本
</content>

仅意图模式

仅输出意图分类。系统消息格式:

You are Qwen, created by Alibaba Cloud. You are a helpful assistant.
You should choose one tag from the tag list:
{JSON 格式的意图字典}
Just reply with the chosen tag.

提示:使用单个大写字母 (A, B, C…) 作为意图键可获得更快响应(始终为 1 个 token)


仅函数调用模式(NORMAL_MODE)

仅输出函数调用信息。系统消息格式:

You are Qwen, created by Alibaba Cloud. You are a helpful assistant. You may call one or more tools to assist with the user query. The tools you can use are as follows:
[JSON 格式的工具定义]
Response in NORMAL_MODE.

响应格式

<tool_call>
{函数调用对象}
</tool_call>

工具定义格式

工具应在系统消息中定义为 JSON 数组:

[
  {
    "name": "函数名称",
    "description": "函数描述",
    "parameters": {
      "type": "object",
      "properties": {
        "参数名": {
          "type": "string",
          "description": "参数描述"
        }
      },
      "required": ["参数名"]
    }
  }
]

多轮对话

模型支持多轮对话。如果提供的信息不足, 模型会先提出后续问题, 然后再进行函数调用

示例

用户:“我想查天气”
模型:“请问您想查询哪个城市的天气呢?“
用户:“杭州”
模型:返回带有 location 参数的函数调用


响应格式

标准的 chat completion 响应, 根据所选模式使用模型特定的内容格式

id string

completion 的唯一标识符


choices array

completion 选择数组

message object

生成的消息

content string

响应内容, 格式由模式指定(意图标签, XML 格式的工具调用或纯文本)


usage object

token 使用统计

prompt_tokens integer

提示中的 token 数量

completion_tokens integer

completion 中的 token 数量

total_tokens integer

使用的总 token 数量