forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update .21 core app insights sample with core bot 4.5.1 changes (micr…
…osoft#2031) * - Update bot with 4.5.1 changes to core bot sample - Update to pass TelemetryClient via property on ComponentDialog (in startup.cs) instead of by constructor - Update FlightBookingRecgnizer to pass TelemetryClient to LuisRecognizer * Small fixes * Set LangVersion to latest to ensure build does not fail with C# 7.1 features * - Remove unnecessary setting of TelemetryClient when adding child dialogs - Made TelemetryInitializerMiddleware DI scope narrower as per comment from Gabo - Added missing copyright header - Reverted pattern to pass TelemetryClient into Main dialog via DI * Removed remaining redundant TelemetryClient setters when adding new dialogs * Update comment for setting TelemetryClient in MainDialog
- Loading branch information
1 parent
b58352d
commit 6ca6255
Showing
33 changed files
with
960 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
samples/csharp_dotnetcore/21.corebot-app-insights/CognitiveModels/FlightBooking.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// <auto-generated> | ||
// Code generated by LUISGen .\FlightBooking.json -cs Luis.FlightBooking -o . | ||
// Tool github: https://github.com/microsoft/botbuilder-tools | ||
// Changes may cause incorrect behavior and will be lost if the code is | ||
// regenerated. | ||
// </auto-generated> | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.AI.Luis; | ||
|
||
namespace Microsoft.BotBuilderSamples | ||
{ | ||
public partial class FlightBooking: IRecognizerConvert | ||
{ | ||
public string Text; | ||
public string AlteredText; | ||
public enum Intent { | ||
BookFlight, | ||
Cancel, | ||
GetWeather, | ||
None | ||
}; | ||
public Dictionary<Intent, IntentScore> Intents; | ||
|
||
public class _Entities | ||
{ | ||
|
||
// Built-in entities | ||
public DateTimeSpec[] datetime; | ||
|
||
// Lists | ||
public string[][] Airport; | ||
|
||
// Composites | ||
public class _InstanceFrom | ||
{ | ||
public InstanceData[] Airport; | ||
} | ||
public class FromClass | ||
{ | ||
public string[][] Airport; | ||
[JsonProperty("$instance")] | ||
public _InstanceFrom _instance; | ||
} | ||
public FromClass[] From; | ||
|
||
public class _InstanceTo | ||
{ | ||
public InstanceData[] Airport; | ||
} | ||
public class ToClass | ||
{ | ||
public string[][] Airport; | ||
[JsonProperty("$instance")] | ||
public _InstanceTo _instance; | ||
} | ||
public ToClass[] To; | ||
|
||
// Instance | ||
public class _Instance | ||
{ | ||
public InstanceData[] datetime; | ||
public InstanceData[] Airport; | ||
public InstanceData[] From; | ||
public InstanceData[] To; | ||
} | ||
[JsonProperty("$instance")] | ||
public _Instance _instance; | ||
} | ||
public _Entities Entities; | ||
|
||
[JsonExtensionData(ReadData = true, WriteData = true)] | ||
public IDictionary<string, object> Properties {get; set; } | ||
|
||
public void Convert(dynamic result) | ||
{ | ||
var app = JsonConvert.DeserializeObject<FlightBooking>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); | ||
Text = app.Text; | ||
AlteredText = app.AlteredText; | ||
Intents = app.Intents; | ||
Entities = app.Entities; | ||
Properties = app.Properties; | ||
} | ||
|
||
public (Intent intent, double score) TopIntent() | ||
{ | ||
Intent maxIntent = Intent.None; | ||
var max = 0.0; | ||
foreach (var entry in Intents) | ||
{ | ||
if (entry.Value.Score > max) | ||
{ | ||
maxIntent = entry.Key; | ||
max = entry.Value.Score.Value; | ||
} | ||
} | ||
return (maxIntent, max); | ||
} | ||
} | ||
} |
Oops, something went wrong.