【发布时间】:2019-02-26 05:51:25
【问题描述】:
我正在尝试将 QnAmaker 知识库与 Azure 机器人服务集成。 我无法在 QnAMaker 门户上找到知识库 ID。 如何在 QnAPortal 中查找 kbid?
【问题讨论】:
标签: botframework azure-bot-service qnamaker
我正在尝试将 QnAmaker 知识库与 Azure 机器人服务集成。 我无法在 QnAMaker 门户上找到知识库 ID。 如何在 QnAPortal 中查找 kbid?
【问题讨论】:
标签: botframework azure-bot-service qnamaker
嘿,你也可以使用 python 来获得这个,看看下面的代码。 也就是说,如果您想编写一个程序来动态获取 kb id。
import http.client, os, urllib.parse, json, time, sys
# Represents the various elements used to create HTTP request path for QnA Maker
operations.
# Replace this with a valid subscription key.
# User host = '<your-resource-name>.cognitiveservices.azure.com'
host = '<your-resource-name>.cognitiveservices.azure.com'
subscription_key = '<QnA-Key>'
get_kb_method = '/qnamaker/v4.0/knowledgebases/'
try:
headers = {
'Ocp-Apim-Subscription-Key': subscription_key,
'Content-Type': 'application/json'
}
conn = http.client.HTTPSConnection(host)
conn.request ("GET", get_kb_method, None, headers)
response = conn.getresponse()
data = response.read().decode("UTF-8")
result = None
if len(data) > 0:
result = json.loads(data)
print
#print(json.dumps(result, sort_keys=True, indent=2))
# Note status code 204 means success.
KB_id = result["knowledgebases"][0]["id"]
print(response.status)
print(KB_id)
except :
print ("Unexpected error:", sys.exc_info()[0])
print ("Unexpected error:", sys.exc_info()[1])
【讨论】: