botbuilder-js icon indicating copy to clipboard operation
botbuilder-js copied to clipboard

CustomQuestionAnswering answers return empty metadata

Open jesus-diaz-rivero opened this issue 3 years ago • 2 comments

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

  1. Go to Language Studio
  2. Create a dummy project
  3. Create random Question/Answer pairs with some metadata tags
  4. Initialize an instance of the CustomQuestionAnswering class in a node project.
  5. Call getAnswers or generateAnswers
  6. Inspect result
  7. 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.

jesus-diaz-rivero avatar Jul 19 '22 12:07 jesus-diaz-rivero

Hi @jesus-diaz-rivero,

I'm able to reproduce this behavior. Looking into next steps.

anishprasad01 avatar Jul 21 '22 23:07 anishprasad01

This can be reproduced with the following steps:

  1. Create a Language resource
  2. Add some question and answer pairs with metadata
  3. Save and deploy the resource
  4. Clone a fresh sample 12.customQABot and put the connection details for the language resource in the env
  5. In the sample, go to line 53 in CustomQABot.js and add console.log(response); to print out the response received from the Language service.
  6. Run the bot and ask a question, then observe the result.
  7. Optionally, also ask the question externally (for example by curl or Postman), and observe the metadata being received.

anishprasad01 avatar Jul 22 '22 19:07 anishprasad01

@jesus-diaz-rivero we have a fix in the works for this, thanks.

johnataylor avatar Aug 24 '22 18:08 johnataylor