代码之家  ›  专栏  ›  技术社区  ›  Souvik Ghosh

如何基于源代码过滤QnAMaker问题

  •  0
  • Souvik Ghosh  · 技术社区  · 7 年前

    我在Bot框架中使用qnamakerrestapi来查询知识库。

    它的工作很好,但我想过滤的'问题'的基础上'源'上指定的 requestData https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/metadata-generateanswer-usage

    我尝试将“source”作为元数据传递给 strictFilters

    Dictionary<string, object> requestData = new Dictionary<string, object>
    {
        ["question"] = question,
        ["top"] = top,
        ["strictFilters"] = new Dictionary<string, object>
        {
            ["source"] = "test.tsv"
        }
    };
    
    string requestBody = JsonConvert.SerializeObject(requestData);
    kbId = _configuration[qnaKbName];
    method = "/knowledgebases/" + kbId + "/generateAnswer/";
    var uri = host + method;
    var response = await Post(uri, requestBody);
    return response;
    

    请求JSON格式-

    {"question":"flexible working","top":5,"strictFilters":{"source":"test.tsv"}}
    

    它不工作,我得到下面的回应-

    {
      "error": {
        "code": "BadArgument",
        "message": "Parameter is null"
      }
    }
    

    尝试像这样创建请求JSON-

    {"question":"sabbatical","top":5,"strictFilters":[{"name":"source","value":"test.tsv"}]}
    

    {
      "error": {
        "code": "Unspecified",
        "message": "Something happened. Please retry after some time."
      }
    }
    

    有什么办法吗?如果我能提供更多细节,请告诉我。。

    0 回复  |  直到 7 年前
        1
  •  0
  •   FlyingFoX Stephen Cleary    5 年前

    错误 BadArgument, Parameter is null 当传递的输入json与qnaapi请求体不匹配时发生。例如,如果API期望 {"question":"this is my question"} {"questionAB":"this is my question"} ,这将引发错误。