question

SAI-5851 avatar image
0 Votes"
SAI-5851 asked ramr-msft edited

Unable to create knowledge base using python SDK, gives and errorResponse of BadArguement. How to solve this? Please help me out.

I am trying to create a knowledge base, by uploading a file, but I get a errorResponse which looks something like this:


 "errorResponse": {
             "error": {
                 "code": "BadArgument",
                 "message": "Failed to extract QnAs from the source",
                 "details": [
                     {
                         "code": "ExtractionFailure",
                         "message": "Unsupported / Invalid url(s). Failed to extract Q&A from the source",
                         "target": "Multiturn-ContosoBenefits.pdf",
                         "innerError": {
                             "code": "CannotParse"
                         }
                     }
                 ]
             }
         }

I am using this file Multiturn-ContosoBenefits.pdf and this documentation for reference create.




qna-feedbackazure-qna-maker
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SAI-5851 Thanks for the question. Here is the quick-start code using python to create KB in the QnA Maker.

https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/python/QnAMaker/rest/create-kb.py

118540-image.png


0 Votes 0 ·
image.png (45.7 KiB)

I am having the same problem still. It is not working. Also, can you help me with how to get question and answers which are extracted? I have tried the downloading code but it is returning something else and not the excepted question answers.

0 Votes 0 ·

@SAI-5851 Thanks for the details. Could you please share request body Json that you are trying.

0 Votes 0 ·
Show more comments

1 Answer

ramr-msft avatar image
0 Votes"
ramr-msft answered ramr-msft edited

@SAI-5851 Thanks for the details. We are able to create knowledge base in QnAmaker using the preview-SDK quick start sample as shown below in the snapshot.
120366-screenshot-225.png

In the CreateKbDTO please set the files as shown below in the code.


  urls = []
         files = [
             FileDTO(
                 file_name = "structured.docx",
                 file_uri = "https://github.com/Azure-Samples/cognitive-services-sample-data-files/raw/master/qna-maker/data-source-formats/structured.docx"
             )]
        
        
         create_kb_dto = CreateKbDTO(
             name="QnA Maker Python SDK Quickstart",
             qna_list=[
                 qna1,
                 qna2
             ],
             urls=urls,
             files=files,
             enable_hierarchical_extraction=True,
             default_answer_used_for_extraction="No answer found.",
             language="English"
         )
         create_op = client.knowledgebase.create(create_kb_payload=create_kb_dto)
        
         create_op_monitor = _monitor_operation(client=client, operation=create_op)



screenshot-225.png (29.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.