【问题标题】:How to find Knowledge base ID (kbid) for QnAMaker?如何查找 QnAMaker 的知识库 ID (kbid)?
【发布时间】:2019-02-26 05:51:25
【问题描述】:

我正在尝试将 QnAmaker 知识库与 Azure 机器人服务集成。 我无法在 QnAMaker 门户上找到知识库 ID。 如何在 QnAPortal 中查找 kbid?

【问题讨论】:

    标签: botframework azure-bot-service qnamaker


    【解决方案1】:

    知识库 ID 可以位于知识库中“部署详细信息”下的设置中。它是 POST 中位于“知识库”和“generateAnswer”之间的 guid(见下图)。

    希望有帮助!

    【讨论】:

      【解决方案2】:

      嘿,你也可以使用 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])
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多