public async Task QnaMaker_TestThreshold() { var qna = new QnAMakerMiddleware(new QnAMakerOptions() { KnowledgeBaseId = knowlegeBaseId, SubscriptionKey = subscriptionKey, Top = 1, ScoreThreshold = 0.99F }, new HttpClient()); var results = await qna.GetAnswers("how do I clean the stove?"); Assert.IsNotNull(results); Assert.AreEqual(results.Length, 0, "should get zero result because threshold"); }
public async Task QnaMaker_ReturnsAnswer() { var qna = new QnAMakerMiddleware(new QnAMakerOptions() { KnowledgeBaseId = knowlegeBaseId, SubscriptionKey = subscriptionKey, Top = 1 }, new HttpClient()); var results = await qna.GetAnswers("how do I clean the stove?"); Assert.IsNotNull(results); Assert.AreEqual(results.Length, 1, "should get one result"); Assert.IsTrue(results[0].Answer.StartsWith("BaseCamp: You can use a damp rag to clean around the Power Pack")); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { //services.Configure<Settings>(Configuration); services.AddBot <QnABot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); options.Middleware.Add(new CatchExceptionMiddleware <Exception>(async(context, exception) => { await context.TraceActivity("EchoBot Exception", exception); await context.SendActivity("Sorry, it looks like something went wrong!"); })); var qnaEndpoint = GetQnAMakerEndpoint(Configuration); var qnaMiddleware = new QnAMakerMiddleware(qnaEndpoint); options.Middleware.Add(qnaMiddleware); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddBot <QnABot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); // The CatchExceptionMiddleware provides a top-level exception handler for your bot. // Any exceptions thrown by other Middleware, or by your OnTurn method, will be // caught here. To facillitate debugging, the exception is sent out, via Trace, // to the emulator. Trace activities are NOT displayed to users, so in addition // an "Ooops" message is sent. options.Middleware.Add(new CatchExceptionMiddleware <Exception>(async(context, exception) => { await context.TraceActivity("EchoBot Exception", exception); await context.SendActivity("Sorry, it looks like something went wrong!"); })); var qnaEndpoint = GetQnAMakerEndpoint(Configuration); var qnaMiddleware = new QnAMakerMiddleware(qnaEndpoint); options.Middleware.Add(qnaMiddleware); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddBot <QnABot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); //QNA middleware configuration //Each time new activity is recived it goes via middleware var qnaEndpoint = GetQnAMakerEndpoint(Configuration); var qnaMiddleware = new QnAMakerMiddleware(qnaEndpoint); options.Middleware.Add(qnaMiddleware); /* // Storing State in the form of State form * options.Middleware.Add(new ConversationState<State>( * new AzureTableStorage("DefaultEndpointsProtocol=https;AccountName=qutdemodotnetv4a6a4;AccountKey=2RHTNZprcLsjniApNy" + * "Fttb5MTu72EkE995SzIyKpUkhjW8g8RvogaCl2flzC9k4RuNEyDfn+J0Qtz4zOmCFBfg==", "conversationstatetable"))); * options.EnableProactiveMessages = true;*/ // Exeption middleware lauer options.Middleware.Add(new CatchExceptionMiddleware <Exception>(async(context, exception) => { await context.TraceActivity("EchoBot Exception", exception); await context.SendActivity("Sorry, it looks like something went wrong!"); })); // Another time of storage in Memory for job execution IStorage dataStore = new MemoryStorage(); options.Middleware.Add( new BotState <Dictionary <int, JobData> >( dataStore, JobData.PropertyName, (context) => $"jobs/{typeof(Dictionary<int, JobData>)}")); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddBot <AAAClaimBot>(options => { options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); // The CatchExceptionMiddleware provides a top-level exception handler for your bot. // Any exceptions thrown by other Middleware, or by your OnTurn method, will be // caught here. To facillitate debugging, the exception is sent out, via Trace, // to the emulator. Trace activities are NOT displayed to users, so in addition // an "Ooops" message is sent. options.Middleware.Add(new CatchExceptionMiddleware <Exception>(async(context, exception) => { await context.TraceActivity("EchoBot Exception", exception); await context.SendActivity("Sorry, it looks like something went wrong!"); })); IStorage inMemoryDataStore = new MemoryStorage(); var qnaEndpoint = GetQnAMakerEndpoint(Configuration); var qnaMiddleware = new QnAMakerMiddleware(qnaEndpoint); options.Middleware.Add(qnaMiddleware); options.Middleware.Add(new ConversationState <ClaimStateModel>(inMemoryDataStore)); }); /*services.AddBot<RichCardsBot>(options => * { * options.CredentialProvider = new ConfigurationCredentialProvider(Configuration); * * // The CatchExceptionMiddleware provides a top-level exception handler for your bot. * // Any exceptions thrown by other Middleware, or by your OnTurn method, will be * // caught here. To facillitate debugging, the exception is sent out, via Trace, * // to the emulator. Trace activities are NOT displayed to users, so in addition * // an "Ooops" message is sent. * options.Middleware.Add(new CatchExceptionMiddleware<Exception>(async (context, exception) => * { * await context.TraceActivity("EchoBot Exception", exception); * await context.SendActivity("Sorry, it looks like something went wrong!"); * })); * * // The Memory Storage used here is for local bot debugging only. When the bot * // is restarted, anything stored in memory will be gone. * IStorage dataStore = new MemoryStorage(); * * // The File data store, shown here, is suitable for bots that run on * // a single machine and need durable state across application restarts. * // IStorage dataStore = new FileStorage(System.IO.Path.GetTempPath()); * * // For production bots use the Azure Table Store, Azure Blob, or * // Azure CosmosDB storage provides, as seen below. To include any of * // the Azure based storage providers, add the Microsoft.Bot.Builder.Azure * // Nuget package to your solution. That package is found at: * // https://www.nuget.org/packages/Microsoft.Bot.Builder.Azure/ * * // IStorage dataStore = new Microsoft.Bot.Builder.Azure.AzureTableStorage("AzureTablesConnectionString", "TableName"); * // IStorage dataStore = new Microsoft.Bot.Builder.Azure.AzureBlobStorage("AzureBlobConnectionString", "containerName"); * * options.Middleware.Add(new ConversationState<Dictionary<string, object>>(dataStore)); * });*/ }