Cognitive Services | Update Qnas - Why does add operation parse HTML to Markdown but replace operation does not

Zachary Shane 26 Reputation points
2022-08-11T11:48:51.073+00:00

I'm using the Question Answering Projects - Update Qnas API operation and I'm experiencing different behavior between the updateOperationKind of "add" and "replace".

When I use "add" and pass in some HTML it will parse the HTML to Markdown. Then I have clean Markdown in the Language Studio editor.

Alternatively, when I pass in the same HTML using the "replace" operation, it does not parse the HTML and uploads it as plain text. This causes the chat bot to render actual HTML as plain text which is not ideal.

So why is there a difference?

My use case here is I'm allowing users in a SharePoint tenant to request for a QnA bot on their site. They can build QnA Pairs within a Power App with data being stored in SharePoint lists. When I do the initial import of data using the "add" operation, everything translates from SharePoint correctly. It's all converted to Markdown in Language Studio.

However, when I then allow them to edit their answers, and use the "replace" operation, it replaces the Markdown with HTML.

As a work around I can just delete the QnA pair in the KB and then do another "add". But I'm trying to avoid that since I'm syncing the 2 locations and that would make it more difficult.

Here is a sample body for you to try:

[  
    {  
        "op": "replace",  
        "value":{  
            "id": 1,  
            "answer": "<div class=\"ExternalClass48DCB366DF144C948DCFAD9A12F2DFD6\"><p><strong>Lorem ipsum dolor sit amet</strong>, consectetur adipiscing elit. Nam id nulla ac mauris convallis finibus in vitae leo. Nullam auctor eros quis neque laoreet, sed malesuada augue pulvinar. Suspendisse potenti. Duis semper, ipsum eu elementum convallis, libero neque auctor dolor, in tempor nulla nisl non diam. Etiam sapien nisl, consectetur id justo vel, congue scelerisque diam. Vivamus aliquam rutrum ipsum ut laoreet. **Donec vitae velit non **elit vestibulum auctor non in justo. Sed tincidunt tempor nibh consequat condimentum. Etiam sodales in nunc eu cursus. Aliquam tempor gravida porta. Nam ultrices nisl id blandit malesuada. Phasellus eu neque at metus scelerisque lobortis vitae et odio. In ut feugiat nisi, in fermentum tellus. Nulla nec scelerisque augue. Sed placerat suscipit aliquet.</p></div>",  
            "source": "My New Source",  
            "questions": [  
                "Nullam auctor eros quis neque laoreet"  
            ],  
            "metadata": {},  
            "dialog": {  
                "isContextOnly": false,  
                "prompts": []  
            }  
        }  
    },  
    {  
        "op": "add",  
        "value":{  
            "answer": "<div class=\"ExternalClass48DCB366DF144C948DCFAD9A12F2DFD6\"><p><strong>Lorem ipsum dolor sit amet</strong>, consectetur adipiscing elit. Nam id nulla ac mauris convallis finibus in vitae leo. Nullam auctor eros quis neque laoreet, sed malesuada augue pulvinar. Suspendisse potenti. Duis semper, ipsum eu elementum convallis, libero neque auctor dolor, in tempor nulla nisl non diam. Etiam sapien nisl, consectetur id justo vel, congue scelerisque diam. Vivamus aliquam rutrum ipsum ut laoreet. **Donec vitae velit non **elit vestibulum auctor non in justo. Sed tincidunt tempor nibh consequat condimentum. Etiam sodales in nunc eu cursus. Aliquam tempor gravida porta. Nam ultrices nisl id blandit malesuada. Phasellus eu neque at metus scelerisque lobortis vitae et odio. In ut feugiat nisi, in fermentum tellus. Nulla nec scelerisque augue. Sed placerat suscipit aliquet.</p></div>",  
            "source": "My New Source",  
            "questions": [  
                "Nullam auctor eros quis neque laoreet"  
            ],  
            "metadata": {},  
            "dialog": {  
                "isContextOnly": false,  
                "prompts": []  
            }  
        }  
    }  
]  
Microsoft Q&A
Microsoft Q&A
Use this tag to share suggestions, feature requests, and bugs with the Microsoft Q&A team. The Microsoft Q&A team will evaluate your feedback on a regular basis and provide updates along the way.
559 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,335 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 41,841 Reputation points Microsoft Employee
    2022-08-11T14:25:09.567+00:00

    @Zachary Shane Did you try to preserve the HTML format in your file by ensuring that opening and closing of the tags are converted in the encoded format? The guidance from the markdown format documentation for the update/replace API is to follow the encoding format. For example:

    Representation in API request: &lt;br&gt;
    Representation in KB: <br>

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.