Skip to content

Commit

Permalink
CLU project
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed May 24, 2023
1 parent 20d4421 commit 0b779a2
Show file tree
Hide file tree
Showing 45 changed files with 15,626 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreWithLanguageCLU", "CoreWithLanguageCLU\CoreWithLanguageCLU.csproj", "{18BC36DA-7A7B-4A89-BDB5-4DA22876A213}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{18BC36DA-7A7B-4A89-BDB5-4DA22876A213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18BC36DA-7A7B-4A89-BDB5-4DA22876A213}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18BC36DA-7A7B-4A89-BDB5-4DA22876A213}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18BC36DA-7A7B-4A89-BDB5-4DA22876A213}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {82AF080E-50C1-4342-9A1F-B108D845B644}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# files generated during the lubuild process
generated/
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Settings;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace CoreWithLanguageCLU.Controllers
{
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
// achieved by specifying a more specific type for the bot constructor argument.
[ApiController]
public class BotController : ControllerBase
{
private readonly Dictionary<string, IBotFrameworkHttpAdapter> _adapters = new Dictionary<string, IBotFrameworkHttpAdapter>();
private readonly IBot _bot;
private readonly ILogger<BotController> _logger;

public BotController(
IConfiguration configuration,
IEnumerable<IBotFrameworkHttpAdapter> adapters,
IBot bot,
ILogger<BotController> logger)
{
_bot = bot ?? throw new ArgumentNullException(nameof(bot));
_logger = logger;

var adapterSettings = configuration.GetSection(AdapterSettings.AdapterSettingsKey).Get<List<AdapterSettings>>() ?? new List<AdapterSettings>();
adapterSettings.Add(AdapterSettings.CoreBotAdapterSettings);

foreach (var adapter in adapters ?? throw new ArgumentNullException(nameof(adapters)))
{
var settings = adapterSettings.FirstOrDefault(s => s.Enabled && s.Type == adapter.GetType().FullName);

if (settings != null)
{
_adapters.Add(settings.Route, adapter);
}
}
}

[HttpPost]
[HttpGet]
[Route("api/{route}")]
public async Task PostAsync(string route)
{
if (string.IsNullOrEmpty(route))
{
_logger.LogError($"PostAsync: No route provided.");
throw new ArgumentNullException(nameof(route));
}

if (_adapters.TryGetValue(route, out IBotFrameworkHttpAdapter adapter))
{
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogInformation($"PostAsync: routed '{route}' to {adapter.GetType().Name}");
}

// Delegate the processing of the HTTP POST to the appropriate adapter.
// The adapter will invoke the bot.
await adapter.ProcessAsync(Request, Response, _bot).ConfigureAwait(false);
}
else
{
_logger.LogError($"PostAsync: No adapter registered and enabled for route {route}.");
throw new KeyNotFoundException($"No adapter registered and enabled for route {route}.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Logging;

namespace CoreWithLanguageCLU.Controllers
{
/// <summary>
/// A controller that handles skill replies to the bot.
/// </summary>
[ApiController]
[Route("api/skills")]
public class SkillController : ChannelServiceController
{
private readonly ILogger<SkillController> _logger;

public SkillController(ChannelServiceHandlerBase handler, ILogger<SkillController> logger)
: base(handler)
{
_logger = logger;
}

public override Task<IActionResult> ReplyToActivityAsync(string conversationId, string activityId, Activity activity)
{
try
{
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug($"ReplyToActivityAsync: conversationId={conversationId}, activityId={activityId}");
}

return base.ReplyToActivityAsync(conversationId, activityId, activity);
}
catch (Exception ex)
{
_logger.LogError(ex, $"ReplyToActivityAsync: {ex}");
throw;
}
}

public override Task<IActionResult> SendToConversationAsync(string conversationId, Activity activity)
{
try
{
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug($"SendToConversationAsync: conversationId={conversationId}");
}

return base.SendToConversationAsync(conversationId, activity);
}
catch (Exception ex)
{
_logger.LogError(ex, $"SendToConversationAsync: {ex}");
throw;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/BotFramework-Composer/main/Composer/packages/server/schemas/botproject.schema",
"name": "CoreWithLanguageCLU",
"skills": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<UserSecretsId>56196dad-e653-48b3-a22b-f02096743b0e</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Content Include="**/*.blu;**/*.dialog;**/*.lg;**/*.lu;**/*.model;**/*.onnx;**/*.qna;**/*.txt" Exclude="$(BaseOutputPath)/**;$(BaseIntermediateOutputPath)/**;wwwroot/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.18.1" />
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.18.1" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime" Version="4.18.1" />
<PackageReference Include="Microsoft.Bot.Components.HelpAndCancel" Version="1.3.0" />
<PackageReference Include="Microsoft.Bot.Components.Welcome" Version="1.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"$kind": "Microsoft.AdaptiveDialog",
"$designer": {
"name": "CoreWithLanguageCLU",
"description": "",
"id": "4pM5gc"
},
"autoEndDialog": true,
"defaultResultProperty": "dialog.result",
"triggers": [
{
"$kind": "Microsoft.OnConversationUpdateActivity",
"$designer": {
"id": "376720",
"comment": "This trigger runs when a conversation update activity is sent to the bot. This indicates a user or bot being added or removed from a conversation."
},
"actions": [
{
"$kind": "Microsoft.Foreach",
"$designer": {
"id": "518944",
"name": "Loop: for each item",
"comment": "For each member added to the conversation."
},
"itemsProperty": "turn.Activity.membersAdded",
"actions": [
{
"$kind": "Microsoft.IfCondition",
"$designer": {
"id": "641773",
"name": "Branch: if/else",
"comment": "Checks that that member added ID does not match the bot ID. This prevents the greeting message from being sent when the bot is added to a conversation."
},
"condition": "=string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
"actions": [
{
"$kind": "Microsoft.BeginDialog",
"$designer": {
"id": "PlH6iz",
"comment": "Launches the WelcomeDialog containing logic for greeting users."
},
"activityProcessed": true,
"dialog": "WelcomeDialog"
}
]
}
]
}
]
},
{
"$kind": "Microsoft.OnIntent",
"$designer": {
"id": "e1i6lY",
"name": "Cancel",
"comment": "Triggered when the Cancel intent is recognized in the user's utterance."
},
"intent": "Cancel",
"actions": [
{
"$kind": "Microsoft.BeginDialog",
"$designer": {
"id": "FDsuIq",
"comment": "Launches the CancelDialog."
},
"activityProcessed": true,
"dialog": "CancelDialog"
}
],
"condition": "=turn.recognized.score > 0.9"
},
{
"$kind": "Microsoft.OnIntent",
"$designer": {
"id": "9wETGs",
"name": "Help",
"comment": "Triggered when the Help intent is recognized in the user's utterance."
},
"intent": "Help",
"actions": [
{
"$kind": "Microsoft.BeginDialog",
"$designer": {
"id": "B0NP8m",
"comment": "Launches the HelpDialog."
},
"activityProcessed": true,
"dialog": "HelpDialog"
}
]
},
{
"$kind": "Microsoft.OnError",
"$designer": {
"id": "aLQGr7",
"comment": "Triggered when an error event is thrown by the dialog stack. "
},
"actions": [
{
"$kind": "Microsoft.TelemetryTrackEventAction",
"$designer": {
"id": "Aucn7t",
"comment": "Logs the error received in the Telelmetry Client (typically Application Insights for production instances)."
},
"eventName": "ErrorOccurred",
"properties": {
"Type": "=turn.dialogEvent.value.className",
"Exception": "=turn.dialogEvent.value"
}
},
{
"$kind": "Microsoft.SendActivity",
"$designer": {
"id": "2outgQ",
"comment": "Shows error message to user."
},
"activity": "${SendActivity_ErrorOccured()}"
},
{
"$kind": "Microsoft.TraceActivity",
"$designer": {
"id": "NVFqr5",
"comment": "Emits a trace activity with the error value that is visible in local testing channels such as the Bot Framework Composer Web Chat window and the Bot Framework Emulator."
},
"name": "=turn.dialogEvent.value.className",
"valueType": "Exception",
"value": "=turn.dialogEvent.value",
"label": "ErrorOccurred"
}
]
},
{
"$kind": "Microsoft.OnUnknownIntent",
"$designer": {
"id": "FOxcnx",
"comment": "This trigger fires when an incoming activity is not handled by any other trigger."
},
"actions": [
{
"$kind": "Microsoft.SendActivity",
"$designer": {
"id": "IQMEuO",
"comment": "It is recommended to show a message to the user when the bot does not know how to handle an incoming activity and provide follow up options or a help message.\n"
},
"activity": "${SendActivity_DidNotUnderstand()}"
}
]
}
],
"generator": "CoreWithLanguageCLU.lg",
"id": "CoreWithLanguageCLU",
"recognizer": {
"$kind": "Microsoft.CluRecognizer",
"projectName": "LUIS-CLU",
"endpoint": "https://ceci-core-assistant-clu2.cognitiveservices.azure.com",
"endpointKey": "66b66ad932864bbebc6d23b9207cc472",
"deploymentName": "CLU"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="BotBuilder.myget.org" value="https://botbuilder.myget.org/F/botbuilder-v4-dotnet-daily/api/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Loading

0 comments on commit 0b779a2

Please sign in to comment.