问题
My QnA maker Knowledge Base is currently trained by a pdf file (http://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf ). While testing, QnA bot is not displaying the table formats from the input given.
The below image shows how it is currently displayed in the QnA maker test page.
What should I do to bring the table format (with all the row and column borders) to the chat result as same as in the input pdf file.
回答1:
According to the QnA Maker docs on docs.microsoft.com:
After importing a file or URL, QnA Maker converts and stores your content in the markdown format. The conversion process adds new lines in the text, such as \n\n. A knowledge of the markdown format helps you to understand the converted content and manage your knowledge base content.
If you add or edit your content directly in your knowledge base, use markdown formatting to create rich text content or change the markdown format content that is already in the answer. QnA Maker supports much of the markdown format to bring rich text capabilities to your content. However, the client application, such as a chat bot may not support the same set of markdown formats. It is important to test the client application's display of answers.
Tables are an html construct, and not supported in the list of options that QnA has on their markdown formats that can be used. If you're looking for a more table-like structure, they DO support bulleted and nested lists:
Power button
- Press the power button to turn your Surface Pro 4 on. You can also use the power button to put it to sleep and wake it when you’re ready to start working again.
Touchscreen
- Use the 12.3” display, with its 3:2 aspect ratio and 2736 x 1824 resolution, to watch HD movies, browse the web, and use your favorite apps. The new Surface G5 touch processor provides up to twice the touch accuracy of Surface Pro 3 and lets you use your fingers to select items, zoom in, and move things around. For more info, see Surface touchscreen on Surface.com.
To render it like that, you would use markdown like this:
Get acquainted with the features built in to your Surface Pro 4. Here’s a quick overview of Surface Pro 4 features: \n * Power button \n\t * Press the power button to turn your Surface Pro 4 on.You can also use the power button to put it to sleep and wake it when you’re ready to start working again. \n * Touchscreen \n\t * Use the 12.3” display, with its 3:2 aspect ratio and 2736 x 1824 resolution, to watch HD movies, browse the web, and use your favorite apps. The new Surface G5 touch processor provides up to twice the touch accuracy of Surface Pro 3 and lets you use your fingers to select items, zoom in, and move things around. For more info, see Surface touchscreen on Surface.com.
The page outlining how to do markdown on QnAMaker is here.
回答2:
To follow up what JJ_Wailes had written...
She is 100% correct; you can use markdown to edit the rendering of how your Q&A appears inside the Test panel. However the thing to also bare in mind is the last part of the excerpt she posted from the QnA docs:
However, the client application, such as a chat bot may not support the same set of markdown formats. It is important to test the client application's display of answers.
So how things are rendered to the users in chat ultimately depends on the channel you use.
Couple Suggestions
#1 Sticking with the idea of displaying a table to user
So if you truly insist on sticking with displaying a table to the users, one option you could look into is using the Bot Framework Web Chat channel. You can check out this thread in the webchat repo for how you can implement a table using markdown in WebChat.
await context.sendActivity({
type: 'message',
textFormat: 'markdown',
text: `| My | Table | \n|-------|--------| \n| Hello | World! |`
});
However, my 2 cents, is to instead go with recommendation #2, and using the multi-turn feature of QnA Maker. Because 1.) a table is a massive block of text to send the user all at once 2.) might render nicely on desktop, but not necessarily mobile
#2 Using Multi-Turn Feature of QnA Maker
The multi-turn feature will allow you to break down large bits of information into multiple messages to the user.
For example if user wrote "drinks",
- QnA can render 3 buttons displaying "soda, alcohol, milkshakes".
Then if the user clicked the "soda",
- QnA can then render "Coke, Rootbeer, Orange Soda" as follow-up.
Screenshot of multi-turn buttons in QnA docs:
Now since the multi-turn feature is currently in preview, it's not natively supported in the Bot Framework just yet, however it will be soon, as there are already PRs up for the work of integrating multi-turn into the 3 language SDKs of Bot Framework: C#, JS, Python
However we already have a sample in the experimental section of our botbuilder-samples repo, that shows you how you can already integrate it into your bot.
来源:https://stackoverflow.com/questions/57590225/qna-bot-not-displaying-table-format-properly