CustomQuestionAnswering answers return empty metadata
Versions
SDK: 4.16.0 NodeJS: 16.15.1 Browser: Chrome 103 OS: macOS 11.2.3
Describe the bug
When using the CustomQuestionAnswering class to query against a Language project, the answers returned contain empty arrays in place of the actual metadata key/value pairs configured in Language Studio.
To Reproduce
- Go to Language Studio
- Create a dummy project
- Create random Question/Answer pairs with some metadata tags
- Initialize an instance of the CustomQuestionAnswering class in a node project.
- Call getAnswers or generateAnswers
- Inspect result
- Compare result vs. a call against the REST API as documented here (https://docs.microsoft.com/en-us/rest/api/cognitiveservices/questionanswering/question-answering/get-answers?tabs=HTTP#knowledgebaseanswercontext)
Expected behavior
Output of the get/generateAnswer methods should include all metadata tags
Screenshots
N/A
Additional context
At a first glance it seems the issue is that, unlike the QnA Maker API, CustomQuestionAnswering stores its metadata in an object rather than an array. However, the function languageServiceUtils.formatQnaResult tries to map the metadata object from the response as if it were an array.
Hi @jesus-diaz-rivero,
I'm able to reproduce this behavior. Looking into next steps.
This can be reproduced with the following steps:
- Create a Language resource
- Add some question and answer pairs with metadata
- Save and deploy the resource
- Clone a fresh sample 12.customQABot and put the connection details for the language resource in the
env - In the sample, go to line 53 in
CustomQABot.jsand addconsole.log(response);to print out the response received from the Language service. - Run the bot and ask a question, then observe the result.
- Optionally, also ask the question externally (for example by curl or Postman), and observe the metadata being received.
@jesus-diaz-rivero we have a fix in the works for this, thanks.