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

SAI 1 Reputation point
2021-07-28T04:53:03.557+00:00

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.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,393 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,616 Reputation points
    2021-08-04T06:13:53.033+00:00

    @SAI 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)  
    
    0 comments No comments