@Abhijat Vatsyayan Thanks, That is by design. We keep a track of the QnA count and assign Ids when adding QnAs. we take care of assigning Ids.
ID ignored while adding a QnA
I am specifying an id while adding a QnA to a knowledge base. I am assuming that this id can be used to later update or delete the QnA. But it seems that QnaMaker ignores the ID and assigns its own ID to the QnA. What I find interesting is that the API is letting a caller specify a unique ID - this seems like a really bad API design but also makes me wonder if I do not understand the purpose of the ID field. There is little documentation so I have no way of finding this out.
I have, therefore, no way to later update or delete the QnA (ignoring hacks like publishing, querying and then trying to match)
I have included partial python test case that creates the QnA
import unittest
import testutils.OperationsTestBase as base
import azure.cognitiveservices.knowledge.qnamaker as q
from azure.cognitiveservices.knowledge.qnamaker.models import UpdateKbOperationDTOAdd, UpdateKbOperationDTO, \
UpdateKbOperationDTODelete, UpdateKbOperationDTOUpdate, ErrorResponseException, QnADTO, MetadataDTO, UpdateQnaDTO, \
UpdateKbContentsDTO, UpdateQnaDTOQuestions
import utils.IO
class TestCustomQnaList(base.OperationsTestBase):
def setUp(self) -> None:
self.qna_id = 1009 * 1013
super().setUp()
self.initial_questions = ["Who won the soccer world cup last year?",
"What do you know about soccer?",
"Tell me about soccer",
"Do you know who won the soccer world cup last year?"]
self.updated_questions = ["Who won the soccer world cup last year?",
"What do you know about soccer?",
"What do you know about the world cup?",
"Tell me about soccer",
"Do you know who won the soccer world cup last year?"]
self.kb_manager = self.create_kb_mgr()
def test_add_qna_list(self):
answer = """ I know that Brazil **did not win** the soccer world cup last year.
"""
qna1 = QnADTO(
questions=self.initial_questions,
answer=answer,
id=self.qna_id,
metadata=[
MetadataDTO(name="Category", value="sports, soccer")
]
)
add = UpdateKbOperationDTOAdd(qna_list=[qna1], urls=[], files=[])
update_kb_op = UpdateKbOperationDTO(add=add, delete=None, update=None)
update_op = self.kb_manager.update(update_kb_op, wait_for_done=True)
print(update_op)
The line
update_op = self.kb_manager.update(update_kb_op, wait_for_done=True)
Just calls
client.knowledgebase.update(self.kb.id, update_object)
and then waits for the operation to complete