You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

微软CLU无Upload 'Utterances' API?求自动化上传替代方案

替代LUIS上传Utterances到CLU的自动化方案

CLU并非没有批量导入utterances的能力,只是接口归类和LUIS不同,以下是三种可行的自动化上传方案:

1. 调用CLU创作API批量导入

CLU创作API提供了POST /language/authoring/analyze-conversations/projects/{projectName}/:import端点,支持批量导入包含意图、实体和utterances的结构化JSON数据。

数据格式要求(与LUIS略有差异)

需遵循CLU的训练数据规范,示例JSON结构:

{
  "projectFileKind": "Conversation",
  "intents": [{"category": "BookFlight"}],
  "entities": [{"category": "Destination"}],
  "utterances": [
    {
      "text": "I want to fly to Paris",
      "intent": "BookFlight",
      "entities": [{"category": "Destination", "offset": 16, "length": 5}]
    }
  ]
}

调用时需在请求头中携带创作密钥(Ocp-Apim-Subscription-Key),请求体传入上述格式的JSON内容即可完成批量导入。

2. 使用Azure CLI实现自动化

通过Azure CLI的CLU扩展可以快速完成批量导入,适合脚本化自动化流程:

  1. 安装CLU相关扩展:
az extension add --name ml
  1. 执行导入命令:
az ml clu project import --name <你的项目名> --file <本地JSON文件路径> --resource-group <资源组名> --subscription <订阅ID>

将上述命令嵌入Shell或PowerShell脚本,即可实现定时或批量的自动化上传。

3. 通过CLU SDK集成到代码流程

官方提供的多语言SDK(Python、.NET等)支持批量导入操作,以Python为例:

  1. 安装SDK:
pip install azure-ai-language-conversations
  1. 示例导入代码:
import json
from azure.core.credentials import AzureKeyCredential
from azure.ai.language.conversations.authoring import ConversationAuthoringClient

endpoint = "你的CLU创作端点"
key = "你的创作密钥"
project_name = "你的项目名称"

client = ConversationAuthoringClient(endpoint, AzureKeyCredential(key))

# 读取本地utterances数据文件
with open("utterances_data.json", "r", encoding="utf-8") as f:
    import_payload = json.load(f)

# 发起异步导入请求
poller = client.begin_import_project(project_name, import_payload)
import_result = poller.result()

这种方式适合嵌入现有自动化流水线,还可额外添加LUIS到CLU的格式转换逻辑,处理历史数据迁移。

关键注意事项

  • 确保CLU项目已提前创建,且导入JSON中的意图、实体名称与项目定义完全匹配,否则会导致导入失败。
  • 必须使用创作密钥而非预测密钥调用接口/SDK,且端点需对应项目所在区域。

内容的提问来源于stack exchange,提问作者masadskt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 06:08:21