Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing code docs for the AI libraries (LUIS / QnA) #4147

Merged
merged 4 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/Generator/GeographyV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,29 @@ public GeographyV2(string type, string location)
/// </summary>
public static class Types
{
/// <summary>
/// Constant for LUIS geographic location type of POI.
/// </summary>
public const string POI = "poi";

/// <summary>
/// Constant for LUIS geographic location type of City.
/// </summary>
public const string City = "city";

/// <summary>
/// Constant for LUIS geographic location type Country or Region.
/// </summary>
public const string CountryRegion = "countryRegion";

/// <summary>
/// Constant for LUIS geographic location type of Continent.
/// </summary>
public const string Continent = "continent";

/// <summary>
/// Constant for LUIS geographic location type of State.
/// </summary>
public const string State = "state";
}
}
Expand Down
11 changes: 11 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/Generator/OrdinalV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,19 @@ public OrdinalV2(string relativeTo, long offset)
/// </summary>
public static class Anchor
{
/// <summary>
/// Constant for Offset anchor type of Current.
/// </summary>
public const string Current = "current";

/// <summary>
/// Constant for Offset anchor type of End.
/// </summary>
public const string End = "end";

/// <summary>
/// Constant for Offset anchor type of Start.
/// </summary>
public const string Start = "start";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public interface ITelemetryRecognizer : IRecognizer
/// <returns>The LUIS results of the analysis of the current message text in the current turn's context activity.</returns>
Task<RecognizerResult> RecognizeAsync(ITurnContext turnContext, Dictionary<string, string> telemetryProperties, Dictionary<string, double> telemetryMetrics, CancellationToken cancellationToken = default);

/// <summary>
/// Runs an utterance through a recognizer and returns a strongly-typed recognizer result.
/// </summary>
/// <typeparam name="T">The recognition result type.</typeparam>
/// <param name="turnContext">Turn context.</param>
/// <param name="telemetryProperties">Dictionary containing additional properties to be attached to the outgoing telemetry item.</param>
/// <param name="telemetryMetrics">Dictionary containing additional metrics to be attached to the outgoing telemetry item.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Analysis of utterance.</returns>
Task<T> RecognizeAsync<T>(ITurnContext turnContext, Dictionary<string, string> telemetryProperties, Dictionary<string, double> telemetryMetrics, CancellationToken cancellationToken = default)
where T : IRecognizerConvert, new();

Expand Down
11 changes: 11 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/LuisAdaptiveRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public class LuisAdaptiveRecognizer : Recognizer
{
/// <summary>
/// The Kind name for this recognizer.
/// </summary>
[JsonProperty("$kind")]
public const string Kind = "Microsoft.LuisRecognizer";

Expand Down Expand Up @@ -136,6 +139,14 @@ public LuisRecognizerOptionsV3 RecognizerOptions(DialogContext dialogContext)
};
}

/// <summary>
/// Uses the <see cref="RecognizerResult"/> returned from the <see cref="LuisRecognizer"/> and populates a dictionary of string
/// with properties to be logged into telemetry. Including any additional properties that were passed into the method.
/// </summary>
/// <param name="recognizerResult">An instance of <see cref="RecognizerResult"/> to extract the telemetry properties from.</param>
/// <param name="telemetryProperties">A collection of additional properties to be added to the returned dictionary of properties.</param>
/// <param name="dc">An instance of <see cref="DialogContext"/>.</param>
/// <returns>The dictionary of properties to be logged with telemetry for the recongizer result.</returns>
protected override Dictionary<string, string> FillRecognizerResultTelemetryProperties(RecognizerResult recognizerResult, Dictionary<string, string> telemetryProperties, DialogContext dc)
{
var (logPersonalInfo, error) = this.LogPersonalInformation.TryGetValue(dc.State);
Expand Down
3 changes: 3 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/LuisApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public class LuisApplication
{
/// <summary>
/// Initializes a new instance of the <see cref="LuisApplication"/> class.
/// </summary>
public LuisApplication()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public class LuisComponentRegistration : ComponentRegistration, IComponentDeclarativeTypes
{
/// <summary>
/// Gets a list of <see cref="LuisAdaptiveRecognizer"/> declarative type objects.
/// </summary>
/// <param name="resourceExplorer">An instance of <see cref="ResourceExplorer"/>.</param>
/// <returns>A collection of <see cref="DeclarativeType"/> of <see cref="LuisAdaptiveRecognizer"/>.</returns>
public IEnumerable<DeclarativeType> GetDeclarativeTypes(ResourceExplorer resourceExplorer)
{
yield return new DeclarativeType<LuisAdaptiveRecognizer>(LuisAdaptiveRecognizer.Kind);
}

/// <summary>
/// Gets a list of <see cref="LuisAdaptiveRecognizer"/> declarative type objects.
/// </summary>
/// <param name="resourceExplorer">An instance of <see cref="ResourceExplorer"/>.</param>
/// <param name="sourceContext">An instance of <see cref="SourceContext"/>.</param>
/// <returns>A collection of <see cref="DeclarativeType"/> of <see cref="LuisAdaptiveRecognizer"/>.</returns>
public IEnumerable<JsonConverter> GetConverters(ResourceExplorer resourceExplorer, SourceContext sourceContext)
{
yield return new ArrayExpressionConverter<DynamicList>();
Expand Down
3 changes: 3 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/LuisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace Microsoft.Bot.Builder.AI.Luis
{
/// <summary>
/// Extension methods for LUIS.
/// </summary>
public static class LuisExtensions
{
/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/LuisRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public class LuisRecognizer : ITelemetryRecognizer
{
/// <summary>
/// The declarative type for this recognizer.
/// </summary>
[JsonProperty("$kind")]
public const string DeclarativeType = "Microsoft.LuisRecognizer";

Expand Down Expand Up @@ -123,6 +126,12 @@ public LuisRecognizer(string applicationEndpoint, LuisPredictionOptions predicti
{
}

/// <summary>
/// Gets the default HttpClient to be used when calling the LUIS API.
/// </summary>
/// <value>
/// A <see cref="HttpClient"/>.
/// </value>
public static HttpClient DefaultHttpClient { get; private set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public abstract class LuisRecognizerOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="LuisRecognizerOptions"/> class.
/// </summary>
/// <param name="application">An instance of <see cref="LuisApplication"/>.</param>
protected LuisRecognizerOptions(LuisApplication application)
{
Application = application ?? throw new ArgumentNullException(nameof(application));
Expand Down Expand Up @@ -49,6 +53,10 @@ protected LuisRecognizerOptions(LuisApplication application)
/// <value>If true, personal information is logged to Telemetry; otherwise the properties will be filtered.</value>
public bool LogPersonalInformation { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether flag to indicate if full results from the LUIS API should be returned with the recognizer result.
/// </summary>
/// <value>A value indicating whether full results from the LUIS API should be returned with the recognizer result.</value>
public bool IncludeAPIResults { get; set; } = false;

// Support original ITurnContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

namespace Microsoft.Bot.Builder.AI.Luis
{
/// <summary>
/// Options for <see cref="LuisRecognizerOptionsV2"/>.
/// </summary>
public class LuisRecognizerOptionsV2 : LuisRecognizerOptions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace Microsoft.Bot.Builder.AI.Luis
{
/// <summary>
/// Options for <see cref="LuisRecognizerOptionsV3"/>.
/// </summary>
public class LuisRecognizerOptionsV3 : LuisRecognizerOptions
{
/// <summary>
Expand Down
47 changes: 47 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/LuisTelemetryConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,64 @@ namespace Microsoft.Bot.Builder.AI.Luis
/// </summary>
public static class LuisTelemetryConstants
{
/// <summary>
/// The Key used when storing a LUIS Result in a custom event within telemetry.
/// </summary>
public static readonly string LuisResult = "LuisResult"; // Event name

/// <summary>
/// The Key used when storing a LUIS app ID in a custom event within telemetry.
/// </summary>
public static readonly string ApplicationIdProperty = "applicationId";

/// <summary>
/// The Key used when storing a LUIS intent in a custom event within telemetry.
/// </summary>
public static readonly string IntentProperty = "intent";

/// <summary>
/// The Key used when storing a LUIS intent score in a custom event within telemetry.
/// </summary>
public static readonly string IntentScoreProperty = "intentScore";

/// <summary>
/// The Key used when storing a LUIS intent in a custom event within telemetry.
/// </summary>
public static readonly string Intent2Property = "intent2";

/// <summary>
/// The Key used when storing a LUIS intent score in a custom event within telemetry.
/// </summary>
public static readonly string IntentScore2Property = "intentScore2";

/// <summary>
/// The Key used when storing LUIS entities in a custom event within telemetry.
/// </summary>
public static readonly string EntitiesProperty = "entities";

/// <summary>
/// The Key used when storing the LUIS query in a custom event within telemetry.
/// </summary>
public static readonly string QuestionProperty = "question";

/// <summary>
/// The Key used when storing an Activity ID in a custom event within telemetry.
/// </summary>
public static readonly string ActivityIdProperty = "activityId";

/// <summary>
/// The Key used when storing a sentiment label in a custom event within telemetry.
/// </summary>
public static readonly string SentimentLabelProperty = "sentimentLabel";

/// <summary>
/// The Key used when storing a LUIS sentiment score in a custom event within telemetry.
/// </summary>
public static readonly string SentimentScoreProperty = "sentimentScore";

/// <summary>
/// The Key used when storing the FromId in a custom event within telemetry.
/// </summary>
public static readonly string FromIdProperty = "fromId";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<!-- These documentation warnings excludes should be removed as part of https://github.com/microsoft/botbuilder-dotnet/issues/4052 -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<Content Include="**/*.dialog" />
<Content Include="**/*.lg" />
<Content Include="**/*.lu" />
Expand Down
3 changes: 3 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.LUIS/V3/LuisApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace Microsoft.Bot.Builder.AI.LuisV3
/// </summary>
public class LuisApplication
{
/// <summary>
/// Initializes a new instance of the <see cref="LuisApplication"/> class.
/// </summary>
public LuisApplication()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public QnAMakerDialog([CallerFilePath] string sourceFilePath = "", [CallerLineNu
return await base.BeginDialogAsync(dc, dialogOptions, cancellationToken).ConfigureAwait(false);
}

/// <inheritdoc/>
public override Task<DialogTurnResult> ContinueDialogAsync(DialogContext dc, CancellationToken cancellationToken = default)
{
var interrupted = dc.State.GetValue<bool>(TurnPath.Interrupted, () => false);
Expand All @@ -363,6 +364,7 @@ public override Task<DialogTurnResult> ContinueDialogAsync(DialogContext dc, Can
return base.ContinueDialogAsync(dc, cancellationToken);
}

/// <inheritdoc/>
protected override async Task<bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken)
{
if (dc.Context.Activity.Type == ActivityTypes.Message)
Expand Down
3 changes: 3 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.QnA/ITelemetryQnAMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Microsoft.Bot.Builder.AI.QnA
{
/// <summary>
/// Interface for adding telemetry logging capabilities to <see cref="QnAMaker"/>.
/// </summary>
public interface ITelemetryQnAMaker
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<!-- These documentation warnings excludes should be removed as part of https://github.com/microsoft/botbuilder-dotnet/issues/4052 -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<Content Include="**/*.dialog" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ namespace Microsoft.Bot.Builder.AI.QnA
/// </summary>
public class FeedbackRecords
{
// <summary>
// List of feedback records
// </summary>
/// <summary>
/// Gets or sets the list of feedback records.
/// </summary>
/// <value>
/// List of feedback records.
/// </value>
[JsonProperty("feedbackRecords")]
public FeedbackRecord[] Records { get; set; }
}
Expand Down
11 changes: 11 additions & 0 deletions libraries/Microsoft.Bot.Builder.AI.QnA/Models/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@

namespace Microsoft.Bot.Builder.AI.QnA
{
/// <summary>
/// Represents the Metadata object sent as part of QnA Maker requests.
/// </summary>
[Serializable]
public class Metadata
{
/// <summary>
/// Gets or sets the name for the Metadata property.
/// </summary>
/// <value>A string.</value>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the value for the Metadata property.
/// </summary>
/// <value>A string.</value>
[JsonProperty(PropertyName = "value")]
public string Value { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public class QnAMakerTraceInfo
[JsonProperty("rankerType")]
public string RankerType { get; set; }

/// <summary>
/// Gets or sets the <see cref="Metadata"/> collection to be sent when calling QnA Maker to boost results.
/// </summary>
/// <value>
/// An array of <see cref="Metadata"/>.
/// </value>
[Obsolete("This property is no longer used and will be ignored")]
[JsonIgnore]
public Metadata[] MetadataBoost { get; set; }
Expand Down
Loading