├── GPTVirtualAssistant
├── language-generation
│ └── en-us
│ │ ├── common.en-us.lg
│ │ └── GPTVirtualAssistant.en-us.lg
├── knowledge-base
│ └── en-us
│ │ └── GPTVirtualAssistant.en-us.qna
├── dialogs
│ └── emptyBot
│ │ └── knowledge-base
│ │ └── en-us
│ │ └── emptyBot.en-us.qna
├── language-understanding
│ └── en-us
│ │ └── GPTVirtualAssistant.en-us.lu
├── .deployment
├── recognizers
│ ├── GPTVirtualAssistant.lu.qna.dialog
│ ├── GPTVirtualAssistant.lu.dialog
│ └── GPTVirtualAssistant.en-us.lu.dialog
├── GPTVirtualAssistant.botproj
├── Nuget.config
├── scripts
│ ├── package.json
│ ├── DeploymentTemplates
│ │ ├── preexisting-rg-parameters.json
│ │ ├── new-rg-parameters.json
│ │ ├── template-with-new-rg.json
│ │ ├── qna-template.json
│ │ ├── function-template-with-preexisting-rg.json
│ │ └── template-with-preexisting-rg.json
│ ├── README.md
│ └── provisionComposer.js
├── GPTVirtualAssistant.csproj
├── schemas
│ ├── update-schema.sh
│ ├── update-schema.ps1
│ └── sdk.uischema
├── Program.cs
├── settings
│ └── appsettings.example.json
├── README.md
├── Controllers
│ ├── SkillController.cs
│ └── BotController.cs
├── Startup.cs
├── GPTVirtualAssistant.dialog
├── media
│ ├── create-azure-resource-command-line.png
│ └── publish-az-login.png
├── .gitignore
└── wwwroot
│ └── default.htm
├── readme_images
├── publish-bot.png
├── configure-aoai.png
├── open-botcomposer.png
├── configure-channels.png
├── configure-settings.png
└── configure-deployment.png
├── SUPPORT.md
├── CODE_OF_CONDUCT.md
├── LICENSE
├── GPTVirtualAssistant.sln
├── README.md
└── SECURITY.md
/GPTVirtualAssistant/language-generation/en-us/common.en-us.lg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/knowledge-base/en-us/GPTVirtualAssistant.en-us.qna:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/dialogs/emptyBot/knowledge-base/en-us/emptyBot.en-us.qna:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/language-understanding/en-us/GPTVirtualAssistant.en-us.lu:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/.deployment:
--------------------------------------------------------------------------------
1 | [config]
2 | project = GPTVirtualAssistant.csproj
--------------------------------------------------------------------------------
/readme_images/publish-bot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/publish-bot.png
--------------------------------------------------------------------------------
/readme_images/configure-aoai.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/configure-aoai.png
--------------------------------------------------------------------------------
/readme_images/open-botcomposer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/open-botcomposer.png
--------------------------------------------------------------------------------
/readme_images/configure-channels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/configure-channels.png
--------------------------------------------------------------------------------
/readme_images/configure-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/configure-settings.png
--------------------------------------------------------------------------------
/readme_images/configure-deployment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/aoai-virtual-assistant/HEAD/readme_images/configure-deployment.png
--------------------------------------------------------------------------------
/GPTVirtualAssistant/recognizers/GPTVirtualAssistant.lu.qna.dialog:
--------------------------------------------------------------------------------
1 | {
2 | "$kind": "Microsoft.CrossTrainedRecognizerSet",
3 | "recognizers": []
4 | }
5 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/recognizers/GPTVirtualAssistant.lu.dialog:
--------------------------------------------------------------------------------
1 | {
2 | "$kind": "Microsoft.MultiLanguageRecognizer",
3 | "id": "LUIS_GPTVirtualAssistant",
4 | "recognizers": {}
5 | }
6 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/GPTVirtualAssistant.botproj:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/microsoft/BotFramework-Composer/main/Composer/packages/server/schemas/botproject.schema",
3 | "name": "GPTVirtualAssistant",
4 | "skills": {}
5 | }
--------------------------------------------------------------------------------
/GPTVirtualAssistant/recognizers/GPTVirtualAssistant.en-us.lu.dialog:
--------------------------------------------------------------------------------
1 | {
2 | "$kind": "Microsoft.LuisRecognizer",
3 | "id": "LUIS_GPTVirtualAssistant",
4 | "applicationId": "=settings.luis.GPTVirtualAssistant_en_us_lu.appId",
5 | "version": "=settings.luis.GPTVirtualAssistant_en_us_lu.version",
6 | "endpoint": "=settings.luis.endpoint",
7 | "endpointKey": "=settings.luis.endpointKey"
8 | }
9 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/Nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SUPPORT.md:
--------------------------------------------------------------------------------
1 | # Support
2 |
3 | ## How to file issues and get help
4 |
5 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing
6 | issues before filing new issues to avoid duplicates. For new issues, file your bug or
7 | feature request as a new Issue.
8 |
9 | ## Microsoft Support Policy
10 |
11 | Support for this project is limited to the resources listed above.
12 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/scripts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "azure_provision",
3 | "version": "1.0.0",
4 | "description": "provision to azure cloud",
5 | "main": "provisionComposer.js",
6 | "license": "MIT",
7 | "scripts": {
8 | "start": "node provisionComposer.js"
9 | },
10 | "dependencies": {
11 | "@azure/arm-appinsights": "^2.1.0",
12 | "@azure/arm-botservice": "^3.1.0",
13 | "@azure/arm-resources": "^2.1.0",
14 | "@azure/graph": "^5.0.1",
15 | "@azure/ms-rest-nodeauth": "^3.0.3",
16 | "@types/fs-extra": "^8.1.0",
17 | "chalk": "^4.0.0",
18 | "fs-extra": "^8.1.0",
19 | "minimist": "^1.2.5",
20 | "ora": "^4.0.4",
21 | "request-promise": "^4.2.5"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/language-generation/en-us/GPTVirtualAssistant.en-us.lg:
--------------------------------------------------------------------------------
1 | [import](common.lg)
2 |
3 | # SendActivity_Greeting()
4 | [Activity
5 | Text = ${SendActivity_Greeting_text()}
6 | ]
7 |
8 | # SendActivity_Greeting_text()
9 | - Welcome to your bot.
10 |
11 | # SendActivity_DidNotUnderstand()
12 | [Activity
13 | Text = ${SendActivity_DidNotUnderstand_text()}
14 | ]
15 |
16 | # SendActivity_DidNotUnderstand_text()
17 | - Sorry, I didn't get that.
18 | # SendActivity_4mZVbC()
19 | [Activity
20 | Text = ${SendActivity_4mZVbC_text()}
21 | ]
22 |
23 | # SendActivity_N4sj6t()
24 | [Activity
25 | Text = ${SendActivity_N4sj6t_text()}
26 | ]
27 |
28 | # SendActivity_HUzaKb()
29 | [Activity
30 | Text = ${SendActivity_HUzaKb_text()}
31 | ]
32 |
33 | # SendActivity_HUzaKb_text()
34 | - ${conversation.context.gpt_response.content.choices[0].text}
35 | # SendActivity_4mZVbC_text()
36 | - Resetting conversation.
37 | # SendActivity_N4sj6t_text()
38 | - Setting new prompt.
--------------------------------------------------------------------------------
/GPTVirtualAssistant/GPTVirtualAssistant.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 | OutOfProcess
6 | 88592b1b-3b29-4a1c-99d5-cf2dc4f842bd
7 |
8 |
9 |
10 | PreserveNewest
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/scripts/DeploymentTemplates/preexisting-rg-parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3 | "contentVersion": "1.0.0.0",
4 | "parameters": {
5 | "appId": {
6 | "value": ""
7 | },
8 | "appSecret": {
9 | "value": ""
10 | },
11 | "botId": {
12 | "value": ""
13 | },
14 | "botSku": {
15 | "value": ""
16 | },
17 | "newAppServicePlanName": {
18 | "value": ""
19 | },
20 | "newAppServicePlanSku": {
21 | "value": {
22 | "name": "S1",
23 | "tier": "Standard",
24 | "size": "S1",
25 | "family": "S",
26 | "capacity": 1
27 | }
28 | },
29 | "appServicePlanLocation": {
30 | "value": ""
31 | },
32 | "existingAppServicePlan": {
33 | "value": ""
34 | },
35 | "newWebAppName": {
36 | "value": ""
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/GPTVirtualAssistant/scripts/DeploymentTemplates/new-rg-parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3 | "contentVersion": "1.0.0.0",
4 | "parameters": {
5 | "groupLocation": {
6 | "value": ""
7 | },
8 | "groupName": {
9 | "value": ""
10 | },
11 | "appId": {
12 | "value": ""
13 | },
14 | "appSecret": {
15 | "value": ""
16 | },
17 | "botId": {
18 | "value": ""
19 | },
20 | "botSku": {
21 | "value": ""
22 | },
23 | "newAppServicePlanName": {
24 | "value": ""
25 | },
26 | "newAppServicePlanSku": {
27 | "value": {
28 | "name": "S1",
29 | "tier": "Standard",
30 | "size": "S1",
31 | "family": "S",
32 | "capacity": 1
33 | }
34 | },
35 | "newAppServicePlanLocation": {
36 | "value": ""
37 | },
38 | "newWebAppName": {
39 | "value": ""
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30503.244
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GPTVirtualAssistant", "GPTVirtualAssistant\GPTVirtualAssistant.csproj", "{59188C21-2D56-4E8E-B2D2-64BFD955FC6B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {59188C21-2D56-4E8E-B2D2-64BFD955FC6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {59188C21-2D56-4E8E-B2D2-64BFD955FC6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {59188C21-2D56-4E8E-B2D2-64BFD955FC6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {59188C21-2D56-4E8E-B2D2-64BFD955FC6B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {60EC00FC-40B2-47AF-9965-4389E1EC29F2}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/schemas/update-schema.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | SCHEMA_FILE=sdk.schema
3 | UISCHEMA_FILE=sdk.uischema
4 | BACKUP_SCHEMA_FILE=sdk-backup.schema
5 | BACKUP_UISCHEMA_FILE=sdk-backup.uischema
6 |
7 | while [ $# -gt 0 ]; do
8 | if [[ $1 == *"-"* ]]; then
9 | param="${1/-/}"
10 | declare $param="$2"
11 | fi
12 | shift
13 | done
14 |
15 | echo "Running schema merge."
16 | [ -f "$SCHEMA_FILE" ] && mv "./$SCHEMA_FILE" "./$BACKUP_SCHEMA_FILE"
17 | [ -f "$UISCHEMA_FILE" ] && mv "./$UISCHEMA_FILE" "./$BACKUP_UISCHEMA_FILE"
18 |
19 | bf dialog:merge "*.schema" "!**/sdk-backup.schema" "*.uischema" "!**/sdk-backup.uischema" "!**/sdk.override.uischema" "!**/generated" "../*.csproj" "../package.json" -o $SCHEMA_FILE
20 |
21 | if [ -f "$SCHEMA_FILE" ]; then
22 | rm -rf "./$BACKUP_SCHEMA_FILE"
23 | rm -rf "./$BACKUP_UISCHEMA_FILE"
24 | echo "Schema merged succesfully."
25 | [ -f "$SCHEMA_FILE" ] && echo " Schema: $SCHEMA_FILE"
26 | [ -f "$UISCHEMA_FILE" ] && echo " UI Schema: $UISCHEMA_FILE"
27 | else
28 | echo "Schema merge failed. Restoring previous versions."
29 | [ -f "$BACKUP_SCHEMA_FILE" ] && mv "./$BACKUP_SCHEMA_FILE" "./$SCHEMA_FILE"
30 | [ -f "$BACKUP_UISCHEMA_FILE" ] && mv "./$BACKUP_UISCHEMA_FILE" "./$UISCHEMA_FILE"
31 | fi
32 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Extensions;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.Hosting;
6 |
7 | namespace GPTVirtualAssistant
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IHostBuilder CreateHostBuilder(string[] args) =>
17 | Host.CreateDefaultBuilder(args)
18 | .ConfigureAppConfiguration((hostingContext, builder) =>
19 | {
20 | var applicationRoot = AppDomain.CurrentDomain.BaseDirectory;
21 | var environmentName = hostingContext.HostingEnvironment.EnvironmentName;
22 | var settingsDirectory = "settings";
23 |
24 | builder.AddBotRuntimeConfiguration(applicationRoot, settingsDirectory, environmentName);
25 |
26 | builder.AddCommandLine(args);
27 | })
28 | .ConfigureWebHostDefaults(webBuilder =>
29 | {
30 | webBuilder.UseStartup();
31 | });
32 | }
33 | }
--------------------------------------------------------------------------------
/GPTVirtualAssistant/schemas/update-schema.ps1:
--------------------------------------------------------------------------------
1 | $SCHEMA_FILE="sdk.schema"
2 | $UISCHEMA_FILE="sdk.uischema"
3 | $BACKUP_SCHEMA_FILE="sdk-backup.schema"
4 | $BACKUP_UISCHEMA_FILE="sdk-backup.uischema"
5 |
6 | Write-Host "Running schema merge."
7 |
8 | if (Test-Path $SCHEMA_FILE -PathType leaf) { Move-Item -Force -Path $SCHEMA_FILE -Destination $BACKUP_SCHEMA_FILE }
9 | if (Test-Path $UISCHEMA_FILE -PathType leaf) { Move-Item -Force -Path $UISCHEMA_FILE -Destination $BACKUP_UISCHEMA_FILE }
10 |
11 | bf dialog:merge "*.schema" "!**/sdk-backup.schema" "*.uischema" "!**/sdk-backup.uischema" "!**/sdk.override.uischema" "!**/generated" "../*.csproj" "../package.json" -o $SCHEMA_FILE
12 |
13 | if (Test-Path $SCHEMA_FILE -PathType leaf)
14 | {
15 | if (Test-Path $BACKUP_SCHEMA_FILE -PathType leaf) { Remove-Item -Force -Path $BACKUP_SCHEMA_FILE }
16 | if (Test-Path $BACKUP_UISCHEMA_FILE -PathType leaf) { Remove-Item -Force -Path $BACKUP_UISCHEMA_FILE }
17 |
18 | Write-Host "Schema merged succesfully."
19 | if (Test-Path $SCHEMA_FILE -PathType leaf) { Write-Host " Schema: $SCHEMA_FILE" }
20 | if (Test-Path $UISCHEMA_FILE -PathType leaf) { Write-Host " UI Schema: $UISCHEMA_FILE" }
21 | }
22 | else
23 | {
24 | Write-Host "Schema merge failed. Restoring previous versions."
25 | if (Test-Path $BACKUP_SCHEMA_FILE -PathType leaf) { Move-Item -Force -Path $BACKUP_SCHEMA_FILE -Destination $SCHEMA_FILE }
26 | if (Test-Path $BACKUP_UISCHEMA_FILE -PathType leaf) { Move-Item -Force -Path $BACKUP_UISCHEMA_FILE -Destination $UISCHEMA_FILE }
27 | }
28 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/settings/appsettings.example.json:
--------------------------------------------------------------------------------
1 | {
2 | "openai": {
3 | "account": "***",
4 | "deployment": "***",
5 | "apikey": "***",
6 | "max_messages": 10
7 | },
8 | "customFunctions": [],
9 | "defaultLanguage": "en-us",
10 | "defaultLocale": "en-us",
11 | "importedLibraries": [],
12 | "languages": [
13 | "en-us"
14 | ],
15 | "Logging": {
16 | "LogLevel": {
17 | "Default": "Information",
18 | "Microsoft": "Warning",
19 | "Microsoft.Hosting.Lifetime": "Information"
20 | }
21 | },
22 | "luFeatures": {
23 | "enableCompositeEntities": true,
24 | "enableListEntities": true,
25 | "enableMLEntities": true,
26 | "enablePattern": true,
27 | "enablePhraseLists": true,
28 | "enablePrebuiltEntities": true,
29 | "enableRegexEntities": true
30 | },
31 | "luis": {
32 | "authoringEndpoint": "",
33 | "authoringRegion": "",
34 | "defaultLanguage": "en-us",
35 | "endpoint": "",
36 | "environment": "composer",
37 | "name": "GPTVirtualAssistant"
38 | },
39 | "MicrosoftAppId": "",
40 | "publishTargets": [],
41 | "qna": {
42 | "hostname": "",
43 | "knowledgebaseid": "",
44 | "qnaRegion": "westus"
45 | },
46 | "runtime": {
47 | "command": "dotnet run --project GPTVirtualAssistant.csproj",
48 | "customRuntime": true,
49 | "key": "adaptive-runtime-dotnet-webapp",
50 | "path": "../"
51 | },
52 | "runtimeSettings": {
53 | "adapters": [],
54 | "features": {
55 | "removeRecipientMentions": false,
56 | "showTyping": false,
57 | "traceTranscript": false,
58 | "useInspection": false,
59 | "setSpeak": {
60 | "voiceFontName": "en-US-JennyNeural",
61 | "fallbackToTextForSpeechIfEmpty": true
62 | }
63 | },
64 | "components": [],
65 | "skills": {
66 | "allowedCallers": []
67 | },
68 | "storage": "",
69 | "telemetry": {
70 | "logActivities": true,
71 | "logPersonalInformation": false,
72 | "options": {
73 | "connectionString": ""
74 | }
75 | }
76 | },
77 | "skillConfiguration": {},
78 | "skillHostEndpoint": "http://localhost:3980/api/skills"
79 | }
--------------------------------------------------------------------------------
/GPTVirtualAssistant/README.md:
--------------------------------------------------------------------------------
1 | # Welcome to your new bot
2 |
3 | This bot project was created using the Empty Bot template, and contains a minimal set of files necessary to have a working bot.
4 |
5 | ## Next steps
6 |
7 | ### Start building your bot
8 |
9 | Composer can help guide you through getting started building your bot. From your bot settings page (the wrench icon on the left navigation rail), click on the rocket-ship icon on the top right for some quick navigation links.
10 |
11 | Another great resource if you're just getting started is the **[guided tutorial](https://docs.microsoft.com/en-us/composer/tutorial/tutorial-introduction)** in our documentation.
12 |
13 | ### Connect with your users
14 |
15 | Your bot comes pre-configured to connect to our Web Chat and DirectLine channels, but there are many more places you can connect your bot to - including Microsoft Teams, Telephony, DirectLine Speech, Slack, Facebook, Outlook and more. Check out all of the places you can connect to on the bot settings page.
16 |
17 | ### Publish your bot to Azure from Composer
18 |
19 | Composer can help you provision the Azure resources necessary for your bot, and publish your bot to them. To get started, create a publishing profile from your bot settings page in Composer (the wrench icon on the left navigation rail). Make sure you only provision the optional Azure resources you need!
20 |
21 | ### Extend your bot with packages
22 |
23 | From Package Manager in Composer you can find useful packages to help add additional pre-built functionality you can add to your bot - everything from simple dialogs & custom actions for working with specific scenarios to custom adapters for connecting your bot to users on clients like Facebook or Slack.
24 |
25 | ### Extend your bot with code
26 |
27 | You can also extend your bot with code - simply open up the folder that was generated for you in the location you chose during the creation process with your favorite IDE (like Visual Studio). You can do things like create custom actions that can be used during dialog flows, create custom middleware to pre-process (or post-process) messages, and more. See [our documentation](https://aka.ms/bf-extend-with-code) for more information.
28 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/Controllers/SkillController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Microsoft.Bot.Builder;
5 | using Microsoft.Bot.Builder.Integration.AspNet.Core;
6 | using Microsoft.Bot.Schema;
7 | using Microsoft.Extensions.Logging;
8 |
9 | namespace GPTVirtualAssistant.Controllers
10 | {
11 | ///
12 | /// A controller that handles skill replies to the bot.
13 | ///
14 | [ApiController]
15 | [Route("api/skills")]
16 | public class SkillController : ChannelServiceController
17 | {
18 | private readonly ILogger _logger;
19 |
20 | public SkillController(ChannelServiceHandlerBase handler, ILogger logger)
21 | : base(handler)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | public override Task ReplyToActivityAsync(string conversationId, string activityId, Activity activity)
27 | {
28 | try
29 | {
30 | if (_logger.IsEnabled(LogLevel.Debug))
31 | {
32 | _logger.LogDebug($"ReplyToActivityAsync: conversationId={conversationId}, activityId={activityId}");
33 | }
34 |
35 | return base.ReplyToActivityAsync(conversationId, activityId, activity);
36 | }
37 | catch (Exception ex)
38 | {
39 | _logger.LogError(ex, $"ReplyToActivityAsync: {ex}");
40 | throw;
41 | }
42 | }
43 |
44 | public override Task SendToConversationAsync(string conversationId, Activity activity)
45 | {
46 | try
47 | {
48 | if (_logger.IsEnabled(LogLevel.Debug))
49 | {
50 | _logger.LogDebug($"SendToConversationAsync: conversationId={conversationId}");
51 | }
52 |
53 | return base.SendToConversationAsync(conversationId, activity);
54 | }
55 | catch (Exception ex)
56 | {
57 | _logger.LogError(ex, $"SendToConversationAsync: {ex}");
58 | throw;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.StaticFiles;
4 | using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Extensions;
5 | using Microsoft.Bot.Builder.Integration.AspNet.Core;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.Hosting;
9 |
10 | namespace GPTVirtualAssistant
11 | {
12 | public class Startup
13 | {
14 | public Startup(IConfiguration configuration)
15 | {
16 | Configuration = configuration;
17 | }
18 |
19 | public IConfiguration Configuration { get; }
20 |
21 | // This method gets called by the runtime. Use this method to add services to the container.
22 | public void ConfigureServices(IServiceCollection services)
23 | {
24 | services.AddControllers().AddNewtonsoftJson(options => {
25 | options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth;
26 | });
27 | services.AddBotRuntime(Configuration);
28 | }
29 |
30 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
31 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
32 | {
33 | if (env.IsDevelopment())
34 | {
35 | app.UseDeveloperExceptionPage();
36 | }
37 |
38 | app.UseDefaultFiles();
39 |
40 | // Set up custom content types - associating file extension to MIME type.
41 | var provider = new FileExtensionContentTypeProvider();
42 | provider.Mappings[".lu"] = "application/vnd.microsoft.lu";
43 | provider.Mappings[".qna"] = "application/vnd.microsoft.qna";
44 |
45 | // Expose static files in manifests folder for skill scenarios.
46 | app.UseStaticFiles(new StaticFileOptions
47 | {
48 | ContentTypeProvider = provider
49 | });
50 | app.UseWebSockets();
51 | app.UseRouting();
52 | app.UseAuthorization();
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapControllers();
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AOAI Virtual Assistant Accelerator
2 |
3 | Quickly get started with virtual assistants using Azure OpenAI
4 |
5 | ## Setup
6 |
7 | - Set up an Azure OpenAI resource. You may need to request access if your subscription is not enabled yet
8 | 
9 | - Create a GPT 3.5 or GPT 4 deployment
10 | 
11 | - Clone the repository:
12 |
13 | `git clone https://github.com/microsoft/aoai-virtual-assistant.git`
14 |
15 | - Create the app settings file at `./GPTVirtualAssistant/settings/appsettings.json`. Use the example file provided as a template. You will need to fill in the information in the "openai" field.
16 | 
17 | - Open the project in Bot Framework Composer
18 | 
19 | - [Publish your bot](https://learn.microsoft.com/en-us/composer/how-to-publish-bot?tabs=v2x)
20 | 
21 | - [Configure end-user channels](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-manage-channels?view=azure-bot-service-4.0)
22 | 
23 |
24 | ## Contributing
25 |
26 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
27 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
28 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
29 |
30 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
31 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
32 | provided by the bot. You will only need to do this once across all repos using our CLA.
33 |
34 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
35 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
36 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
37 |
38 | ## Trademarks
39 |
40 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
41 | trademarks or logos is subject to and must follow
42 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
43 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
44 | Any use of third-party trademarks or logos are subject to those third-party's policies.
45 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/Controllers/BotController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Bot.Builder;
7 | using Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime.Settings;
8 | using Microsoft.Bot.Builder.Integration.AspNet.Core;
9 | using Microsoft.Extensions.Configuration;
10 | using Microsoft.Extensions.Logging;
11 |
12 | namespace GPTVirtualAssistant.Controllers
13 | {
14 | // This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
15 | // implementation at runtime. Multiple different IBot implementations running at different endpoints can be
16 | // achieved by specifying a more specific type for the bot constructor argument.
17 | [ApiController]
18 | public class BotController : ControllerBase
19 | {
20 | private readonly Dictionary _adapters = new Dictionary();
21 | private readonly IBot _bot;
22 | private readonly ILogger _logger;
23 |
24 | public BotController(
25 | IConfiguration configuration,
26 | IEnumerable adapters,
27 | IBot bot,
28 | ILogger logger)
29 | {
30 | _bot = bot ?? throw new ArgumentNullException(nameof(bot));
31 | _logger = logger;
32 |
33 | var adapterSettings = configuration.GetSection(AdapterSettings.AdapterSettingsKey).Get>() ?? new List();
34 | adapterSettings.Add(AdapterSettings.CoreBotAdapterSettings);
35 |
36 | foreach (var adapter in adapters ?? throw new ArgumentNullException(nameof(adapters)))
37 | {
38 | var settings = adapterSettings.FirstOrDefault(s => s.Enabled && s.Type == adapter.GetType().FullName);
39 |
40 | if (settings != null)
41 | {
42 | _adapters.Add(settings.Route, adapter);
43 | }
44 | }
45 | }
46 |
47 | [HttpPost]
48 | [HttpGet]
49 | [Route("api/{route}")]
50 | public async Task PostAsync(string route)
51 | {
52 | if (string.IsNullOrEmpty(route))
53 | {
54 | _logger.LogError($"PostAsync: No route provided.");
55 | throw new ArgumentNullException(nameof(route));
56 | }
57 |
58 | if (_adapters.TryGetValue(route, out IBotFrameworkHttpAdapter adapter))
59 | {
60 | if (_logger.IsEnabled(LogLevel.Debug))
61 | {
62 | _logger.LogInformation($"PostAsync: routed '{route}' to {adapter.GetType().Name}");
63 | }
64 |
65 | // Delegate the processing of the HTTP POST to the appropriate adapter.
66 | // The adapter will invoke the bot.
67 | await adapter.ProcessAsync(Request, Response, _bot).ConfigureAwait(false);
68 | }
69 | else
70 | {
71 | _logger.LogError($"PostAsync: No adapter registered and enabled for route {route}.");
72 | throw new KeyNotFoundException($"No adapter registered and enabled for route {route}.");
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/GPTVirtualAssistant.dialog:
--------------------------------------------------------------------------------
1 | {
2 | "$kind": "Microsoft.AdaptiveDialog",
3 | "$designer": {
4 | "name": "GPTVirtualAssistant",
5 | "description": "",
6 | "id": "A79tBe"
7 | },
8 | "autoEndDialog": true,
9 | "defaultResultProperty": "dialog.result",
10 | "triggers": [
11 | {
12 | "$kind": "Microsoft.OnMessageActivity",
13 | "$designer": {
14 | "id": "qHBDzl",
15 | "name": "Message received (Message received activity)"
16 | },
17 | "actions": [
18 | {
19 | "$kind": "Microsoft.SetProperty",
20 | "$designer": {
21 | "id": "ApoolC"
22 | },
23 | "property": "conversation.context.messages",
24 | "value": "=coalesce(conversation.context.messages, [])"
25 | },
26 | {
27 | "$kind": "Microsoft.IfCondition",
28 | "$designer": {
29 | "id": "iSuaOv"
30 | },
31 | "condition": "=count(conversation.context.messages) > settings.openai.max_messages",
32 | "actions": [
33 | {
34 | "$kind": "Microsoft.SetProperty",
35 | "$designer": {
36 | "id": "5nfF5B"
37 | },
38 | "property": "conversation.context.messages",
39 | "value": "=subArray(conversation.context.messages, 2, count(conversation.context.messages))"
40 | }
41 | ]
42 | },
43 | {
44 | "$kind": "Microsoft.SwitchCondition",
45 | "$designer": {
46 | "id": "PXgnBj"
47 | },
48 | "cases": [
49 | {
50 | "value": "RESET_CONVERSATION",
51 | "actions": [
52 | {
53 | "$kind": "Microsoft.SetProperty",
54 | "$designer": {
55 | "id": "XVuI3J"
56 | },
57 | "property": "conversation.context.messages",
58 | "value": "=[]"
59 | },
60 | {
61 | "$kind": "Microsoft.SendActivity",
62 | "$designer": {
63 | "id": "4mZVbC"
64 | },
65 | "activity": "${SendActivity_4mZVbC()}"
66 | },
67 | {
68 | "$kind": "Microsoft.EndDialog",
69 | "$designer": {
70 | "id": "aixin3"
71 | }
72 | }
73 | ]
74 | },
75 | {
76 | "value": "SET_PROMPT",
77 | "actions": [
78 | {
79 | "$kind": "Microsoft.SendActivity",
80 | "$designer": {
81 | "id": "N4sj6t"
82 | },
83 | "activity": "${SendActivity_N4sj6t()}"
84 | },
85 | {
86 | "$kind": "Microsoft.SetProperty",
87 | "$designer": {
88 | "id": "KWhTOA"
89 | },
90 | "property": "conversation.context.gpt_prompt",
91 | "value": "='<|im_start|>system\\n' + replace(turn.activity.text, 'SET_PROMPT ', '') + '\\n\\n\\n<|im_end|>'"
92 | },
93 | {
94 | "$kind": "Microsoft.SetProperty",
95 | "$designer": {
96 | "id": "G2x7bO"
97 | },
98 | "property": "conversation.context.messages",
99 | "value": "=[]"
100 | }
101 | ]
102 | }
103 | ],
104 | "default": [
105 | {
106 | "$kind": "Microsoft.EditArray",
107 | "$designer": {
108 | "id": "0de1xo"
109 | },
110 | "changeType": "push",
111 | "itemsProperty": "conversation.context.messages",
112 | "value": "='<|im_start|>user\\n' + turn.activity.text + '\\n\\n\\n<|im_end|>'"
113 | },
114 | {
115 | "$kind": "Microsoft.HttpRequest",
116 | "$designer": {
117 | "id": "xGDgaw"
118 | },
119 | "resultProperty": "conversation.context.gpt_response",
120 | "method": "POST",
121 | "body": "={ \"prompt\": conversation.context.gpt_prompt + '\\n' + join(conversation.context.messages, '') + '\\n<|im_start|>assistant ', \"max_tokens\": 800, \"stop\": [\"<|im_end|>\"], \"frequency_penalty\": 0, \"presence_penalty\": 0, \"top_p\": 0.95, \"temperature\": 0.7 }",
122 | "contentType": "application/json",
123 | "responseType": "json",
124 | "headers": {
125 | "api-key": "=settings.openai.apikey"
126 | },
127 | "url": "=\"https://\"+ settings.openai.account + \".openai.azure.com/openai/deployments/\"+ settings.openai.deployment + \"/completions?api-version=2022-12-01\""
128 | },
129 | {
130 | "$kind": "Microsoft.EditArray",
131 | "$designer": {
132 | "id": "ZQ8D95"
133 | },
134 | "changeType": "push",
135 | "itemsProperty": "conversation.context.messages",
136 | "value": "='<|im_start|>assistant\\n' + conversation.context.gpt_response.content.choices[0].text + '\\n\\n\\n<|im_end|>\\n'"
137 | },
138 | {
139 | "$kind": "Microsoft.SendActivity",
140 | "$designer": {
141 | "id": "HUzaKb"
142 | },
143 | "activity": "${SendActivity_HUzaKb()}"
144 | }
145 | ],
146 | "condition": "split(turn.activity.text, ' ')[0]"
147 | }
148 | ]
149 | }
150 | ],
151 | "generator": "GPTVirtualAssistant.lg",
152 | "id": "GPTVirtualAssistant",
153 | "recognizer": "GPTVirtualAssistant.lu.qna"
154 | }
155 |
--------------------------------------------------------------------------------
/GPTVirtualAssistant/media/create-azure-resource-command-line.png:
--------------------------------------------------------------------------------
1 | �PNG
2 |
3 |
IHDR Z ��� sRGB ��� gAMA ���a pHYs � ��+ �IDATx^�=�$י����V0#��r�5�`A FK ɉ`̠�h�(�Md4�&R�ש@��-%���c6����X�_��M���V8�
2h�t��U��{��TWu߿�����N����}���ϝ;WdB!����B!�+#�B!��9
4 | E�����$�>|�r��W�C!�3�B�?������+�m�'?�|�}�/"~̛
�JPes�����!�8
L�20@�L^�d;ײl�N�}���}f���ӀE�=�C�������?�
5 | ���wi��6����2�o�����w('=�Bqp�<\��,;���Ӡ��{P>,��?ğ��1�(��l�ry����-|�_��-�c�X<�����_��/�\'���?�,���p
��.�{���~V�[��1����K{W�)�k�z~�ˏK�yܖ�]�o�_{>�lH��z�0V� ����C�G!Nӝ����v�������K4���p(�c4��������q
�y4�oC0�A��>>'��wb�����~
6 | ~�.�w�^��_���yV���]\˿�=�YR�=H����_B�0yןɳ9���G�}[O�#~[ߖ��OC���R�$�<�^�y�}��\w>�_@�2�.��{H�{W����U�{e\ �3��������/a�m��3��t��m)������a
7 | �=���_=\>M�G!�
8 | ��������a��B/���z�Z�A�`�g9��/���C`��0^�H@�'�eD�c~�{�����n�Ȼp�arh|��4�Z*�����)���[��G;����r�b���;6�������w�
����~<�<@^�n�ߠ�|b�G!����_�8�����
�7^
9 | ��7�e��P��E�;o����Z�h����� P��'O������<µ���<�S*���P lK��#����8�+˶�̸0~�B�j�?`���
10 | 3��:��pB��R(8tLaR�ᓺ8�=n��>[���m�:�C��zЯ�/��(��A� +�)�[8ߊ��N�-6��'�Z6/��_���ro�F�����X5�*��(�����k�T�Q~uX�܄B,p
11 | ��G�\.6[$X��3����̓�M��ӗ��l�3#�;�V��^t��^'�� 0_L`����{�����)�TӔE����H"t��Q�y^���������F<����������ӫ�7�߀?���B��m�,�8uB�M����p�s%��^*�j�p�sۅ@jDNh�w����5ƞ��s�c�C~��~��;W��<�/ȏz�A�ڠ�V��Wa�Cy�aՖ����"�Z7q��[���et�і�賤͝
12 | V����~[�Yc� ��;���� ��|[�I!�v��uB�M �`-���4P5g�ﶭ���RH���Yw��B���������0��9���~!��h���ؐ�X�
13 | ���!�8=H�B!�`4�!�B��H�B!�`4�q�Xe��Y��YҰ��8���4�"����_���1�BQ?�n
r���{�>��ڰ�v��q���I��W�����Y�.�M��Bі�U��-e�)B��`U�bB����O��. *���45�rR�I��ހ���_�\c0�E����a69�X�.��Eٹ�N�2a��Ab�保$Z->�}B�����^X�S�R9��1EϐJ�m?����z��Q�z/��������o#ܺ9���H��=tˮ-NS�m�]�}`�Fa����Ʈ��o����.���8,����r7��/���6B1ޛ���\�O����(Xy���3���F�!G�OݿFh>{�S4��e�᷅� ���w�^������?��)n�qfЌN-���+-�w�4:�H#MS�lBЖ ����8}}��.�!����8Vh�%�d}
S���2���U>�Ubrsw��B�����?6mQV!��j������K�$�a��[�$�熞�즿 �"� \g�:�7�B��]P0TƸh]�E}�#�7���*�����$˽����h���2�4���\>]�R�+Lw��{PvR��
14 | !��*�,�4f�r4Ѓ�����z�N��*1N��Cꌔ \!�%E��w��x�K���X����>}��Z�,�P�����t����S(�虻���t�!��Ǫ�J�p�+��orO�=v��>[������C���`_�
�tF�!�.�;��U��������#)M���p=���Q��lrO,�ڪ=F��6w���O��י�s�[!NI�1�S(�<��r�C��9�p��������%!g��R�؊�P|�0#B>��V8���� :�i�9ª�H"t�����O��?�^!�H�n�~R�a�qg�� ���A�;�}�_�+X)�}���k���՛=(�k�}����7|�6�B%��+CB��W�;�]䆭�n��J?ܥQ�!0���Y�N����۠�uhe���[-܀0l����
��=�a�YT~>ɲ���\z���=P�8j�[��6��<����r7���o=o��X��v���vy!��#=��b���h��BqZX�
15 | !�B��
16 | !�BFSB!��F(�B1)B!�̙P(��B� !��c��gE�I��4�W6+��YS!�le���d;��&��;us���B�9�.;
�GL�Q*�T�{�3��tp��iVd�,�NK