- Notifications
You must be signed in to change notification settings - Fork0
Custom Question Answering Bot and custom Bot UI for Website
License
sanjay-senthilkumar01/Custom-Question-Answering-Bot-and-custom-Bot-UI-
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Neura a QA bot for Neural Inverse website support for the Question regarding Neural Inverse ,With the bot's source code, anyone can create their own bot QA similar to Neura inNeuralinverse.live
Bot Framework v4 Custom question answering bot sample. This sample demonstrates usage of advanced features of Custom question answering likePrecise answering, support for unstructured sources along withMulti-turn conversations andActive Learning in a bot.
This bot has been created usingBot Framework, it shows how to create a bot that uses theCustom question answering feature in Language Service.
TheCustom question answering feature in Language Service enables you to build, train and publish a simple question and answer bot based on FAQ URLs, structured and unstructured documents or editorial content in minutes. In this sample, we demonstrate:
- How to use the Active Learning to generate suggestions for knowledge base.
- How to use follow up prompts to create multiple turns of a conversation.
- How to configure display of precise answers.
- How to enable/disable querying unstructured sources with the bot.
- This project requires aLanguage resource with Custom question answering enabled.
- Follow instructionshere to create a Custom question answering project. You will need this project's name to be used as
ProjectNameinappsettings.json. - VisitLanguage Studio and open created project.
- Go to
Edit knowledge base-> Click on...-> Click onImport questions and answers-> Click onImport as TSV. - ImportSampleForCQA.tsv file.
- You can test your knowledge base by clicking on
Testoption. - Go to
Deploy knowledge baseand click onDeploy.
Follow these steps to updateappsettings.json.
- In theAzure Portal, go to your resource.
- Go to
Keys and Endpointunder Resource Management. - Copy one of the keys as value of
LanguageEndpointKeyand Endpoint as value ofLanguageEndpointHostNameinappsettings.json. ProjectNameis the name of the project created inLanguage Studio.
Install the Bot Framework Emulator version 4.14.0 or greater fromhere
Run the bot from a terminal or from Visual Studio, choose option A or B.
A) From a terminal
# run the botdotnet runB) Or from Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Select
QnABotWithMSI.csprojfile - Press
F5to run the project
Connect to the bot using Bot Framework Emulator
- Launch Bot Framework Emulator
- File -> Open Bot
- Enter a Bot URL of
http://localhost:3978/api/messages
- Try the following utterances:
- Surface Book
- Power
- In Language Studio, click on inspect to see the closeness in the scores of the returned answers.
- InBot Framework Emulator, a card is generated with the suggestions.
- Clicking an option would send afeedback record which would show as suggestion under
Review suggestionsinLanguage Studio. ActiveLearningCardTitle,ActiveLearningCardNoMatchTextandActiveLearningCardNoMatchResponsein the card could be changed fromQnAMakerBaseDialog.cs.
- Clicking an option would send afeedback record which would show as suggestion under
- Try the following utterances:
- Accessibility
- Options
- You will notice that multi-turn prompts associated with the question are also returned in the responses.
- Try the following utterances:
- Accessibility
- Register
- You will notice a short answer returned along with a long answer.
- If testing inLanguage Studio, you might have to check
Include short answer responseat the top. - You can disable precise answering by setting
EnablePreciseAnswerto false inappsettings.json. - You can set
DisplayPreciseAnswerOnlyto true inappsettings.json to display just precise answers in the response. - Learn more aboutprecise answering.
- Go to your project inLanguage Studio -> In
Manage sourcesclick on+ Add source - Click on
URLsand addhttps://www.microsoft.com/en-us/microsoft-365/blog/2022/01/27/from-empowering-frontline-workers-to-accessibility-improvements-heres-whats-new-in-microsoft-365/and selectunstructured in theClassify file structuredropdown. - Try the following utterances:
- Frontline workers
- Hybrid work solutions
- You can observe that, answers are returned with high score.
- You can set
_includeUnstructuredSourcesto false inQnAMakerBaseDialog.cs to prevent querying unstructured sources.
- Go to your project inLanguage Studio -> In
Edit knowledge bases-> UnderMetadata column click on+ Add - Select a QnA to edit and add a key value pair, say
Language:CSharp, and click onSave changes. - Click on
Testand select metadata that you just added(Language : CSharp) by clicking onShow advanced options. - This will return answers with specified metadata only.
- You can filter answers using bot as well by passing metadata and/or source filters. Edit line no. 81 inQnAMakerBaseDialog.cs to something like below.Learn more.
varfilters=newFilters{MetadataFilter=newMetadataFilter(){LogicalOperation=Bot.Builder.AI.QnA.JoinOperator.AND.ToString()},LogicalOperation=Bot.Builder.AI.QnA.JoinOperator.AND.ToString()};filters.MetadataFilter.Metadata.Add(newKeyValuePair<string,string>("Language","CSharp"));filters.SourceFilter.Add("SampleForCQA.tsv");filters.SourceFilter.Add("SampleActiveLearningImport.tsv");// Initialize Filters with filters in line No. 81
When a bot (named asHelpBot) is added to a Teams channel or Teams group chat, you will have to refer it as@HelpBotHow to build a bot? to get answers from the service.However, bot tries to send<at>HelpBot</at>How to build a bot? as query to Custom question answering service which may not give expected results for question to bot. The following code removes<at>HelpBot</at> mentions of the bot from the message and sends the remaining text as query to the service.
- Goto
Bots/QnABotWithMSI.cs - Add References
usingMicrosoft.Bot.Connector;usingSystem.Text.RegularExpressions;
- Modify
OnTurnAsyncfunction as:publicoverrideasyncTaskOnTurnAsync(ITurnContextturnContext,CancellationTokencancellationToken=default){// Teams group chatif(turnContext.Activity.ChannelId.Equals(Channels.Msteams)){turnContext.Activity.Text=turnContext.Activity.RemoveRecipientMention();}awaitbase.OnTurnAsync(turnContext,cancellationToken);// Save any state changes that might have occurred during the turn.awaitConversationState.SaveChangesAsync(turnContext,false,cancellationToken);awaitUserState.SaveChangesAsync(turnContext,false,cancellationToken);}
SeeDeploy your C# bot to Azure for instructions.
The deployment process assumes you have an account on Microsoft Azure and are able to log into theMicrosoft Azure Portal.
If you are new to Microsoft Azure, please refer toGetting started with Azure for guidance on how to get started on Azure.
About
Custom Question Answering Bot and custom Bot UI for Website
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.