bash - Azure QnA Maker 认知服务:以编程方式将知识库连接到 QnA Maker
问题描述
如果我通过 Azure 门户创建新知识库,则需要我将现有的 QnA Maker 服务连接到它。
然而,似乎没有一种编程方式来做到这一点:
QnA Maker REST API 提供创建和发布知识库的调用,但是没有关于如何指定要使用的 QnAmaker 服务的信息:
https://docs.microsoft.com/en-us/rest/api/cognitiveservices/qnamaker/knowledgebase
我使用大致以下操作创建和发布知识库,但似乎找不到任何方法将新创建的知识库与现有的 QnA Maker 认知服务相关联。
我是否误解了这两个资源之间的关系,或者这是文档中的一个空白,如果是这样,我如何将新的 kbase 连接到现有的 QnA Maker 服务实例?
function create_kb () {
userId=$(curl -s -X POST "${api_create_end_point}" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: ${subscription_key}" \
--data-ascii "${body}" | jq -r '.userId')
}
function get_user_kbases () {
kbId=$(curl -s -X GET "https://${endpoint}/qnamaker/v4.0/knowledgebases" \
-H "Ocp-Apim-Subscription-Key: ${subscription_key}" \
--data-ascii "" | jq -r '.knowledgebases | .[] | select(.name == "govbotkb").id')
echo "${kbId}"
}
function publish_knowledge_base () {
echo "Publishing the knowledgebase ${kbId} ..."
publish_result=$(curl -s -X POST "https://${endpoint}/qnamaker/v4.0/knowledgebases/${kbId}" \
-H "Ocp-Apim-Subscription-Key: ${subscription_key}" \
--data-ascii "${body}")
echo "${publish_result}"
}
function get_knowledgebase_details () {
echo "Getting knowledgebase details ..."
echo curl -v -X GET "https://${endpoint}/qnamaker/v4.0/knowledgebases/${kbId}" -H "Ocp-Apim-Subscription-Key: ${subscription_key}"
kbase_details=$( curl -s -X GET "https://${endpoint}/qnamaker/v4.0/knowledgebases/${kbId}" \
-H "Ocp-Apim-Subscription-Key: ${subscription_key}" \
--data-ascii "{body}"
)
echo "${kbase_details}"
}
解决方案
You are passing a subscription key into each of those API calls, including when you create the knowledge base. The subscription key comes from your QnA service, and so it is used to identify your service and connect the knowledge base to it.
推荐阅读
- pandas - 将 CSV 列数据提取到单个 Numpy 数组
- grafana - 在 Grafana InfluxDB 中选择字符串 FROM
- javascript - 如何将 css 模块生成的类传递给 Vue 中的组件
- c# - 如何让控制台读取用户输入的内容数量?
- python - 如果 pyenv 设置为针对多个版本的 python 运行,如何运行 python 代码
- c - 找出子网掩码
- bash - 如何在 shell/bash 脚本中读取 json 对象?
- arrays - 如何通过列表
到列表 来自 JSON? - python - Left += 字符串操作
- r - 如何按字母顺序列出 R 数据框变量?