Closed PuliNath closed 1 year ago
Adding more context -We are using the botframework SDK , which is on the node.js runtime (https://github.com/microsoft/botframework-sdk) specifically ,https://learn.microsoft.com/en-us/javascript/api/botbuilder-ai/?view=botbuilder-ts-latest package.
const { CustomQuestionAnswering } = require("botbuilder-ai");
const qnaEndpoint = { knowledgeBaseId: projectname endpointKey: key, host: languagestudioHost, qnaServiceType:"Language" }; const qnaMakerOptions = { top: 5 }; const QnAService = new CustomQuestionAnswering(qnaEndpoint, qnaMakerOptions, null,undefined, true)
console.log(await QnAService.getAnswers(context)) //here context is the turncontext.
//the results are accuracte but the results do not contain metaData.
{ "answers": [ { "questions": [ "question 1?", "question 2.0" ], "answer": "rsome answerr...", "confidenceScore": 0.6391, "id": 29, "source": "source.xlsx", "metadata":[] -- ------------->empty??? ( this has key /values trained in portal)
whereas if we make use of old qnamaker class from botbuilder-ai we get the meta data , doing this since qnamaker would be not available from 2025.
The issue is on the sdk languageutils.ts file , private formatQnaResult(kbAnswers: KnowledgeBaseAnswers): QnAMakerResults { const qnaResultsAnswers = kbAnswers.answers?.map((kbAnswer: KnowledgeBaseAnswer) => { const qnaResult: QnAMakerResult = { answer: kbAnswer.answer, score: kbAnswer.confidenceScore, metadata: kbAnswer.metadata ? Array.from(kbAnswer.metadata)?.map((nv) => { return { name: nv[0], value: nv[1] }; }) : null,
The highlighted funtion would return [] for objects ,m could u please , let us know if this would be fixed or is fixed in a new version of botbuilder-ai????
Fixed in JS SDK 4.17.1. Please update your packages.
Describe the bug the results answers from customQuestionAnswering.getanswers do not contain METADATA, instead the array is empty. whereas direct api call via curl provided from language studio ,does produce the result. To Reproduce Steps to reproduce the behavior:
Expected behavior The metadata parameter returned from language Studio via CustomQuestionAnswering .getanswers , should have metadata values as trained in the language studio custom question answering.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Could this be due to reason that a dictionary is fetched from the actual/normal curl shared in the language studio portal , the exact same dictionary might have errored out , when converting to an array perhaps? because the result from getanswers method has empty array. adding a link to the library : https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.ai.qna.customquestionanswering.getanswersasync?view=botbuilder-dotnet-stable