From 3b57752687b93d6a6d48deb3bed4599071090e50 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:11:13 -0800 Subject: [PATCH 01/87] Update README.md --- getting-started/MIGRATION/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/MIGRATION/README.md b/getting-started/MIGRATION/README.md index 243710fd1..b7818b029 100644 --- a/getting-started/MIGRATION/README.md +++ b/getting-started/MIGRATION/README.md @@ -8,7 +8,7 @@ ___ ### Why you should migrate to the Teams AI library -Is your Teams App currently build using the [BotFramework (BF) SDK](https://github.com/microsoft/botframework-sdk)? If so you should migrate it to the Teams AI library. +Is your Teams App currently built using the [BotFramework (BF) SDK](https://github.com/microsoft/botframework-sdk)? If so you should migrate it to the Teams AI library. Here are a few reasons why: From 57559dd9f1614008404e60125254823c8ca83fbe Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Mon, 15 Jan 2024 13:01:33 -0800 Subject: [PATCH 02/87] application concept --- getting-started/CONCEPTS/AI-MODULE.md | 0 getting-started/CONCEPTS/APPLICATION.md | 64 +++++++++++++++++++++++++ getting-started/MIGRATION/DOTNET.md | 14 +++--- getting-started/MIGRATION/JS.md | 18 +++---- 4 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 getting-started/CONCEPTS/AI-MODULE.md create mode 100644 getting-started/CONCEPTS/APPLICATION.md diff --git a/getting-started/CONCEPTS/AI-MODULE.md b/getting-started/CONCEPTS/AI-MODULE.md new file mode 100644 index 000000000..e69de29bb diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md new file mode 100644 index 000000000..5d46a96f7 --- /dev/null +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -0,0 +1,64 @@ +# The `Application` class + +The `Application` class encapsulates all the business logic for the application and it comprises of two major components, the Activity Handler system and the AI module. + + +## The Activity Handler system + +The activity handler system is the set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. The method determines the incomming activity for which the callback would be triggered. + +Here's an example of registering a route handler that will trigger when the the user sends *"/login"* to the bot: + +**JS** +```js +// Listen for user to say '/login'. +app.message('/login', async (context: TurnContext, state: TurnState) => { + await context.sendActivity(`Starting sign in flow.`); + // start signin flow +}); +``` + +**C#** +```cs +// Listen for user to say '/login'. +app.OnMessage("/login", async (ITurnContext turnContext, TurnState turnState, CancellationToken cancellationToken) => +{ + await turnContext.SendActivityAsync("Starting sign in flow.", cancellationToken: cancellationToken); + // start signin flow +}); +``` +> The `turnContext` and `turnState` parameters are present in every route handler. To learn more about them see [TURNS](TURNS.md). +> The `message` and `OnMessage` methods are referred to as activity or *route registration* method. + +The `Application` groups the route registration methods based on the specific feature groups: + + +| **Feature** | **Description** | +|-------------------|-----------------------------------------------------------------------------------------| +| Task Modules | route registration methods for task module related activities like `task/fetch`. | +| Message Extension | route registration methods for message extension activities like `composeExtension/query`. | +| Meetings | route registration methods for meeting activites like `application/vnd.microsoft.meetingStart`. | +| AdaptiveCards | route registration methods for adaptive card activities like `adaptiveCard/action`. | +| General | route registration methods for generic activites like `message`. | + +> To see all the route registration methods supported, see the migration docs ([JS](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/JS.md#activity-handler-methods)/[C#](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md#activity-handler-methods)). + +In general, the activity handler system is all that is needed to have a functional bot or message extension. + +## The AI Module +The AI module is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI Module](.AI-MODULE.md). + +## The Routing Logic + +When an incoming activity reaches the server, the bot adapter handles the necessary authentication and creates a turn context object that encapsulates the activity details. It then calls `Application`'s main method (`run()` in Javscript. `OnTurnAsync()` in C#). It is called for every incomming activity. Here's what happens: + +1. If configured in the application options, pulses of the `Typing` activity are sent to the user. +2. If configured in the application options, the @mention is removed from the incoming message activity. +3. The turn state is loaded using the configured turn state factory. +4. If user authentication is configured, then attemp to sign the user in. If there user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. +5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. +6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. +7. If no route is triggered, the incomming activity is a message, and the AI module is configured, then it is invoked by calling the `AI.run()` method. +8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. + +> Note: To learn about what a *turn* is, see [TURNS](TURNS.md). \ No newline at end of file diff --git a/getting-started/MIGRATION/DOTNET.md b/getting-started/MIGRATION/DOTNET.md index 4c318ac39..26d9e3ad9 100644 --- a/getting-started/MIGRATION/DOTNET.md +++ b/getting-started/MIGRATION/DOTNET.md @@ -126,9 +126,9 @@ var applicationBuilder = new ApplicationBuilder() Application app = applicationBuilder.Build(); ``` -## 2. Replace the activity handler implementations with specific route handlers +## 2. Replace the activity handler implementations with specific route registration method. -The `EchoBot` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route handler in the `Application` object. Here's a simple example: +The `EchoBot` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route registration method in the `Application` object. Here's a simple example: Given the `EchoBot` implementation: @@ -159,11 +159,11 @@ If your bot derives from `ActivityHandler` or the `TeamsActivityHandler` refer ## Activity Handler Methods -If your bot derives from the `TeamsActivityHandler` refer to the following table to see which method maps to which `Application` route handler. +If your bot derives from the `TeamsActivityHandler` refer to the following table to see which method maps to which `Application` route registration method. #### Invoke Activities -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | | `OnTeamsO365ConnectorCardActionAsync` | `OnO365ConnectorCardAction` (usage: `app.OnO365ConnectorCardAction(...)`) | | `OnTeamsFileConsentAsync` | Either `OnFileConsentAccept` or `OnFileConsentDecline` | @@ -221,7 +221,7 @@ app.OnConversationUpdate(ConversationUpdateEvents.ChannelCreated, async (ITurnCo #### Message Activites -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | -------------------------------- | -------------------------------------------------------- | | `OnMessage` | `OnMessage` (usage: `app.OnMessage(...)`) | | `OnTeamsMessageEditAsync` | `OnMessageEdit` | @@ -232,7 +232,7 @@ app.OnConversationUpdate(ConversationUpdateEvents.ChannelCreated, async (ITurnCo #### Meeting Activities -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | -------------------------------------- | ------------------------------------------------------- | | `OnTeamsMeetingStartAsync` | `Meetings.OnStart` (usage: `app.Meetings.OnStart(...)`) | | `OnTeamsMeetingEndAsync` | `Meetings.OnEnd` | @@ -241,4 +241,4 @@ app.OnConversationUpdate(ConversationUpdateEvents.ChannelCreated, async (ITurnCo #### Other Activities -If there are activities for which there isn't a corresponding route handler, you can use the generic route handler `Application.OnActivity` and specify a custom selector function given the activity object as input. +If there are activities for which there isn't a corresponding route registration method, you can use the generic route registration method `Application.OnActivity` and specify a custom selector function given the activity object as input. diff --git a/getting-started/MIGRATION/JS.md b/getting-started/MIGRATION/JS.md index 793885ef4..4ad2ac6f3 100644 --- a/getting-started/MIGRATION/JS.md +++ b/getting-started/MIGRATION/JS.md @@ -47,9 +47,9 @@ const app = new ApplicationBuilder() .build(); // this internally calls the Application constructor ``` -## 2. Replace the activity handler implementations with specific route handlers +## 2. Replace the activity handler implementations with specific route registration methods -The `BotActivityHandler` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route handler in the `Application` object. Here's a simple example: +The `BotActivityHandler` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route registration method in the `Application` object. Here's a simple example: Given the `BotActivityHandler` implementation: @@ -74,17 +74,17 @@ app.activity(ActivityTypes.Message, async(context: TurnContext, state: TurnState }); ``` -> The `activity` method is refered as a *route handler*. For each method in the `ActivityHandler` or `TeamsActivityHandler` class, there is an equivalent route handler. +> The `activity` method is refered as a *route registration method*. For each method in the `ActivityHandler` or `TeamsActivityHandler` class, there is an equivalent route registration method. -Your existing BF app will probably have different activity handlers implemented. To migrate that over with Teams AI route handlers see the following. +Your existing BF app will probably have different activity handlers implemented. To migrate that over with Teams AI route registration methods see the following. ## Activity Handler Methods -If your bot derives from the `TeamsActivityHandler` refer to the following table to see which method maps to which `Application` route handler. +If your bot derives from the `TeamsActivityHandler` refer to the following table to see which method maps to which `Application` route registration method. ### Invoke Activities -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | | `handleTeamsO365ConnectorCardAction` | `O365ConnectorCardAction` (usage: `app.O365ConnectorCardAction(...)`) | | `handleTeamsFileConsent` | Either `fileConsentAccept` or `fileConsentDecline` | @@ -141,7 +141,7 @@ app.conversationUpdate('channelCreated', (context: TurnContext, state: TurnState ### Message Activites -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | --------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | `OnMessage` | `message` | | `OnTeamsMessageUndelete`, `OnTeamsMessageEdit` & `OnTeamsMessageSoftDelete` | `messageEventUpdate` , the first parameter `event` specifies the activity. | @@ -150,7 +150,7 @@ app.conversationUpdate('channelCreated', (context: TurnContext, state: TurnState ### Meeting Activities -| `TeamsActivityHandler` method | `Application` route handler | +| `TeamsActivityHandler` method | `Application` route registration method | | --------------------------------- | ---------------------------- | | `OnTeamsMeetingStart` | `meetings.start` | | `OnTeamsMeetingEnd` | `meetings.end` | @@ -159,4 +159,4 @@ app.conversationUpdate('channelCreated', (context: TurnContext, state: TurnState ### Other Activities -If there are activities for which there isn't a corresponding route handler, you can use the generic route handler `Application.activity` and specify a custom selector function given the activity object as input. +If there are activities for which there isn't a corresponding route registration method, you can use the generic route registration method `Application.activity` and specify a custom selector function given the activity object as input. From eb2bbfd5cf557ab68423a38f0121589b550c3304 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:02:15 -0800 Subject: [PATCH 03/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 5d46a96f7..20e2f1543 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -1,6 +1,6 @@ # The `Application` class -The `Application` class encapsulates all the business logic for the application and it comprises of two major components, the Activity Handler system and the AI module. +The `Application` class encapsulates all the business logic for of application and it comprises of two major components, the Activity Handler system and the AI module. ## The Activity Handler system @@ -61,4 +61,4 @@ When an incoming activity reaches the server, the bot adapter handles the necess 7. If no route is triggered, the incomming activity is a message, and the AI module is configured, then it is invoked by calling the `AI.run()` method. 8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. -> Note: To learn about what a *turn* is, see [TURNS](TURNS.md). \ No newline at end of file +> Note: To learn about what a *turn* is, see [TURNS](TURNS.md). From e06fd7803a2c24a6a1a739e00d505bdc237e64f8 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:03:08 -0800 Subject: [PATCH 04/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 20e2f1543..7af0d6b14 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -1,9 +1,9 @@ # The `Application` class -The `Application` class encapsulates all the business logic for of application and it comprises of two major components, the Activity Handler system and the AI module. +The `Application` class encapsulates all the business logic for of application and it comprises of two major components, the _Activity Handler System_ and the _AI Module_. -## The Activity Handler system +## The Activity Handler System The activity handler system is the set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. The method determines the incomming activity for which the callback would be triggered. @@ -46,7 +46,7 @@ The `Application` groups the route registration methods based on the specific fe In general, the activity handler system is all that is needed to have a functional bot or message extension. ## The AI Module -The AI module is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI Module](.AI-MODULE.md). +The AI Module is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI Module](.AI-MODULE.md). ## The Routing Logic From ce10884d40a52a50f9d3a76662e61fa9ac70f412 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:04:44 -0800 Subject: [PATCH 05/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 7af0d6b14..ae754861b 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -5,7 +5,7 @@ The `Application` class encapsulates all the business logic for of application a ## The Activity Handler System -The activity handler system is the set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. The method determines the incomming activity for which the callback would be triggered. +The activity handler system is the primary way to implement bot or message extension applicaiton logic. It is a set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. Here's an example of registering a route handler that will trigger when the the user sends *"/login"* to the bot: From 0e0c3de964572935360d0ff3368d26418c8d4781 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:05:17 -0800 Subject: [PATCH 06/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index ae754861b..5bca1d67d 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -7,7 +7,7 @@ The `Application` class encapsulates all the business logic for of application a The activity handler system is the primary way to implement bot or message extension applicaiton logic. It is a set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. -Here's an example of registering a route handler that will trigger when the the user sends *"/login"* to the bot: +Here's an example of registering a route handler that will run when the the user sends *"/login"* to the bot: **JS** ```js From 0f5027a04c7c3113141f114d5cfa7e9221590d67 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:06:24 -0800 Subject: [PATCH 07/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 5bca1d67d..158772cd1 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -35,11 +35,11 @@ The `Application` groups the route registration methods based on the specific fe | **Feature** | **Description** | |-------------------|-----------------------------------------------------------------------------------------| -| Task Modules | route registration methods for task module related activities like `task/fetch`. | -| Message Extension | route registration methods for message extension activities like `composeExtension/query`. | -| Meetings | route registration methods for meeting activites like `application/vnd.microsoft.meetingStart`. | -| AdaptiveCards | route registration methods for adaptive card activities like `adaptiveCard/action`. | -| General | route registration methods for generic activites like `message`. | +| Task Modules | Task module related activities like `task/fetch`. | +| Message Extension | Message extension activities like `composeExtension/query`. | +| Meetings | Meeting activites like `application/vnd.microsoft.meetingStart`. | +| AdaptiveCards | Adaptive card activities like `adaptiveCard/action`. | +| General | Generic activites like `message`. | > To see all the route registration methods supported, see the migration docs ([JS](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/JS.md#activity-handler-methods)/[C#](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md#activity-handler-methods)). From 6afafa495838fb2beef40342a9552665e0af0f48 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:11:22 -0800 Subject: [PATCH 08/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 158772cd1..145b8c555 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -27,8 +27,8 @@ app.OnMessage("/login", async (ITurnContext turnContext, TurnState turnState, Ca // start signin flow }); ``` -> The `turnContext` and `turnState` parameters are present in every route handler. To learn more about them see [TURNS](TURNS.md). > The `message` and `OnMessage` methods are referred to as activity or *route registration* method. +> The `turnContext` and `turnState` parameters are present in every route handler. To learn more about them see [TURNS](TURNS.md). The `Application` groups the route registration methods based on the specific feature groups: @@ -50,7 +50,7 @@ The AI Module is an optional component used to plug in LLM powered experiences l ## The Routing Logic -When an incoming activity reaches the server, the bot adapter handles the necessary authentication and creates a turn context object that encapsulates the activity details. It then calls `Application`'s main method (`run()` in Javscript. `OnTurnAsync()` in C#). It is called for every incomming activity. Here's what happens: +When an incoming activity reaches the server, the bot adapter handles the necessary authentication and creates a turn context object that encapsulates the activity details. Then the `Application`'s main method (`run()` in Javscript. `OnTurnAsync()` in C#) is called. It's logic can be broken down into these eight steps. 1. If configured in the application options, pulses of the `Typing` activity are sent to the user. 2. If configured in the application options, the @mention is removed from the incoming message activity. @@ -61,4 +61,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 7. If no route is triggered, the incomming activity is a message, and the AI module is configured, then it is invoked by calling the `AI.run()` method. 8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. + +> Note: _End the turn_ means that the main method has terminated execution and so the application has completed processing the incomming activity. + > Note: To learn about what a *turn* is, see [TURNS](TURNS.md). From 5cd87b041491272afa90288b3ac19939f515c273 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:12:20 -0800 Subject: [PATCH 09/87] Update README.md --- getting-started/CONCEPTS/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index 5af2fa13b..b78689da6 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -9,3 +9,4 @@ Here you will find short guides on features available in the library. | Name | Description | | --------------------------------------- | ------------------------------------------------- | | [Turn Context and Turn State](TURNS.md) | Explains what the turn context and turn state is. | +| [The Application class](APPLICATION.md) | What the `Application` class is and how it works. | From db62b3b2d5a27080eb333d44739893ee3fc31325 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Mon, 15 Jan 2024 14:15:08 -0800 Subject: [PATCH 10/87] ai module init --- .../Microsoft.TeamsAI/AI/AI.cs | 2 +- .../{AI-MODULE.md => ACTION-PLANNER.md} | 0 getting-started/CONCEPTS/AI-SYSTEM.md | 7 ++ getting-started/CONCEPTS/APPLICATION.md | 8 +- getting-started/CONCEPTS/MODERATOR.md | 43 ++++++++++ getting-started/CONCEPTS/PLANNER.md | 85 +++++++++++++++++++ getting-started/CONCEPTS/TURNS.md | 2 +- js/packages/teams-ai/src/Application.ts | 2 +- 8 files changed, 142 insertions(+), 7 deletions(-) rename getting-started/CONCEPTS/{AI-MODULE.md => ACTION-PLANNER.md} (100%) create mode 100644 getting-started/CONCEPTS/AI-SYSTEM.md create mode 100644 getting-started/CONCEPTS/MODERATOR.md create mode 100644 getting-started/CONCEPTS/PLANNER.md diff --git a/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/AI.cs b/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/AI.cs index e87693f25..f7c74c3e6 100644 --- a/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/AI.cs +++ b/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/AI.cs @@ -138,7 +138,7 @@ public AI RegisterDefaultAction(string name, IActionHandler hand /// /// Import a set of Actions from the given class instance. The functions must have the `Action` attribute. - /// Once these functions are imported, the AI module will have access to these functions. + /// Once these functions are imported, the AI System will have access to these functions. /// /// Instance of a class containing these functions. /// The current instance object. diff --git a/getting-started/CONCEPTS/AI-MODULE.md b/getting-started/CONCEPTS/ACTION-PLANNER.md similarity index 100% rename from getting-started/CONCEPTS/AI-MODULE.md rename to getting-started/CONCEPTS/ACTION-PLANNER.md diff --git a/getting-started/CONCEPTS/AI-SYSTEM.md b/getting-started/CONCEPTS/AI-SYSTEM.md new file mode 100644 index 000000000..249dbb5b4 --- /dev/null +++ b/getting-started/CONCEPTS/AI-SYSTEM.md @@ -0,0 +1,7 @@ +# The AI System + +The AI system is responsible for moderating input and output, generating plans, and executing them. It can be used free standing or routed to by the Application object. This system is encapsulated in the `AI` class. There are four things that make up this system, the moderator, the planner, and actions. + +1. [Moderator](./MODERATOR.md) +2. [Planner](./PLANNER.md) +3. [Actions](./ACTIONS.md) \ No newline at end of file diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 5d46a96f7..a42a348d4 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -1,6 +1,6 @@ # The `Application` class -The `Application` class encapsulates all the business logic for the application and it comprises of two major components, the Activity Handler system and the AI module. +The `Application` class encapsulates all the business logic for the application and it comprises of two major components, the Activity Handler system and the AI System. ## The Activity Handler system @@ -45,8 +45,8 @@ The `Application` groups the route registration methods based on the specific fe In general, the activity handler system is all that is needed to have a functional bot or message extension. -## The AI Module -The AI module is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI Module](.AI-MODULE.md). +## The AI System +The AI System is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI System](.AI-SYSTEM.md). ## The Routing Logic @@ -58,7 +58,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 4. If user authentication is configured, then attemp to sign the user in. If there user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. 5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. 6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. -7. If no route is triggered, the incomming activity is a message, and the AI module is configured, then it is invoked by calling the `AI.run()` method. +7. If no route is triggered, the incomming activity is a message, and the AI System is configured, then it is invoked by calling the `AI.run()` method. 8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. > Note: To learn about what a *turn* is, see [TURNS](TURNS.md). \ No newline at end of file diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md new file mode 100644 index 000000000..8332c2fd7 --- /dev/null +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -0,0 +1,43 @@ +## Moderator + +The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. Here's an example of configuring the `OpenAIModerator`. + +**JS** +```js +const moderator = new OpenAIModerator({ + apiKey: process.env.OPENAI_KEY!, + moderate: 'both' +}); + +const app = new Application({ + storage, + ai: { + planner, + moderator + } +}); +``` + +**C#** +```cs +OpenAIModeratorOptions moderatorOptions = new("api-key", ModerationType.Both); +IModerator moderator = new OpenAIModerator(moderatorOptions); + +AIOptions aIOptions = new(planner) +{ + Moderator = moderator +}; + +var app = new ApplicationBuilder() +.WithStorage(storage) +.WithAIOptions(aIOptions) +.Build(); +``` +> Note for C# application, the moderator should be registered to the Web app's service collection as a singleton. + +The AI system is such that developers can create their own moderator class by simply implementing the moderator interface. The library has a few native moderators that can be used out of the box: + +| Name | Description | +|-----------------------------|-----------------------------------------| +| OpenAIModerator | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | +| AzureContentSafetyModerator | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | \ No newline at end of file diff --git a/getting-started/CONCEPTS/PLANNER.md b/getting-started/CONCEPTS/PLANNER.md new file mode 100644 index 000000000..6948be3f5 --- /dev/null +++ b/getting-started/CONCEPTS/PLANNER.md @@ -0,0 +1,85 @@ +# AI System: Planner + +A planner is a object that takes in a user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. + +This is a powerful concept because it allows you to create actions that can be used in ways that you as a developer may not have thought of. + +For instance, If you have a task and `Summarize` & `SendEmail` action, the planner could combine them to create workflows like "Rewrite the following report into a short paragraph, and email it to johndoe@email.com" without you explicitly having to write code for those scenarios. + +The planner is an extensible part of the AI system. This means that a custom planner can be created for your specific needs. Out of the box, the Teams AI library supports the following planners. + + +| Planner | Description | C# | JS/TS | Python | +| ------------------ | --------------------------------------------------------------------------------------- | --- | ----- | ------ | +| [ActionPlanner](./ACTION-PLANNER.md) | Powerful planner that uses LLMs to generate plans. It has a built-in prompt management, LLM modularity, amongst other features. | ✅ | ✅ | ❌ | +| AssistantsPlanner | A planner that uses OpenAI's Assistants APIs to generate plans. | ✅ | ✅ | ❌ | + +### Plan + +A plan is the entity that is generated by the planner. It is a JSON object of the following shape: + +```json +{ + "type": "plan", + "commands": [ + { + "type": "DO", + "action": "", + "parameters": { + "": "" + } + }, + { + "type": "SAY", + "response": "" + } + ] +} +``` + +A plan consists of two types of commands: + +- **SAY**: Sends a message to the user. + - _response_: The string message to send. +- **DO**: AI system will execute a specific _action_, passing in the generated parameters. + - _action_: A lambda function registered to the AI system + - _parameters_: A dictionary passed to the action. + +The JSON object string is returned by the LLM and deserialized into an object. + +#### Example + +Here's an example of a plan for the following ask: + +User: +`Create a grocery shopping list and add bananas to it.` + +Plan: + +```json +{ + "type": "plan", + "commands": [ + { + "type": "DO", + "action": "createList", + "entities": { + "name": "Grocery Shopping" + } + }, + { + "type": "DO", + "action": "addItem", + "entities": { + "name": "Bananas" + } + }, + { + "type": "SAY", + "response": "Created a grocery shopping list and added a banana to it." + } + ] +} +``` + +This plan is executed in sequential order. So first the list will be created and then an item will be added to it. Finally, the `response` message will be sent to the user. \ No newline at end of file diff --git a/getting-started/CONCEPTS/TURNS.md b/getting-started/CONCEPTS/TURNS.md index b5ebe30d8..542ae22ea 100644 --- a/getting-started/CONCEPTS/TURNS.md +++ b/getting-started/CONCEPTS/TURNS.md @@ -48,7 +48,7 @@ async def on_message(context: TurnContext, state: TurnState): ### Turn State -The turn state object stores cookie-like data for the current turn. Just like the turn context, it is carried through the entire application logic, including the activity handlers and the AI module. Unlike the turn context, the turn state is not a fixed and is meant to be configured to each application specific use cases. +The turn state object stores cookie-like data for the current turn. Just like the turn context, it is carried through the entire application logic, including the activity handlers and the AI System. Unlike the turn context, the turn state is not a fixed and is meant to be configured to each application specific use cases. It is used to store information like the user's message, the conversation history, and any custom data configured by the application code. diff --git a/js/packages/teams-ai/src/Application.ts b/js/packages/teams-ai/src/Application.ts index afc3b241f..8bbf4b83a 100644 --- a/js/packages/teams-ai/src/Application.ts +++ b/js/packages/teams-ai/src/Application.ts @@ -738,7 +738,7 @@ export class Application { } } - // Call AI module if configured + // Call AI System if configured if (this._ai && context.activity.type == ActivityTypes.Message && context.activity.text) { await this._ai.run(context, state); From 441694f082de1b1df149eb217b14b9090dfcf4d3 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:17:18 -0800 Subject: [PATCH 11/87] Update README.md --- getting-started/CONCEPTS/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index b78689da6..0d5b3b69e 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -10,3 +10,4 @@ Here you will find short guides on features available in the library. | --------------------------------------- | ------------------------------------------------- | | [Turn Context and Turn State](TURNS.md) | Explains what the turn context and turn state is. | | [The Application class](APPLICATION.md) | What the `Application` class is and how it works. | +| [The AI System](AI-SYSTEM.md) | Describes the AI System. | From 3625d7fb73b0b2dd5e37da6b620d624530d6dbc4 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:17:53 -0800 Subject: [PATCH 12/87] Update AI-SYSTEM.md --- getting-started/CONCEPTS/AI-SYSTEM.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/AI-SYSTEM.md b/getting-started/CONCEPTS/AI-SYSTEM.md index 249dbb5b4..45d739d2b 100644 --- a/getting-started/CONCEPTS/AI-SYSTEM.md +++ b/getting-started/CONCEPTS/AI-SYSTEM.md @@ -1,7 +1,7 @@ # The AI System -The AI system is responsible for moderating input and output, generating plans, and executing them. It can be used free standing or routed to by the Application object. This system is encapsulated in the `AI` class. There are four things that make up this system, the moderator, the planner, and actions. +The AI system is responsible for moderating input and output, generating plans, and executing them. It can be used free standing or routed to by the Application object. This system is encapsulated in the `AI` class. It is made of three components, the moderator, the planner, and actions. 1. [Moderator](./MODERATOR.md) 2. [Planner](./PLANNER.md) -3. [Actions](./ACTIONS.md) \ No newline at end of file +3. [Actions](./ACTIONS.md) From e79e7c833c91cc417d891d8749809877673aaff4 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:18:18 -0800 Subject: [PATCH 13/87] Update MODERATOR.md --- getting-started/CONCEPTS/MODERATOR.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index 8332c2fd7..6d3e31d04 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -1,4 +1,4 @@ -## Moderator +# Moderator The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. Here's an example of configuring the `OpenAIModerator`. @@ -40,4 +40,4 @@ The AI system is such that developers can create their own moderator class by si | Name | Description | |-----------------------------|-----------------------------------------| | OpenAIModerator | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | -| AzureContentSafetyModerator | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | \ No newline at end of file +| AzureContentSafetyModerator | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | From fc1152912c7cfea9dc13ffc9df12e687ea6ca623 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:19:53 -0800 Subject: [PATCH 14/87] Update PLANNER.md --- getting-started/CONCEPTS/PLANNER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/PLANNER.md b/getting-started/CONCEPTS/PLANNER.md index 6948be3f5..c37b4114b 100644 --- a/getting-started/CONCEPTS/PLANNER.md +++ b/getting-started/CONCEPTS/PLANNER.md @@ -1,4 +1,4 @@ -# AI System: Planner +# AI System - Planner A planner is a object that takes in a user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. @@ -82,4 +82,4 @@ Plan: } ``` -This plan is executed in sequential order. So first the list will be created and then an item will be added to it. Finally, the `response` message will be sent to the user. \ No newline at end of file +This plan is executed in sequential order. So first the list will be created and then an item will be added to it. Finally, the `response` message will be sent to the user. From 842d6c28e52f20379ec518f5d32d48dcefe8e85d Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:20:10 -0800 Subject: [PATCH 15/87] Update MODERATOR.md --- getting-started/CONCEPTS/MODERATOR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index 6d3e31d04..ee69cbdc9 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -1,4 +1,4 @@ -# Moderator +# AI System - Moderator The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. Here's an example of configuring the `OpenAIModerator`. From d22ffbf91718756b1861cd479a6020750d7884c0 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:21:26 -0800 Subject: [PATCH 16/87] Update MODERATOR.md --- getting-started/CONCEPTS/MODERATOR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index ee69cbdc9..6d3e31d04 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -1,4 +1,4 @@ -# AI System - Moderator +# Moderator The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. Here's an example of configuring the `OpenAIModerator`. From 62c41dbd42af494c875740864f6cd935d38cd15b Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:21:37 -0800 Subject: [PATCH 17/87] Update PLANNER.md --- getting-started/CONCEPTS/PLANNER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PLANNER.md b/getting-started/CONCEPTS/PLANNER.md index c37b4114b..38d8a19ab 100644 --- a/getting-started/CONCEPTS/PLANNER.md +++ b/getting-started/CONCEPTS/PLANNER.md @@ -1,4 +1,4 @@ -# AI System - Planner +# Planner A planner is a object that takes in a user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. From 4a9feac91401e28415c6f87d73a2972caf71852a Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:22:02 -0800 Subject: [PATCH 18/87] Update PLANNER.md --- getting-started/CONCEPTS/PLANNER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PLANNER.md b/getting-started/CONCEPTS/PLANNER.md index 38d8a19ab..29dc8f273 100644 --- a/getting-started/CONCEPTS/PLANNER.md +++ b/getting-started/CONCEPTS/PLANNER.md @@ -1,6 +1,6 @@ # Planner -A planner is a object that takes in a user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. +The planner is takes in the user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. This is a powerful concept because it allows you to create actions that can be used in ways that you as a developer may not have thought of. From fcf0cfbe9b3995587b2e379ab1ba84221531f0a7 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Mon, 15 Jan 2024 14:39:02 -0800 Subject: [PATCH 19/87] actions --- getting-started/CONCEPTS/ACTIONS.md | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 getting-started/CONCEPTS/ACTIONS.md diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md new file mode 100644 index 000000000..b6b769b62 --- /dev/null +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -0,0 +1,61 @@ +# Action + +An action is an atomic function that is registered to the AI System. It is a fundamental building block of a plan. + +Here's an example of how an action to create a new list would look like in code. Call this action `createList`: + +### C# + +[List Bot sample](https://github.com/microsoft/teams-ai/blob/a20f8715d3fe81e11c330853e3930e22abe298af/dotnet/samples/04.ai.d.chainedActions.listBot/ListBotActions.cs#L15) +```C# +[Action("createList")] +public bool CreateList([ActionTurnState] ListState turnState, [ActionParameters] Dictionary parameters) +{ + ArgumentNullException.ThrowIfNull(turnState); + ArgumentNullException.ThrowIfNull(parameters); + + string listName = GetParameterString(parameters, "list"); + + EnsureListExists(turnState, listName); + + // Continues exectuion of next command in the plan. + return ""; +} +``` + +> Adding the `Action` attribute marks the method as an action. To register it to the AI System you have pass the instance object containing this method to the `AI.ImportActions(instance)` method. Alternatively you can use the `AI.RegisterAction(name, handler)` to register a single action. + +### JS + +[List Bot sample](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/samples/04.ai.d.chainedActions.listBot/src/index.ts#L153) +```typescript +app.ai.action("createList", async (context: TurnContext, state: ApplicationTurnState, parameters: ListAndItems) => { + // Ex. create a list with name "Grocery Shopping". +ensureListExists(state, parameters.list); + + // Continues exectuion of next command in the plan. + return true; +}); +``` + +> The `action` method registers the action named `createList` with corresponding callback function. + + +## Default Actions + +The user can register custom actions or override default actions in the system. Below is a list of default actions present: + +| Action | Called when | +| --------------------- | ----------------------------------------------------------------------------------------------- | +| `___UnkownAction___` | An unknown action is predicted by the planner. | +| `___FlaggedInput___` | The input is flagged by the moderator. | +| `___FlaggedOutput___` | The output is flagged by the moderator. | +| `___HttpError___` | The planner encounters an HTTP response with status code >= `400` | +| `__TooManySteps__` | The planner task either executed too many steps or timed out. | +| `___PlanReady___` | The plan has been predicted by the planner and it has passed moderation. This can be overriden to mutate the plan before execution. | +| `___DO___` | The AI system is executing a plan with the DO command. Overriding this action will change how _all_ DO commands are handled. | +| `___SAY___` | The AI system is executing a plan wit the SAY command. Overriding this action will change how _all_ SAY commands are handled. By default this will send the `response` message back to the user. | + +> Detailed description of each action can be found in the codebase. + +Note that `___DO___` and `___SAY___`, despite being called commands, are actually specialized actions. This means that a plan is really a sequence of actions. \ No newline at end of file From 64a63a08f6a991d30fce70083b16892ff37e2e40 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:40:38 -0800 Subject: [PATCH 20/87] Update ACTIONS.md --- getting-started/CONCEPTS/ACTIONS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index b6b769b62..dca4cfa10 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -31,7 +31,7 @@ public bool CreateList([ActionTurnState] ListState turnState, [ActionParameters] ```typescript app.ai.action("createList", async (context: TurnContext, state: ApplicationTurnState, parameters: ListAndItems) => { // Ex. create a list with name "Grocery Shopping". -ensureListExists(state, parameters.list); + ensureListExists(state, parameters.list); // Continues exectuion of next command in the plan. return true; @@ -58,4 +58,4 @@ The user can register custom actions or override default actions in the system. > Detailed description of each action can be found in the codebase. -Note that `___DO___` and `___SAY___`, despite being called commands, are actually specialized actions. This means that a plan is really a sequence of actions. \ No newline at end of file +Note that `___DO___` and `___SAY___`, despite being called commands, are actually specialized actions. This means that a plan is really a sequence of actions. From 5592b6e04b7a2620d3fc47d93dadbc46a90c6409 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:43:56 -0800 Subject: [PATCH 21/87] Update README.md --- getting-started/CONCEPTS/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index 0d5b3b69e..34f44b326 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -4,10 +4,20 @@ Here you will find short guides on features available in the library. - +**General Concepts** | Name | Description | | --------------------------------------- | ------------------------------------------------- | | [Turn Context and Turn State](TURNS.md) | Explains what the turn context and turn state is. | | [The Application class](APPLICATION.md) | What the `Application` class is and how it works. | + + +
+ +**The AI System Concepts** +| Name | Description | +| --------------------------------------- | ------------------------------------------------- | | [The AI System](AI-SYSTEM.md) | Describes the AI System. | +| [Planner](PLANNER.md) | Planner and plans. | +| [Moderator](MODERATOR.md) | The moderator. | +| [Actions](ACTIONS.md) | The action in the AI system. | From e1ee94d2fb12ae65b172a7a4d7fa41c79a911dfd Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Tue, 16 Jan 2024 09:44:18 -0800 Subject: [PATCH 22/87] action planner --- getting-started/CONCEPTS/ACTION-PLANNER.md | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index e69de29bb..3297317ef 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -0,0 +1,24 @@ +# Action Planner + +The Action Planner is a powerful planner that uses a LLM to generate plans. It can trigger parameterized actions and send text based responses to the user. It supports the following advanced features: + +[**Prompt Management**](./PROMPTS.md) +The Action Planner has a built-in prompt management system that supports creating prompt templates as folders in the file system. A prompt template is the prompt text along with all the configurations for completion with the LLM model. Dynamic prompts are also supported with template variables and functions. + +[**Augmentations**](./AUGMENTATIONS.md) +Augmentations virtually eliminate the need for prompt engineering. Prompts +can be configured to use a named augmentation which will be automatically appended to the outgoing +prompt. Augmentations let the developer specify whether they want to support multi-step plans (sequence), +or create an AutoGPT style agent (monologue). + +**Validations** +Validators are used to validate the response returned by the LLM and can guarantee +that the parameters passed to an action mach a supplied schema. The validator used is automatically +selected based on the augmentation being used. Validators also prevent hallucinated action names +making it impossible for the LLM to trigger an action that doesn't exist. + +**Repair** +The Action Planner will automatically attempt to repair invalid responses returned by the +LLM using a feedback loop. When a validation fails, the ActionPlanner sends the error back to the +model, along with an instruction asking it to fix its mistake. This feedback technique leads to a +dramatic reduction in the number of invalid responses returned by the model. \ No newline at end of file From e19a2921fdd81f5c05fb37c9012144c147bf7ebf Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Tue, 16 Jan 2024 11:09:35 -0800 Subject: [PATCH 23/87] action planner and prompt management --- getting-started/CONCEPTS/ACTION-PLANNER.md | 9 +- getting-started/CONCEPTS/APPLICATION.md | 2 +- getting-started/CONCEPTS/AUGMENTATIONS.md | 0 getting-started/CONCEPTS/PROMPTS.md | 192 +++++++++++++++++++++ 4 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 getting-started/CONCEPTS/AUGMENTATIONS.md create mode 100644 getting-started/CONCEPTS/PROMPTS.md diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index 3297317ef..f9912d61f 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -2,22 +2,23 @@ The Action Planner is a powerful planner that uses a LLM to generate plans. It can trigger parameterized actions and send text based responses to the user. It supports the following advanced features: -[**Prompt Management**](./PROMPTS.md) +### [Prompt Management](./PROMPTS.md) + The Action Planner has a built-in prompt management system that supports creating prompt templates as folders in the file system. A prompt template is the prompt text along with all the configurations for completion with the LLM model. Dynamic prompts are also supported with template variables and functions. -[**Augmentations**](./AUGMENTATIONS.md) +### [Augmentations](./AUGMENTATIONS.md) Augmentations virtually eliminate the need for prompt engineering. Prompts can be configured to use a named augmentation which will be automatically appended to the outgoing prompt. Augmentations let the developer specify whether they want to support multi-step plans (sequence), or create an AutoGPT style agent (monologue). -**Validations** +### Validations Validators are used to validate the response returned by the LLM and can guarantee that the parameters passed to an action mach a supplied schema. The validator used is automatically selected based on the augmentation being used. Validators also prevent hallucinated action names making it impossible for the LLM to trigger an action that doesn't exist. -**Repair** +### Repair The Action Planner will automatically attempt to repair invalid responses returned by the LLM using a feedback loop. When a validation fails, the ActionPlanner sends the error back to the model, along with an instruction asking it to fix its mistake. This feedback technique leads to a diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index bdb05a224..f2ea6f035 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -46,7 +46,7 @@ The `Application` groups the route registration methods based on the specific fe In general, the activity handler system is all that is needed to have a functional bot or message extension. ## The AI System -The AI System is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI System](.AI-SYSTEM.md). +The AI System is an optional component used to plug in LLM powered experiences like user intent mapping, chaining...etc. It is configured once when orchestrating the application class. To learn more about it see [The AI System](./AI-SYSTEM.md). ## The Routing Logic diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md new file mode 100644 index 000000000..e69de29bb diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md new file mode 100644 index 000000000..d12504bfd --- /dev/null +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -0,0 +1,192 @@ +# Prompts + +Prompts play a crucial role in communicating and directing the behavior of Large Language Models (LLMs) AI. +They serve as inputs or queries that users can provide to elicit specific responses from a model. + +Here's a prompt that asks the LLM for name suggestions: + +_Input:_ + +```prompt +Give me 3 name suggestions for my pet golden retriever. +``` + +_Response:_ + +```prompt +Some possible name suggestions for a pet golden retriever are: + +- Bailey +- Sunny +- Cooper +``` + +## Prompt Template + +Prompt templates are a simple and powerful way to +define and compose AI functions **using plain text**. +You can use it to create natural language prompts, generate responses, extract +information, **invoke other prompts** or perform any other task that can be +expressed with text. + +The language supports two basic features that allow you to include +variables and call functions. + +**Simple Example:** + +Here's an example of a prompt template: + +``` +Give me 3 name suggestions for my pet {{ $petName }}. +``` + +`$petName` is a variable that is populated on runtime when the template is rendered. + +### Prompt Template Language + +You don't need to write any code or import any external libraries, just use the +curly braces {{...}} to embed expressions in your prompts. +Teams AI will parse your template and execute the logic behind it. +This way, you can easily integrate AI into your apps with minimal effort and +maximum flexibility. + +#### Variables + +To include a variable value in your text, use the `{{$variableName}}` syntax. For example, if you have a variable called name that holds the user's name, you can write: + +`Hello {{$name}}, nice to meet you!` + +This will produce a greeting with the user's name. + +Spaces are ignored, so if you find it more readable, you can also write: + +`Hello {{ $name }}, nice to meet you!` + +Here's how to define variables in code: + +**C#** + +In an *action* or *route handler* where the turn state object is available: +```cs +state.Temp.Post = "Lorem Ipsium..." +``` + +The usage in the prompt: +``` +This is the user's post: {{ $post }} +``` + +> Note: The `turnState.Temp.Post = ...` updates a dictionary with the `post` key under the hood from the [GPT Message Extension sample](https://github.com/microsoft/teams-ai/blob/a20f8715d3fe81e11c330853e3930e22abe298af/dotnet/samples/04.ai.b.messageExtensions.gptME/ActivityHandlers.cs#L156). + +**Javascript** + +```typescript +app.beforeTurn((context, state) => { + state.temp.post = "Lorem Ipsium..."; +}); +``` + +The usage in the prompt: +``` +This is the user's post: {{ $post }} +``` + +You can simply add to the `state.temp` object, and it will be accessible from the prompt template on runtime. Note that the safest place to do that would be in the `beforeTurn` activity because it will execute before any activity handler or action. + + +**Default Variables** + +The following are variables accesible in the prompt template without having to manually configure. These are pre-defined in the turn state and populated by the library. Users can override them by changing it in the turn state. + +| Variable name | Description | +| ------------- | ----------------------------------------------------------------- | +| `input` | Input passed from the user to the AI Library. | +| `lastOutput` | Output returned from the last executed action. | + +#### Function calls + +To call an external function and embed the result in your text, use the `{{ functionName }}` syntax. For example if you have a function called `diceRoll` that returns a random number between 1 and 6, you can write: + +`The dice roll has landed on: {{ diceRoll }}` + +**C#** + +In the `Application` class, + +```cs +prompts.AddFunction("diceRoll", async (context, memory, functions, tokenizer, args) => +{ + int diceRoll = // random number between 1 and 6 + return diceRoll; +}); +``` + +**Javascript** + +```typescript +prompts.addFunction('diceRoll', async (context, state, functions, tokenizer, args) => { + let diceRoll = // random number between 1 and 6 + return diceRoll; +}); +``` + +## Creating Prompt Templates + +Each prompt template is a folder with two files, `skprompt.txt` and `config.json`. The folder name is the prompt template's name that can be referred in code. The `skprompt.txt` file contains the prompt's text, which can contain natural language or prompt template syntax as defined in the previous section. The `config.json` file specifies the prompt completion configuration. + +Here's an example of a prompt template from the [Twenty Questions](https://github.com/microsoft/teams-ai/blob/c5ec11842b808e48cd214b3cb52da84e5811da33/js/samples/04.e.twentyQuestions) sample. + +*skprompt.txt* +``` +You are the AI in a game of 20 questions. +The goal of the game is for the Human to guess a secret within 20 questions. +The AI should answer questions about the secret. +The AI should assume that every message from the Human is a question about the secret. + +GuessCount: {{$conversation.guessCount}} +RemainingGuesses: {{$conversation.remainingGuesses}} +Secret: {{$conversation.secretWord}} + +Answer the humans question but do not mention the secret word. +``` + +*config.json* +```json +{ + "schema": 1.1, + "description": "A bot that plays a game of 20 questions", + "type": "completion", + "completion": { + "completion_type": "chat", + "include_history": false, + "include_input": true, + "max_input_tokens": 2000, + "max_tokens": 256, + "temperature": 0.7, + "top_p": 0.0, + "presence_penalty": 0.6, + "frequency_penalty": 0.0 + } +} +``` + +> Note that the configuration properties in the file do not include all the possible configurations. To learn more about the description of each configuration and all the supported configurations see the [`PromptTemplatConfig`](https://github.com/microsoft/teams-ai/blob/2d43f5ca5b3bf27844f760663641741cae4a3243/js/packages/teams-ai/src/prompts/PromptTemplate.ts#L46C18-L46C39) Typescript interface. + +These files can be found under the `src/prompts/chat/` folder. So this prompt template's name is `chat`. Then to plug this files in the Action Planner, the prompt manager has to be created with the folder path specified and then passed into the Action Planner constructor: + +**C#** +```cs +PromptManager prompts = new PromptManager(new PromptManagerOptions(){ + PromptFolder = "./prompts" +}); +``` + +The file path is relative to the source of file in which the `PromptManager` is created. In this case the `Program.cs` was in the same folder as the `prompts` folder. + +**Javascript** +```ts +const prompts = new PromptManager({ + promptsFolder: path.join(__dirname, '../src/prompts') +}); +``` + From c5cd3cc10128eada3d66eb64dc32c82feee23676 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:11:43 -0800 Subject: [PATCH 24/87] Update PROMPTS.md --- getting-started/CONCEPTS/PROMPTS.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index d12504bfd..b572379df 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -21,7 +21,7 @@ Some possible name suggestions for a pet golden retriever are: - Cooper ``` -## Prompt Template +# Prompt Template Prompt templates are a simple and powerful way to define and compose AI functions **using plain text**. @@ -42,7 +42,7 @@ Give me 3 name suggestions for my pet {{ $petName }}. `$petName` is a variable that is populated on runtime when the template is rendered. -### Prompt Template Language +## Prompt Template Language You don't need to write any code or import any external libraries, just use the curly braces {{...}} to embed expressions in your prompts. @@ -50,7 +50,7 @@ Teams AI will parse your template and execute the logic behind it. This way, you can easily integrate AI into your apps with minimal effort and maximum flexibility. -#### Variables +### Variables To include a variable value in your text, use the `{{$variableName}}` syntax. For example, if you have a variable called name that holds the user's name, you can write: @@ -103,7 +103,7 @@ The following are variables accesible in the prompt template without having to m | `input` | Input passed from the user to the AI Library. | | `lastOutput` | Output returned from the last executed action. | -#### Function calls +### Function calls To call an external function and embed the result in your text, use the `{{ functionName }}` syntax. For example if you have a function called `diceRoll` that returns a random number between 1 and 6, you can write: @@ -130,7 +130,7 @@ prompts.addFunction('diceRoll', async (context, state, functions, tokenizer, arg }); ``` -## Creating Prompt Templates +# Creating Prompt Templates Each prompt template is a folder with two files, `skprompt.txt` and `config.json`. The folder name is the prompt template's name that can be referred in code. The `skprompt.txt` file contains the prompt's text, which can contain natural language or prompt template syntax as defined in the previous section. The `config.json` file specifies the prompt completion configuration. From 70707c0195866fdda790050322bf219ddab40562 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:13:14 -0800 Subject: [PATCH 25/87] Update PROMPTS.md --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index b572379df..fc5f96bdb 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -172,7 +172,7 @@ Answer the humans question but do not mention the secret word. > Note that the configuration properties in the file do not include all the possible configurations. To learn more about the description of each configuration and all the supported configurations see the [`PromptTemplatConfig`](https://github.com/microsoft/teams-ai/blob/2d43f5ca5b3bf27844f760663641741cae4a3243/js/packages/teams-ai/src/prompts/PromptTemplate.ts#L46C18-L46C39) Typescript interface. -These files can be found under the `src/prompts/chat/` folder. So this prompt template's name is `chat`. Then to plug this files in the Action Planner, the prompt manager has to be created with the folder path specified and then passed into the Action Planner constructor: +These files can be found under the `src/prompts/chat/` folder. So this prompt template's name is `chat`. Then to plug these files in the Action Planner, the prompt manager has to be created with the folder path specified and then passed into the Action Planner constructor: **C#** ```cs From 9b7c527cc621d575ca145532d916a4318f0da99b Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:17:31 -0800 Subject: [PATCH 26/87] Update README.md --- getting-started/CONCEPTS/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index 34f44b326..870397ff0 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -21,3 +21,12 @@ Here you will find short guides on features available in the library. | [Planner](PLANNER.md) | Planner and plans. | | [Moderator](MODERATOR.md) | The moderator. | | [Actions](ACTIONS.md) | The action in the AI system. | + +
+ +**Action Planner Concepts** +| Name | Description | +| --------------------------------------- | ------------------------------------------------- | +| [The Action Planner](ACTION-PLANNER.md) | Describes the Action Planner. | +| [Prompt Management](PROMPTS.md) | Prompts, prompt templates, and creating prompt templates. | +| [Augmentation](AUGMENTATIONS.md) | Monologue and sequence augmentations. | From 8cab6478a126cffe2b496aa0bc9dfb6d4d252569 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:19:50 -0800 Subject: [PATCH 27/87] Update README.md --- getting-started/CONCEPTS/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index 870397ff0..89179e074 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -10,6 +10,7 @@ Here you will find short guides on features available in the library. | --------------------------------------- | ------------------------------------------------- | | [Turn Context and Turn State](TURNS.md) | Explains what the turn context and turn state is. | | [The Application class](APPLICATION.md) | What the `Application` class is and how it works. | +| [User Authentication](USER-AUTH.md) | Describes user authentication features out of the box |
From 76ddb4d2a84411d92fe690180e539cd7a6db75c3 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:22:20 -0800 Subject: [PATCH 28/87] Update README.md --- getting-started/CONCEPTS/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/README.md b/getting-started/CONCEPTS/README.md index 89179e074..3aaaf6f09 100644 --- a/getting-started/CONCEPTS/README.md +++ b/getting-started/CONCEPTS/README.md @@ -30,4 +30,4 @@ Here you will find short guides on features available in the library. | --------------------------------------- | ------------------------------------------------- | | [The Action Planner](ACTION-PLANNER.md) | Describes the Action Planner. | | [Prompt Management](PROMPTS.md) | Prompts, prompt templates, and creating prompt templates. | -| [Augmentation](AUGMENTATIONS.md) | Monologue and sequence augmentations. | +| [Augmentations](AUGMENTATIONS.md) | Monologue and sequence augmentations. | From 4ee4c4b0f0b153a8b178f353e549b9c5bd5d2481 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:31:32 -0800 Subject: [PATCH 29/87] Create USER-AUTH.md --- getting-started/CONCEPTS/USER-AUTH.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 getting-started/CONCEPTS/USER-AUTH.md diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -0,0 +1 @@ + From 715eca71b908c0915d0674854deaa59d25586abb Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Tue, 16 Jan 2024 16:04:58 -0800 Subject: [PATCH 30/87] augmentations --- getting-started/CONCEPTS/AUGMENTATIONS.md | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index e69de29bb..8a5d1d493 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -0,0 +1,120 @@ +# Augmentations + +Augmentations virtually eliminate the need for prompt engineering. Prompts +can be configured to use a named augmentation which will be automatically appended to the outgoing +prompt. Augmentations let the developer specify whether they want to support multi-step plans (sequence), +or create an AutoGPT style agent (monologue). + +It is recommended to read the [AI System](./AI-SYSTEM.md) and [Action Planner](./ACTION-PLANNER.md) guides if you are not familiar with plans and actions. + +## Sequence Augmentation + +This augmentation allows the model to return a sequence of actions to perform. It does this by appending instructions to the prompt text in runtime. These instructions guide the model to generate a plan object that uses actions defined in the `actions.json` file from the prompt template folder. + +Here's an example of the `actions.json` file from the [Light Bot](https://github.com/microsoft/teams-ai/blob/77339da9e3e03bfd7f629fc796cfebdcd2891afb/js/samples/04.ai.c.actionMapping.lightBot/src/prompts/sequence/actions.json) sample: + +```js +[ + { + "name": "LightsOn", + "description": "Turns on the lights" + }, + { + "name": "LightsOff", + "description": "Turns off the lights" + }, + { + "name": "Pause", + "description": "Delays for a period of time", + "parameters": { + "type": "object", + "properties": { + "time": { + "type": "number", + "description": "The amount of time to delay in milliseconds" + } + }, + "required": [ + "time" + ] + } + } +] +``` + +It defines three actions, `LightsOn`, `LightsOff` and `Pause`. The `Pause` action requires the `time` parameter, while the other two doesn't. + +These actions are then used and appended to the prompt text in runtime. This is text added to end of the prompt text: + +```txt +actions: + LightsOn: + description: Turns on the lights + LightsOff: + description: Turns off the lights + Pause: + description: Delays for a period of time + parameters: + time: + type: number + description: The amount of time to delay in milliseconds + +Use the actions above to create a plan in the following JSON format: + +{ + "type": "plan", + "commands": [ + { + "type": "DO", + "action": "", + "parameters": { + "": "" + } + }, + { + "type": "SAY", + "response": "" + } + ] +} +``` +> Note: When the prompt is rendered, the above text is compressed to reduce token usage. + +The first section lists the actions in yaml structure. The second sections tells the model to return a plan object of the following schema. + +### Configuring your prompt + +To use sequence augmentation in your prompt there are two steps. + +1. Update the prompt's `config.json` by adding the `augmentation` property. +```diff +{ + "schema": 1.1, + "description": "", + "type": "", + "completion": {}, ++ "augmentation": { ++ "augmentation_type": "sequence" ++ } +} +``` +2. Create an `actions.json` file in the prompt folder with a list of actions. For example: +```json +[ + { + "name": "LightsOn", + "description": "Turns on the lights" + }, + { + "name": "LightsOff", + "description": "Turns off the lights" + }, +] +``` + +The learn more about the action object schema see the corresponding typescript interface [ChatCompletionAction](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/packages/teams-ai/src/models/ChatCompletionAction.ts#L14). + + + + +## Monologue Augmentation \ No newline at end of file From 2b8a4f49da1d5678d35b641396a8511d1fe617f9 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:06:18 -0800 Subject: [PATCH 31/87] Update AUGMENTATIONS.md --- getting-started/CONCEPTS/AUGMENTATIONS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 8a5d1d493..2ee8d0ab4 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -84,7 +84,7 @@ The first section lists the actions in yaml structure. The second sections tells ### Configuring your prompt -To use sequence augmentation in your prompt there are two steps. +There are two steps to use sequence augmentation in your prompt: 1. Update the prompt's `config.json` by adding the `augmentation` property. ```diff @@ -117,4 +117,4 @@ The learn more about the action object schema see the corresponding typescript i -## Monologue Augmentation \ No newline at end of file +## Monologue Augmentation From 7783e7d61cbbe27ab3fc5e75cf7c46ad84b325f8 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:06:52 -0800 Subject: [PATCH 32/87] Update AUGMENTATIONS.md --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 2ee8d0ab4..91c52fc3e 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -44,7 +44,7 @@ Here's an example of the `actions.json` file from the [Light Bot](https://github It defines three actions, `LightsOn`, `LightsOff` and `Pause`. The `Pause` action requires the `time` parameter, while the other two doesn't. -These actions are then used and appended to the prompt text in runtime. This is text added to end of the prompt text: +These actions are then appended to the prompt text in runtime. This is text added to end of the prompt text: ```txt actions: From ca5f97cff8240e8635769d4e814a56762f7c91a1 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Wed, 17 Jan 2024 14:32:03 -0800 Subject: [PATCH 33/87] routing logic and augmentations --- getting-started/CONCEPTS/APPLICATION.md | 2 + getting-started/CONCEPTS/AUGMENTATIONS.md | 75 ++++++++++++++++++++++- getting-started/assets/routing-logic.png | 3 + 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 getting-started/assets/routing-logic.png diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index f2ea6f035..80e5f384a 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -65,3 +65,5 @@ When an incoming activity reaches the server, the bot adapter handles the necess > Note: _End the turn_ means that the main method has terminated execution and so the application has completed processing the incomming activity. > Note: To learn about what a *turn* is, see [TURNS](TURNS.md). + +![the routing logic](../assets/routing-logic.png) \ No newline at end of file diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 8a5d1d493..c243f781b 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -115,6 +115,79 @@ To use sequence augmentation in your prompt there are two steps. The learn more about the action object schema see the corresponding typescript interface [ChatCompletionAction](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/packages/teams-ai/src/models/ChatCompletionAction.ts#L14). +## Monologue Augmentation +This augmentation adds support for an inner monologue to the prompt. The monologue helps the LLM to perform chain-of-thought reasoning across multiple turns of conversation. It does this by appending instructions to the prompt text in runtime. It tells the model to explicitly show it's thought, reasoning & plan in response to the user's message and predict the next action to execute. If looping is configured, then the predicted action can guide the model to predict the next action by returning the instruction as a string in the action handler callback. The loop will terminate as soon as the model predicts a *SAY* action, which sends the response back to the user. -## Monologue Augmentation \ No newline at end of file +Using the `actions.json` example from abovce, the instructions appended to the prompt look like this: + +These actions are then used and appended to the prompt text in runtime. This is text added to end of the prompt text: + +```txt +actions: + LightsOn: + description: Turns on the lights + LightsOff: + description: Turns off the lights + Pause: + description: Delays for a period of time + parameters: + time: + type: number + description: The amount of time to delay in milliseconds + +Return a JSON object with your thoughts and the next action to perform. +Only respond with the JSON format below and base your plan on the actions above. +If you're not sure what to do, you can always say something by returning a SAY action. +If you're told your JSON response has errors, do your best to fix them. + +Response Format: + +{ + "thoughts": { + "thought": "", + "reasoning": "", + "plan": "- short bulleted\\n- list that conveys\\n- long-term plan" + }, + "action": { + "name": "", + "parameters": { + "": "" + } + } +} +``` + +> Note: When the prompt is rendered, the above text is compressed to reduce token usage. + +The first section lists the actions in yaml structure. The second sections tells the model to return a plan object of the following schema. + +### Configuring your prompt + +To use monologue augmentation in your prompt there are two steps. + +1. Update the prompt's `config.json` by adding the `augmentation` property. +```diff +{ + "schema": 1.1, + "description": "", + "type": "", + "completion": {}, ++ "augmentation": { ++ "augmentation_type": "monologue" ++ } +} +``` +2. Create an `actions.json` file in the prompt folder with a list of actions. For example: +```json +[ + { + "name": "LightsOn", + "description": "Turns on the lights" + }, + { + "name": "LightsOff", + "description": "Turns off the lights" + }, +] +``` \ No newline at end of file diff --git a/getting-started/assets/routing-logic.png b/getting-started/assets/routing-logic.png new file mode 100644 index 000000000..814da5f6d --- /dev/null +++ b/getting-started/assets/routing-logic.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9d5b13a539bd9b0cb3bc9c5380b22854ea037da5b10798e0951e62eda162584 +size 78442 From 045de5650fd8142a3b5bbdad0677506c3f31bfe2 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Wed, 17 Jan 2024 16:10:52 -0800 Subject: [PATCH 34/87] user authentication --- getting-started/CONCEPTS/USER-AUTH.md | 168 ++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 8b1378917..1649acc5b 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -1 +1,169 @@ +# User Authentication +A critical feature of any Teams application is the ability to access relevent user data from third party services, for example a DevOps bot being able to access the user's work items from Azure DevOps. To do this the bot or message extension has to be able to authenticate the user to third party services. In the Bot Framework SDK, configuring user authenticate is incredibly hard to implement and even more so to debug potential issues. The Teams AI library has user authentication built-in to the `Application` class and exposes a simple interface to configuring it for both bots and message extensions. + +## Quickstart + +To dive right in and test out a bot or message extension see the [user authentication samples](../SAMPLES.md#user-authentication-samples). They are relatively straight forward to set up given the right tools installed. If you have not tested a sample before it is recommnded to first follow the [quickstart guide](../QUICKSTART.md). + +## Configuring the application + +Adding user authentication is as simple as configuring it in the `Application` class constructor or builder: + +**C#** +```cs +AuthenticationOptions options = new(); +options.AddAuthentication("graph", new OAuthSettings() + { + ConnectionName = config.OAUTH_CONNECTION_NAME, + Title = "Sign In", + Text = "Please sign in to use the bot.", + } +); + +Application app = new ApplicationBuilder() + .WithStorage(storage) + .WithTurnStateFactory(() => new AppState()) + .WithAuthentication(adapter, options) + .Build(); +``` + +**Javascript** +```js +const app = new ApplicationBuilder() + .withStorage(storage) + .withAuthentication(adapter, { + settings: { + graph: { + connectionName: process.env.OAUTH_CONNECTION_NAME ?? '', + title: 'Sign in', + text: 'Please sign in to use the bot.', + } + } + }) + .build(); +``` + +The `adapter` is the configured `BotAdapter` for the application. The second parameter in the `.withAuthentication` is the authentication options. + +The `settings` property is an object of all the different services that the user could be authenticated to, called *connections*. The above example has the `graph` connection which specifies configurations to authenticate the user to Microsoft Graph. The name `graph` is arbitrary and is used when specifying which service to sign the user in and out of. + +The `connectionName` property is what you configure in the Azure Bot Resource, see [Configure OAuth connection for your bot resource](https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/bot-sso-register-aad?tabs=windows#configure-oauth-connection-for-your-bot-resource). + +The `text` property is the titie and the `text` property is the body of the sign in card sent to the user. + +With this configuration, the bot will attempt to authenticate the user when they try to interact with it. To control when for which incomming activities the bot should authenticate the user, you can specify configure the auto sign in property in the options. + +**C#** +```cs +options.AutoSignIn = (ITurnContext turnContext, CancellationToken cancellationToken) => + { + string command = (turnContext.Activity.Value as JObject).Value("commandId"); + bool signOutActivity = command == "signOutCommand"; + if (signOutActivity) + { + return Task.FromResult(true); + } + return Task.FromResult(false); + }; +``` + +**Javascript** +```ts +.withAuthentication(adapter, { + // settings: { + // graph: { + // connectionName: process.env.OAUTH_CONNECTION_NAME ?? '', + // title: 'Sign in', + // text: 'Please sign in to use the bot.', + // endOnInvalidMessage: true + // } + // }, + autoSignIn: (context: TurnContext) => { + const signOutActivity = context.activity?.value.commandId === 'signOutCommand'; + if (signOutActivity) { + return Promise.resolve(false); + } + + return Promise.resolve(true); + } +}) +``` + +The `autoSignIn` property takes a callback that triggers the sign in flow if it returns true. It depends on the turn context from which the incomming activity details can be extracted. In the above example, the library will not attempt to sign the user in if the incomming activity `commandId` is *"signOutCommand"*. + +This is useful if the user should be signed in by default before attempting to interacting with the bot in general. If the user should only be authenticated in certain scenarios then you can disable auto sign in by having the callback alway return false and trigger authentication manually. + +Here's an example of manually triggering sign in flow in an activity or action handler: + + +**C#** +```cs +string? token = await app.GetTokenOrStartSignInAsync(turnContext, turnState, "graph", cancellationToken); +if (token == null || token.Length == 0) +{ + await turnContext.SendActivityAsync("You have to be signed in to fulfill this request. Starting sign in flow..."); +} +``` + +**Javascript** +```ts +const token = await app.getTokenOrStartSignIn(context, state, 'graph'); +if (!token) { + await context.sendActivity('You have to be signed in to fulfill this request. Starting sign in flow...'); +} +``` + +The `app.getTokenOrStartSignIn` method will attempt to get the access token if the user is already signed in. Otherwise, the sign in flow will be triggered. The string `'graph'` references the connection name set by the user in the `settings` object of the authentication options. + +If multiple settings are configured then the user can be authenticated into multiple services through the manual triggering of the sign in flow. + +**Note:** Once the sign in flow completes the application is NOT redirected back to it's previous task, when triggered from message activity or in action handler. This means that if user authentication is triggered through a message extension, then the same activity will be sent again to the bot after sign in completes. But if sign in is triggered when the incomming activity is a message then the same activitiy will NOT be sent again to the bot after sign in completes. + +To handle the event when the user has signed successfully or failed to sign in simply register corresponding handler: + +**C#** +```cs +app.Authentication.Get("graph").OnUserSignInSuccess(async (context, state) => +{ + // Successfully logged in + await context.SendActivityAsync("Successfully logged in"); + await context.SendActivityAsync($"Token string length: {state.Temp.AuthTokens["graph"].Length}"); + await context.SendActivityAsync($"This is what you said before the AuthFlow started: {context.Activity.Text}"); +}); + +app.Authentication.Get("graph").OnUserSignInFailure(async (context, state, ex) => +{ + // Failed to login + await context.SendActivityAsync("Failed to login"); + await context.SendActivityAsync($"Error message: {ex.Message}"); +}); +``` + +**Javascript** +```ts +app.authentication.get('graph').onUserSignInSuccess(async (context: TurnContext, state: ApplicationTurnState) => { + // Successfully logged in + await context.sendActivity('Successfully logged in'); + await context.sendActivity(`Token string length: ${state.temp.authTokens['graph']!.length}`); + await context.sendActivity(`This is what you said before the AuthFlow started: ${context.activity.text}`); +}); + +app.authentication.get('graph').onUserSignInFailure(async (context: TurnContext, _state: ApplicationTurnState, error: AuthError) => { + // Failed to login + await context.sendActivity('Failed to login'); + await context.sendActivity(`Error message: ${error.message}`); +}); +``` + +You can also sign a user out of connection: + +**C#** +```cs +await app.Authentication.SignOutUserAsync(context, state, "graph", cancellationToken); +``` + +**Javascript** +```js +await app.authentication.signOutUser(context, state, 'graph'); +``` \ No newline at end of file From 7ef2d127938242b1235130afc9a7b518fd05fc24 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Wed, 17 Jan 2024 16:13:52 -0800 Subject: [PATCH 35/87] authentication --- getting-started/CONCEPTS/USER-AUTH.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 1649acc5b..f5ba730a3 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -52,6 +52,8 @@ The `connectionName` property is what you configure in the Azure Bot Resource, s The `text` property is the titie and the `text` property is the body of the sign in card sent to the user. +### Auto sign in + With this configuration, the bot will attempt to authenticate the user when they try to interact with it. To control when for which incomming activities the bot should authenticate the user, you can specify configure the auto sign in property in the options. **C#** @@ -92,7 +94,11 @@ options.AutoSignIn = (ITurnContext turnContext, CancellationToken cancellationTo The `autoSignIn` property takes a callback that triggers the sign in flow if it returns true. It depends on the turn context from which the incomming activity details can be extracted. In the above example, the library will not attempt to sign the user in if the incomming activity `commandId` is *"signOutCommand"*. -This is useful if the user should be signed in by default before attempting to interacting with the bot in general. If the user should only be authenticated in certain scenarios then you can disable auto sign in by having the callback alway return false and trigger authentication manually. +This is useful if the user should be signed in by default before attempting to interacting with the bot in general. + +### Manual Sign In + +If the user should only be authenticated in certain scenarios then you can disable auto sign in by having the callback alway return false and trigger authentication manually. Here's an example of manually triggering sign in flow in an activity or action handler: @@ -120,6 +126,8 @@ If multiple settings are configured then the user can be authenticated into mult **Note:** Once the sign in flow completes the application is NOT redirected back to it's previous task, when triggered from message activity or in action handler. This means that if user authentication is triggered through a message extension, then the same activity will be sent again to the bot after sign in completes. But if sign in is triggered when the incomming activity is a message then the same activitiy will NOT be sent again to the bot after sign in completes. +### Handling sign in success or failure + To handle the event when the user has signed successfully or failed to sign in simply register corresponding handler: **C#** @@ -156,6 +164,8 @@ app.authentication.get('graph').onUserSignInFailure(async (context: TurnContext, }); ``` +### Sign out a user + You can also sign a user out of connection: **C#** From 24586b8c2a9d1ead59b5fef7082b5c65eab0b3bc Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:59:17 -0800 Subject: [PATCH 36/87] Update getting-started/CONCEPTS/ACTION-PLANNER.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTION-PLANNER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index f9912d61f..2101a9744 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -14,7 +14,7 @@ or create an AutoGPT style agent (monologue). ### Validations Validators are used to validate the response returned by the LLM and can guarantee -that the parameters passed to an action mach a supplied schema. The validator used is automatically +that the parameters passed to an action match a supplied schema. The validator used is automatically selected based on the augmentation being used. Validators also prevent hallucinated action names making it impossible for the LLM to trigger an action that doesn't exist. From e9e066239c797a9a83d2774b46bf5016a31c2be1 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:59:24 -0800 Subject: [PATCH 37/87] Update getting-started/MIGRATION/JS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/MIGRATION/JS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/MIGRATION/JS.md b/getting-started/MIGRATION/JS.md index 4ad2ac6f3..8ff3bcce0 100644 --- a/getting-started/MIGRATION/JS.md +++ b/getting-started/MIGRATION/JS.md @@ -49,7 +49,7 @@ const app = new ApplicationBuilder() ## 2. Replace the activity handler implementations with specific route registration methods -The `BotActivityHandler` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route registration method in the `Application` object. Here's a simple example: +The `BotActivityHandler` class derives from the `ActivityHandler` class. Each method in the class corresponds to a specific route registration method (`handler`) in the `Application` object. Here's a simple example: Given the `BotActivityHandler` implementation: From d6dcc3e6faa4f1939471487e4473c7dd8838afc9 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:00:24 -0800 Subject: [PATCH 38/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index f5ba730a3..7eaa508a3 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -70,7 +70,7 @@ options.AutoSignIn = (ITurnContext turnContext, CancellationToken cancellationTo }; ``` -**Javascript** +**JavaScript** ```ts .withAuthentication(adapter, { // settings: { From 34101f22f4a2695763437b849af7c22ffa0347bc Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:00:38 -0800 Subject: [PATCH 39/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 7eaa508a3..71b0d1b9b 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -54,7 +54,7 @@ The `text` property is the titie and the `text` property is the body of the sign ### Auto sign in -With this configuration, the bot will attempt to authenticate the user when they try to interact with it. To control when for which incomming activities the bot should authenticate the user, you can specify configure the auto sign in property in the options. +With this configuration, the bot will attempt to authenticate the user when they try to interact with it. To control when for which incoming activities the bot should authenticate the user, you can specify configure the auto sign in property in the options. **C#** ```cs From e289b0599cc9d4f8de7514436468f7f2965a7e96 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:05:51 -0800 Subject: [PATCH 40/87] Update ACTIONS.md --- getting-started/CONCEPTS/ACTIONS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index dca4cfa10..930e6b8fa 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -47,14 +47,14 @@ The user can register custom actions or override default actions in the system. | Action | Called when | | --------------------- | ----------------------------------------------------------------------------------------------- | -| `___UnkownAction___` | An unknown action is predicted by the planner. | +| `___UnknownAction___` | An unknown action is predicted by the planner. | | `___FlaggedInput___` | The input is flagged by the moderator. | | `___FlaggedOutput___` | The output is flagged by the moderator. | | `___HttpError___` | The planner encounters an HTTP response with status code >= `400` | | `__TooManySteps__` | The planner task either executed too many steps or timed out. | | `___PlanReady___` | The plan has been predicted by the planner and it has passed moderation. This can be overriden to mutate the plan before execution. | | `___DO___` | The AI system is executing a plan with the DO command. Overriding this action will change how _all_ DO commands are handled. | -| `___SAY___` | The AI system is executing a plan wit the SAY command. Overriding this action will change how _all_ SAY commands are handled. By default this will send the `response` message back to the user. | +| `___SAY___` | The AI system is executing a plan with the SAY command. Overriding this action will change how _all_ SAY commands are handled. By default this will send the `response` message back to the user. | > Detailed description of each action can be found in the codebase. From ec6b78961a053028894826c4490480cee32d6023 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:06:20 -0800 Subject: [PATCH 41/87] Update APPLICATION.md --- getting-started/CONCEPTS/APPLICATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 80e5f384a..ce22e82fc 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -5,7 +5,7 @@ The `Application` class encapsulates all the business logic for the application ## The Activity Handler System -The activity handler system is the primary way to implement bot or message extension applicaiton logic. It is a set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. +The activity handler system is the primary way to implement bot or message extension application logic. It is a set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. Here's an example of registering a route handler that will run when the the user sends *"/login"* to the bot: @@ -66,4 +66,4 @@ When an incoming activity reaches the server, the bot adapter handles the necess > Note: To learn about what a *turn* is, see [TURNS](TURNS.md). -![the routing logic](../assets/routing-logic.png) \ No newline at end of file +![the routing logic](../assets/routing-logic.png) From aa63e1618ae127dec472a3e3c41a51b2ea99545d Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Thu, 18 Jan 2024 15:24:06 -0800 Subject: [PATCH 42/87] added example for azure content safety moderator in docs --- getting-started/CONCEPTS/MODERATOR.md | 46 +++++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index 6d3e31d04..249aea7c6 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -1,6 +1,18 @@ # Moderator -The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. Here's an example of configuring the `OpenAIModerator`. +The `Moderator` is responsible for reviewing the input prompt and approving the AI generated plans. It is configured when orchestrating the `Application` class. + +The AI system is such that developers can create their own moderator class by simply implementing the moderator interface. The library has a few native moderators that can be used out of the box: + +| Name | Description | +|-----------------------------|-----------------------------------------| +| [OpenAIModerator](#openai-moderator) | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | +| [AzureContentSafetyModerator](#azure-content-safety-moderator) | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | + + +## OpenAI Moderator + +Here's an example of configuring the `OpenAIModerator`: **JS** ```js @@ -20,24 +32,38 @@ const app = new Application({ **C#** ```cs -OpenAIModeratorOptions moderatorOptions = new("api-key", ModerationType.Both); -IModerator moderator = new OpenAIModerator(moderatorOptions); +OpenAIModeratorOptions moderatorOptions = new(config.OpenAI.ApiKey, ModerationType.Both); +IModerator moderator = new OpenAIModerator(moderatorOptions); -AIOptions aIOptions = new(planner) +AIOptions aIOptions = new(planner) { Moderator = moderator }; -var app = new ApplicationBuilder() +var app = new ApplicationBuilder() .WithStorage(storage) .WithAIOptions(aIOptions) .Build(); ``` +> This snippet is taken from the [Twenty Questions bot] sample > Note for C# application, the moderator should be registered to the Web app's service collection as a singleton. -The AI system is such that developers can create their own moderator class by simply implementing the moderator interface. The library has a few native moderators that can be used out of the box: +## Azure Content Safety Moderator -| Name | Description | -|-----------------------------|-----------------------------------------| -| OpenAIModerator | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | -| AzureContentSafetyModerator | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | +Here's an example of configuring the `AzureContentSafetyModerator`: + +**JS** +```js +const moderator = new AzureContentSafetyModerator({ + apiKey: process.env.AZURE_CONTENT_SAFETY_KEY, + endpoint: process.env.AZURE_CONTENT_SAFETY_ENDPOINT, + apiVersion: '2023-04-30-preview', + moderate: 'both' +}); +``` + +**C#** +```cs +AzureContentSafetyModeratorOptions moderatorOptions = new(config.Azure.ContentSafetyApiKey, config.Azure.ContentSafetyEndpoint, ModerationType.Both); +IModerator moderator = new AzureContentSafetyModerator(moderatorOptions); +``` \ No newline at end of file From 751de3b833ff28baf5a5cfb1467ac7497390b09d Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Thu, 18 Jan 2024 16:54:07 -0800 Subject: [PATCH 43/87] user auth --- getting-started/CONCEPTS/USER-AUTH.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 71b0d1b9b..0fb3e3834 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -73,14 +73,7 @@ options.AutoSignIn = (ITurnContext turnContext, CancellationToken cancellationTo **JavaScript** ```ts .withAuthentication(adapter, { - // settings: { - // graph: { - // connectionName: process.env.OAUTH_CONNECTION_NAME ?? '', - // title: 'Sign in', - // text: 'Please sign in to use the bot.', - // endOnInvalidMessage: true - // } - // }, + settings: { /* Settings options here... */ }, autoSignIn: (context: TurnContext) => { const signOutActivity = context.activity?.value.commandId === 'signOutCommand'; if (signOutActivity) { From 1bf7aaa6f486f6d27c7d9edf3b1d127167774754 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:54:58 -0800 Subject: [PATCH 44/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 71b0d1b9b..2e922e2b7 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -92,7 +92,7 @@ options.AutoSignIn = (ITurnContext turnContext, CancellationToken cancellationTo }) ``` -The `autoSignIn` property takes a callback that triggers the sign in flow if it returns true. It depends on the turn context from which the incomming activity details can be extracted. In the above example, the library will not attempt to sign the user in if the incomming activity `commandId` is *"signOutCommand"*. +The `autoSignIn` property takes a callback that triggers the sign in flow if it returns true. It depends on the turn context from which the incomming activity details can be extracted. In the above example, the library will not attempt to sign the user in if the incoming activity `commandId` is *"signOutCommand"*. This is useful if the user should be signed in by default before attempting to interacting with the bot in general. From 8a90a03c450018b77b7d9e73325f265a7c585885 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:05 -0800 Subject: [PATCH 45/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 2e922e2b7..9e29101b1 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -120,7 +120,7 @@ if (!token) { } ``` -The `app.getTokenOrStartSignIn` method will attempt to get the access token if the user is already signed in. Otherwise, the sign in flow will be triggered. The string `'graph'` references the connection name set by the user in the `settings` object of the authentication options. +The `app.getTokenOrStartSignIn` method will attempt to get the access token if the user is already signed in. Otherwise, the sign in flow will be triggered. The string `'graph'` below references the connection name set by the user in the `settings` object of the authentication options. If multiple settings are configured then the user can be authenticated into multiple services through the manual triggering of the sign in flow. From 6d4d8cbeac53189d54751626c35087f22bbcc6f2 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:12 -0800 Subject: [PATCH 46/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 9e29101b1..47a922cba 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -122,7 +122,7 @@ if (!token) { The `app.getTokenOrStartSignIn` method will attempt to get the access token if the user is already signed in. Otherwise, the sign in flow will be triggered. The string `'graph'` below references the connection name set by the user in the `settings` object of the authentication options. -If multiple settings are configured then the user can be authenticated into multiple services through the manual triggering of the sign in flow. +If multiple settings are configured, then the user can be authenticated into multiple services through the manual triggering of the sign in flow. **Note:** Once the sign in flow completes the application is NOT redirected back to it's previous task, when triggered from message activity or in action handler. This means that if user authentication is triggered through a message extension, then the same activity will be sent again to the bot after sign in completes. But if sign in is triggered when the incomming activity is a message then the same activitiy will NOT be sent again to the bot after sign in completes. From c1bd26454ccf6970e0fb92497d08d35aefa780bc Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:19 -0800 Subject: [PATCH 47/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 47a922cba..39c45ffc5 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -98,7 +98,7 @@ This is useful if the user should be signed in by default before attempting to i ### Manual Sign In -If the user should only be authenticated in certain scenarios then you can disable auto sign in by having the callback alway return false and trigger authentication manually. +If the user should only be authenticated in certain scenarios, you can disable auto sign in by having the callback always return false and trigger authentication manually. Here's an example of manually triggering sign in flow in an activity or action handler: From 2a7600b815d816a822f35bccc2eea6cef2ed52c6 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:25 -0800 Subject: [PATCH 48/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 39c45ffc5..0f10ac012 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -124,7 +124,7 @@ The `app.getTokenOrStartSignIn` method will attempt to get the access token if t If multiple settings are configured, then the user can be authenticated into multiple services through the manual triggering of the sign in flow. -**Note:** Once the sign in flow completes the application is NOT redirected back to it's previous task, when triggered from message activity or in action handler. This means that if user authentication is triggered through a message extension, then the same activity will be sent again to the bot after sign in completes. But if sign in is triggered when the incomming activity is a message then the same activitiy will NOT be sent again to the bot after sign in completes. +**Note:** Once the sign in flow completes when triggered from a message activity or an action handler, the application is NOT redirected back to its previous task. This means that if user authentication is triggered through a message extension, then the same activity will be sent again to the bot after sign in completes. But if sign in is triggered when the incoming activity is a message then the same activity will NOT be sent again to the bot after sign in completes. ### Handling sign in success or failure From 78040865161c20df0c1e4f2f588b84074746acdd Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:31 -0800 Subject: [PATCH 49/87] Update getting-started/CONCEPTS/USER-AUTH.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/USER-AUTH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/USER-AUTH.md b/getting-started/CONCEPTS/USER-AUTH.md index 0f10ac012..bccf257f9 100644 --- a/getting-started/CONCEPTS/USER-AUTH.md +++ b/getting-started/CONCEPTS/USER-AUTH.md @@ -128,7 +128,7 @@ If multiple settings are configured, then the user can be authenticated into mul ### Handling sign in success or failure -To handle the event when the user has signed successfully or failed to sign in simply register corresponding handler: +To handle the event when the user has signed in successfully or failed to sign in, simply register corresponding handler: **C#** ```cs From 6ceff9369b80de8d360bee3f3961a21a0e8ba24a Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:55:41 -0800 Subject: [PATCH 50/87] Update getting-started/CONCEPTS/TURNS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/TURNS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/TURNS.md b/getting-started/CONCEPTS/TURNS.md index 542ae22ea..842400cd7 100644 --- a/getting-started/CONCEPTS/TURNS.md +++ b/getting-started/CONCEPTS/TURNS.md @@ -48,7 +48,7 @@ async def on_message(context: TurnContext, state: TurnState): ### Turn State -The turn state object stores cookie-like data for the current turn. Just like the turn context, it is carried through the entire application logic, including the activity handlers and the AI System. Unlike the turn context, the turn state is not a fixed and is meant to be configured to each application specific use cases. +The turn state object stores cookie-like data for the current turn. Just like the turn context, it is carried through the entire application logic, including the activity handlers and the AI System. Unlike the turn context, the turn state is not fixed and is meant to be configured to each application-specific use case. It is common for apps to have conversation state, user state, and temp (temporary) state, but as a developer you can add or remove state objects to fit your needs. It is used to store information like the user's message, the conversation history, and any custom data configured by the application code. From 4a009eb9f97343e2a02f6dfbf13404046fc76281 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:57:56 -0800 Subject: [PATCH 51/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index fc5f96bdb..e628edd85 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -26,7 +26,7 @@ Some possible name suggestions for a pet golden retriever are: Prompt templates are a simple and powerful way to define and compose AI functions **using plain text**. You can use it to create natural language prompts, generate responses, extract -information, **invoke other prompts** or perform any other task that can be +information, **invoke other prompts,** or perform any other task that can be expressed with text. The language supports two basic features that allow you to include From e75e7b6687b48ba013fdb059eb3f72bdd887d203 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:58:04 -0800 Subject: [PATCH 52/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index e628edd85..728590258 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -45,7 +45,7 @@ Give me 3 name suggestions for my pet {{ $petName }}. ## Prompt Template Language You don't need to write any code or import any external libraries, just use the -curly braces {{...}} to embed expressions in your prompts. +double curly braces {{...}} to embed expressions in your prompts. Teams AI will parse your template and execute the logic behind it. This way, you can easily integrate AI into your apps with minimal effort and maximum flexibility. From ea0c344d2269bb1a22fe342278071988c285bbfa Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Thu, 18 Jan 2024 17:00:37 -0800 Subject: [PATCH 53/87] fix prompts --- getting-started/CONCEPTS/PROMPTS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index fc5f96bdb..b191a714a 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -7,13 +7,13 @@ Here's a prompt that asks the LLM for name suggestions: _Input:_ -```prompt +``` Give me 3 name suggestions for my pet golden retriever. ``` _Response:_ -```prompt +``` Some possible name suggestions for a pet golden retriever are: - Bailey From d724fdb7f764c7455dd8968dbfb90ffcd4a6e2b4 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:48:47 -0800 Subject: [PATCH 54/87] Update getting-started/CONCEPTS/ACTION-PLANNER.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTION-PLANNER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index 2101a9744..7400570e1 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -1,6 +1,6 @@ # Action Planner -The Action Planner is a powerful planner that uses a LLM to generate plans. It can trigger parameterized actions and send text based responses to the user. It supports the following advanced features: +The Action Planner is a powerful planner that uses an LLM to generate plans. It can trigger parameterized actions and send text-based responses to the user. It supports the following advanced features: ### [Prompt Management](./PROMPTS.md) From 13cbbc7a0283b87c42b84be0cc0e41de8f99f164 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:48:59 -0800 Subject: [PATCH 55/87] Update getting-started/CONCEPTS/ACTIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index 930e6b8fa..4e78157ce 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -18,7 +18,7 @@ public bool CreateList([ActionTurnState] ListState turnState, [ActionParameters] EnsureListExists(turnState, listName); - // Continues exectuion of next command in the plan. + // Continues execution of next command in the plan. return ""; } ``` From 11769479463fb4bd98ff7eda667a66987f4f40ca Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:49:34 -0800 Subject: [PATCH 56/87] Update getting-started/CONCEPTS/ACTION-PLANNER.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTION-PLANNER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index 7400570e1..7ed9c6b4c 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -15,7 +15,7 @@ or create an AutoGPT style agent (monologue). ### Validations Validators are used to validate the response returned by the LLM and can guarantee that the parameters passed to an action match a supplied schema. The validator used is automatically -selected based on the augmentation being used. Validators also prevent hallucinated action names +selected based on the augmentation being used. Validators also prevent hallucinated action names, making it impossible for the LLM to trigger an action that doesn't exist. ### Repair From a151fdf7cbafe7e4dbbcd177b4abf9512d454da4 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:49:45 -0800 Subject: [PATCH 57/87] Update getting-started/CONCEPTS/ACTIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index 4e78157ce..863d6fca4 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -2,7 +2,7 @@ An action is an atomic function that is registered to the AI System. It is a fundamental building block of a plan. -Here's an example of how an action to create a new list would look like in code. Call this action `createList`: +Here's an example of what an action creating a new list would look like in code. Call this action `createList`: ### C# From 9a17a54ee3d1115c434fd3e6261d6f749f7851bf Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:49:56 -0800 Subject: [PATCH 58/87] Update getting-started/CONCEPTS/ACTIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index 863d6fca4..d3c170c62 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -23,7 +23,7 @@ public bool CreateList([ActionTurnState] ListState turnState, [ActionParameters] } ``` -> Adding the `Action` attribute marks the method as an action. To register it to the AI System you have pass the instance object containing this method to the `AI.ImportActions(instance)` method. Alternatively you can use the `AI.RegisterAction(name, handler)` to register a single action. +> Adding the `Action` attribute marks the method as an action. To register it to the AI System you have pass the instance object containing this method to the `AI.ImportActions(instance)` method. Alternatively, you can use the `AI.RegisterAction(name, handler)` to register a single action. ### JS From 62c7ec512103037563ec5c574ff7ecada47cfd69 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:05 -0800 Subject: [PATCH 59/87] Update getting-started/CONCEPTS/ACTIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTIONS.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index d3c170c62..fc0b06895 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -45,15 +45,15 @@ app.ai.action("createList", async (context: TurnContext, state: ApplicationTurnS The user can register custom actions or override default actions in the system. Below is a list of default actions present: -| Action | Called when | -| --------------------- | ----------------------------------------------------------------------------------------------- | -| `___UnknownAction___` | An unknown action is predicted by the planner. | -| `___FlaggedInput___` | The input is flagged by the moderator. | -| `___FlaggedOutput___` | The output is flagged by the moderator. | -| `___HttpError___` | The planner encounters an HTTP response with status code >= `400` | -| `__TooManySteps__` | The planner task either executed too many steps or timed out. | -| `___PlanReady___` | The plan has been predicted by the planner and it has passed moderation. This can be overriden to mutate the plan before execution. | -| `___DO___` | The AI system is executing a plan with the DO command. Overriding this action will change how _all_ DO commands are handled. | +| Action | Called when | +| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `___UnknownAction___` | An unknown action is predicted by the planner. | +| `___FlaggedInput___` | The input is flagged by the moderator. | +| `___FlaggedOutput___` | The output is flagged by the moderator. | +| `___HttpError___` | The planner encounters an HTTP response with status code >= `400` | +| `__TooManySteps__` | The planner task either executed too many steps or timed out. | +| `___PlanReady___` | The plan has been predicted by the planner and it has passed moderation. This can be overriden to mutate the plan before execution. | +| `___DO___` | The AI system is executing a plan with the DO command. Overriding this action will change how _all_ DO commands are handled. | | `___SAY___` | The AI system is executing a plan with the SAY command. Overriding this action will change how _all_ SAY commands are handled. By default this will send the `response` message back to the user. | > Detailed description of each action can be found in the codebase. From 8b31736fca5e9d0a1f494e3fdd65942d62909ba1 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:17 -0800 Subject: [PATCH 60/87] Update getting-started/CONCEPTS/ACTIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTIONS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/getting-started/CONCEPTS/ACTIONS.md b/getting-started/CONCEPTS/ACTIONS.md index fc0b06895..7551dcaca 100644 --- a/getting-started/CONCEPTS/ACTIONS.md +++ b/getting-started/CONCEPTS/ACTIONS.md @@ -28,6 +28,7 @@ public bool CreateList([ActionTurnState] ListState turnState, [ActionParameters] ### JS [List Bot sample](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/samples/04.ai.d.chainedActions.listBot/src/index.ts#L153) + ```typescript app.ai.action("createList", async (context: TurnContext, state: ApplicationTurnState, parameters: ListAndItems) => { // Ex. create a list with name "Grocery Shopping". From 91583edccfb5a26a0e381f7a5d8981f0a6f59e4a Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:25 -0800 Subject: [PATCH 61/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index ce22e82fc..96759a498 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -1,6 +1,6 @@ # The `Application` class -The `Application` class encapsulates all the business logic for the application and it comprises of two major components, the _Activity Handler System_ and the _AI System_. +The `Application` class encapsulates all the business logic for the application and comprises of two major components, the _Activity Handler System_ and the _AI System_. ## The Activity Handler System From 1e411a76b3ddf6c6a33243b4402c8cd2b6fa3b27 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:34 -0800 Subject: [PATCH 62/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 96759a498..26fd2aff3 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -5,7 +5,7 @@ The `Application` class encapsulates all the business logic for the application ## The Activity Handler System -The activity handler system is the primary way to implement bot or message extension application logic. It is a set of methods and configuration that allows you to register callbacks (known as route handlers) which will trigger based on the incomming activity. These can be in the form of a message, message reaction, or virtually any interaction with the Teams app. +The activity handler system is the primary way to implement bot or message extension application logic. It is a set of methods and configurations that allows you to register callbacks (known as route handlers), which will trigger based on the incoming activity. These can be in the form of a message, message reaction, or virtually any interaction within the Teams app. Here's an example of registering a route handler that will run when the the user sends *"/login"* to the bot: From c0a3509fdc1d0018de73cbf07c5e3b158e4a5b90 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:43 -0800 Subject: [PATCH 63/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 26fd2aff3..964d51aa4 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -33,13 +33,13 @@ app.OnMessage("/login", async (ITurnContext turnContext, TurnState turnState, Ca The `Application` groups the route registration methods based on the specific feature groups: -| **Feature** | **Description** | -|-------------------|-----------------------------------------------------------------------------------------| -| Task Modules | Task module related activities like `task/fetch`. | +| **Feature** | **Description** | +| ----------------- | ---------------------------------------------------------------- | +| Task Modules | Task module related activities like `task/fetch`. | | Message Extension | Message extension activities like `composeExtension/query`. | | Meetings | Meeting activites like `application/vnd.microsoft.meetingStart`. | | AdaptiveCards | Adaptive card activities like `adaptiveCard/action`. | -| General | Generic activites like `message`. | +| General | Generic activites like `message`. | > To see all the route registration methods supported, see the migration docs ([JS](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/JS.md#activity-handler-methods)/[C#](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md#activity-handler-methods)). From 15e452525a01402a5a0bba72715a0a983a251b14 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:50:53 -0800 Subject: [PATCH 64/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 964d51aa4..3440b3ef8 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -50,7 +50,7 @@ The AI System is an optional component used to plug in LLM powered experiences l ## The Routing Logic -When an incoming activity reaches the server, the bot adapter handles the necessary authentication and creates a turn context object that encapsulates the activity details. Then the `Application`'s main method (`run()` in Javscript. `OnTurnAsync()` in C#) is called. It's logic can be broken down into these eight steps. +When an incoming activity reaches the server, the bot adapter handles the necessary authentication and creates a turn context object that encapsulates the activity details. Then the `Application`'s main method (`run()` in Javscript. `OnTurnAsync()` in C#) is called. Its logic can be broken down into these eight steps. 1. If configured in the application options, pulses of the `Typing` activity are sent to the user. 2. If configured in the application options, the @mention is removed from the incoming message activity. From 539c84fa8b8b7d902655fa69bb3bf12e9512a9e9 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:02 -0800 Subject: [PATCH 65/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 3440b3ef8..15c97959a 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -55,7 +55,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 1. If configured in the application options, pulses of the `Typing` activity are sent to the user. 2. If configured in the application options, the @mention is removed from the incoming message activity. 3. The turn state is loaded using the configured turn state factory. -4. If user authentication is configured, then attemp to sign the user in. If there user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. +4. If user authentication is configured, then attempt to sign the user in. If the user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. 5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. 6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. 7. If no route is triggered, the incomming activity is a message, and the AI System is configured, then it is invoked by calling the `AI.run()` method. From 4990b61d681aa0a9eb707be90be5806d667ee093 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:11 -0800 Subject: [PATCH 66/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 15c97959a..4739c10ff 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -58,7 +58,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 4. If user authentication is configured, then attempt to sign the user in. If the user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. 5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. 6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. -7. If no route is triggered, the incomming activity is a message, and the AI System is configured, then it is invoked by calling the `AI.run()` method. +7. If no route is triggered, the incoming activity is a message, and an AI System is configured, then it is invoked by calling the `AI.run()` method. 8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. From cf09c27d5d136f1ce4d232d72524217ce3eb6877 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:19 -0800 Subject: [PATCH 67/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index 4739c10ff..ffce62a82 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -59,7 +59,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. 6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. 7. If no route is triggered, the incoming activity is a message, and an AI System is configured, then it is invoked by calling the `AI.run()` method. -8. The `AfterTurnAsync` activity handler is executed. If it return true, save turn state to storage. +8. The `AfterTurnAsync` activity handler is executed. If it returns true, save turn state to storage. > Note: _End the turn_ means that the main method has terminated execution and so the application has completed processing the incomming activity. From ac30a251bbdf4f31e960fb18eeb63dc73f2b510a Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:26 -0800 Subject: [PATCH 68/87] Update getting-started/CONCEPTS/APPLICATION.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/APPLICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index ffce62a82..b0848e839 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -62,7 +62,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 8. The `AfterTurnAsync` activity handler is executed. If it returns true, save turn state to storage. -> Note: _End the turn_ means that the main method has terminated execution and so the application has completed processing the incomming activity. +> Note: _End the turn_ means that the main method has terminated execution and so the application has completed processing the incoming activity. > Note: To learn about what a *turn* is, see [TURNS](TURNS.md). From bb53dd516b406cad72642dcf6f162943808085bb Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:32 -0800 Subject: [PATCH 69/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 1e30474c9..97e7f6d4b 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -13,7 +13,7 @@ This augmentation allows the model to return a sequence of actions to perform. I Here's an example of the `actions.json` file from the [Light Bot](https://github.com/microsoft/teams-ai/blob/77339da9e3e03bfd7f629fc796cfebdcd2891afb/js/samples/04.ai.c.actionMapping.lightBot/src/prompts/sequence/actions.json) sample: -```js +```json [ { "name": "LightsOn", From 693e2fab4f7c19d3253dc137ce5ff19f4adeff9b Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:38 -0800 Subject: [PATCH 70/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 97e7f6d4b..ffedbe964 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -42,7 +42,7 @@ Here's an example of the `actions.json` file from the [Light Bot](https://github ] ``` -It defines three actions, `LightsOn`, `LightsOff` and `Pause`. The `Pause` action requires the `time` parameter, while the other two doesn't. +It defines three actions, `LightsOn`, `LightsOff` and `Pause`. The `Pause` action requires the `time` parameter, while the other two don't. These actions are then appended to the prompt text in runtime. This is text added to end of the prompt text: From b0ccfab75a1071280f19f506732b9dafd603b73c Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:43 -0800 Subject: [PATCH 71/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index ffedbe964..5e090697c 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -44,7 +44,7 @@ Here's an example of the `actions.json` file from the [Light Bot](https://github It defines three actions, `LightsOn`, `LightsOff` and `Pause`. The `Pause` action requires the `time` parameter, while the other two don't. -These actions are then appended to the prompt text in runtime. This is text added to end of the prompt text: +These actions are then appended to the prompt text during runtime. This is text added to end of the prompt text: ```txt actions: From fac9fdbef5210242c62ee3035a19c7bafe78dcc4 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:48 -0800 Subject: [PATCH 72/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 5e090697c..4f6374a60 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -80,7 +80,7 @@ Use the actions above to create a plan in the following JSON format: ``` > Note: When the prompt is rendered, the above text is compressed to reduce token usage. -The first section lists the actions in yaml structure. The second sections tells the model to return a plan object of the following schema. +The first section lists the actions in yaml structure. The second section tells the model to return a plan object of the following schema. ### Configuring your prompt From 3349accbb45bb2cbd5389125e35a00b5c78c3166 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:51:56 -0800 Subject: [PATCH 73/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 4f6374a60..a86bc68dd 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -117,7 +117,7 @@ The learn more about the action object schema see the corresponding typescript i ## Monologue Augmentation -This augmentation adds support for an inner monologue to the prompt. The monologue helps the LLM to perform chain-of-thought reasoning across multiple turns of conversation. It does this by appending instructions to the prompt text in runtime. It tells the model to explicitly show it's thought, reasoning & plan in response to the user's message and predict the next action to execute. If looping is configured, then the predicted action can guide the model to predict the next action by returning the instruction as a string in the action handler callback. The loop will terminate as soon as the model predicts a *SAY* action, which sends the response back to the user. +This augmentation adds support for an inner monologue to the prompt. The monologue helps the LLM perform chain-of-thought reasoning across multiple turns of conversation. It does this by appending instructions to the prompt text during runtime. It tells the model to explicitly show it's thought, reasoning and plan in response to the user's message, then predict the next action to execute. If looping is configured, then the predicted action can guide the model to predict the next action by returning the instruction as a string in the action handler callback. The loop will terminate as soon as the model predicts a *SAY* action, which sends the response back to the user. Using the `actions.json` example from abovce, the instructions appended to the prompt look like this: From 33330e6fad0b33ee636d2c4fdca7f6d286e95a6b Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:53:24 -0800 Subject: [PATCH 74/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index a86bc68dd..df2c9e53f 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -160,7 +160,7 @@ Response Format: > Note: When the prompt is rendered, the above text is compressed to reduce token usage. -The first section lists the actions in yaml structure. The second sections tells the model to return a plan object of the following schema. +The first section lists the actions in yaml structure. The second section tells the model to return a plan object of the following schema. ### Configuring your prompt From 4a9f44c89519fdd39c68c5db9d14766bfcf9b26a Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:53:33 -0800 Subject: [PATCH 75/87] Update getting-started/CONCEPTS/MODERATOR.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/MODERATOR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index 249aea7c6..f32bbc24f 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -45,7 +45,7 @@ var app = new ApplicationBuilder() .WithAIOptions(aIOptions) .Build(); ``` -> This snippet is taken from the [Twenty Questions bot] sample +> This snippet is taken from the [Twenty Questions bot] sample. > Note for C# application, the moderator should be registered to the Web app's service collection as a singleton. ## Azure Content Safety Moderator From a492c086397a0d2a92e87c081f3255bde8e4e73c Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:53:40 -0800 Subject: [PATCH 76/87] Update getting-started/CONCEPTS/MODERATOR.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/MODERATOR.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/getting-started/CONCEPTS/MODERATOR.md b/getting-started/CONCEPTS/MODERATOR.md index f32bbc24f..b2e3940c6 100644 --- a/getting-started/CONCEPTS/MODERATOR.md +++ b/getting-started/CONCEPTS/MODERATOR.md @@ -4,12 +4,11 @@ The `Moderator` is responsible for reviewing the input prompt and approving the The AI system is such that developers can create their own moderator class by simply implementing the moderator interface. The library has a few native moderators that can be used out of the box: -| Name | Description | -|-----------------------------|-----------------------------------------| -| [OpenAIModerator](#openai-moderator) | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | +| Name | Description | +| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| [OpenAIModerator](#openai-moderator) | Wrapper around OpenAI's [Moderation API](https://platform.openai.com/docs/api-reference/moderations). | | [AzureContentSafetyModerator](#azure-content-safety-moderator) | Wrapper around [Azure Content Safety](https://learn.microsoft.com/en-us/azure/ai-services/content-safety/overview) API | - ## OpenAI Moderator Here's an example of configuring the `OpenAIModerator`: From 9add9eb6ba24f3ef9a3c6868fec2a908214fe507 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:53:48 -0800 Subject: [PATCH 77/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index df2c9e53f..4eb0167a2 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -119,7 +119,7 @@ The learn more about the action object schema see the corresponding typescript i This augmentation adds support for an inner monologue to the prompt. The monologue helps the LLM perform chain-of-thought reasoning across multiple turns of conversation. It does this by appending instructions to the prompt text during runtime. It tells the model to explicitly show it's thought, reasoning and plan in response to the user's message, then predict the next action to execute. If looping is configured, then the predicted action can guide the model to predict the next action by returning the instruction as a string in the action handler callback. The loop will terminate as soon as the model predicts a *SAY* action, which sends the response back to the user. -Using the `actions.json` example from abovce, the instructions appended to the prompt look like this: +Using the `actions.json` example from abovce, the instructions appended to the prompt look like the text below. These actions are then used and appended to the prompt text in runtime. This is text added to end of the prompt text: From 8eb8fa718de1aae706b5cd962adf2059e6ebfbb0 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:15:10 -0800 Subject: [PATCH 78/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index 8099f2132..357caedbf 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -68,7 +68,7 @@ Here's how to define variables in code: In an *action* or *route handler* where the turn state object is available: ```cs -state.Temp.Post = "Lorem Ipsium..." +state.Temp.Post = "Lorem Ipsum..." ``` The usage in the prompt: From b347f42efc5086d37820a6caf9eedf9a2e7f90f7 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:17:12 -0800 Subject: [PATCH 79/87] Update getting-started/CONCEPTS/AUGMENTATIONS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index 4eb0167a2..ffc672784 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -112,7 +112,7 @@ There are two steps to use sequence augmentation in your prompt: ] ``` -The learn more about the action object schema see the corresponding typescript interface [ChatCompletionAction](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/packages/teams-ai/src/models/ChatCompletionAction.ts#L14). +To learn more about the action object schema see the corresponding typescript interface [ChatCompletionAction](https://github.com/microsoft/teams-ai/blob/0fca2ed09d327ecdc682f2b15eb342a552733f5e/js/packages/teams-ai/src/models/ChatCompletionAction.ts#L14). ## Monologue Augmentation From 914c85051864b77323e0b23f4d129a58ae7b77e3 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:17:38 -0800 Subject: [PATCH 80/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index 357caedbf..39b2868b5 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -76,7 +76,7 @@ The usage in the prompt: This is the user's post: {{ $post }} ``` -> Note: The `turnState.Temp.Post = ...` updates a dictionary with the `post` key under the hood from the [GPT Message Extension sample](https://github.com/microsoft/teams-ai/blob/a20f8715d3fe81e11c330853e3930e22abe298af/dotnet/samples/04.ai.b.messageExtensions.gptME/ActivityHandlers.cs#L156). +> Note: The `turnState.Temp.Post = ...` updates a dictionary with the `post` key under the hood from the [AI Message Extension sample](https://github.com/microsoft/teams-ai/blob/a20f8715d3fe81e11c330853e3930e22abe298af/dotnet/samples/04.ai.b.messageExtensions.gptME/ActivityHandlers.cs#L156). **Javascript** From 835fce411f39f7ae56ded83be9ffb29fbe9b9c6f Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:18:04 -0800 Subject: [PATCH 81/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index 39b2868b5..03ed98bec 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -82,7 +82,7 @@ This is the user's post: {{ $post }} ```typescript app.beforeTurn((context, state) => { - state.temp.post = "Lorem Ipsium..."; + state.temp.post = "Lorem Ipsum..."; }); ``` From 81a574d3991c0acd221685af44ff17729c1c910e Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:18:31 -0800 Subject: [PATCH 82/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index 03ed98bec..eaf8e335a 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -96,7 +96,7 @@ You can simply add to the `state.temp` object, and it will be accessible from th **Default Variables** -The following are variables accesible in the prompt template without having to manually configure. These are pre-defined in the turn state and populated by the library. Users can override them by changing it in the turn state. +The following are variables accessible in the prompt template without having to manually configure them. These are pre-defined in the turn state and populated by the library. Users can override them by changing it in the turn state. | Variable name | Description | | ------------- | ----------------------------------------------------------------- | From 2dbadfb10cfef872db74d16b3d8823e498a61d65 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:19:01 -0800 Subject: [PATCH 83/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index eaf8e335a..30a20c71b 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -98,10 +98,10 @@ You can simply add to the `state.temp` object, and it will be accessible from th The following are variables accessible in the prompt template without having to manually configure them. These are pre-defined in the turn state and populated by the library. Users can override them by changing it in the turn state. -| Variable name | Description | -| ------------- | ----------------------------------------------------------------- | -| `input` | Input passed from the user to the AI Library. | -| `lastOutput` | Output returned from the last executed action. | +| Variable name | Description | +| ------------- | ---------------------------------------------- | +| `input` | Input passed from the user to the AI Library. | +| `lastOutput` | Output returned from the last executed action. | ### Function calls From 776beaa9dc6daae9a94538ee08359296ee89cde9 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:19:43 -0800 Subject: [PATCH 84/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index 30a20c71b..aabc1f5d1 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -105,7 +105,7 @@ The following are variables accessible in the prompt template without having to ### Function calls -To call an external function and embed the result in your text, use the `{{ functionName }}` syntax. For example if you have a function called `diceRoll` that returns a random number between 1 and 6, you can write: +To call an external function and embed the result in your text, use the `{{ functionName }}` syntax. For example, if you have a function called `diceRoll` that returns a random number between 1 and 6, you can write: `The dice roll has landed on: {{ diceRoll }}` From 933282a11c6995da79e17c52042bec6e458fde03 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:20:34 -0800 Subject: [PATCH 85/87] Update getting-started/CONCEPTS/PROMPTS.md Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/PROMPTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index aabc1f5d1..c9c40cab3 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -132,7 +132,7 @@ prompts.addFunction('diceRoll', async (context, state, functions, tokenizer, arg # Creating Prompt Templates -Each prompt template is a folder with two files, `skprompt.txt` and `config.json`. The folder name is the prompt template's name that can be referred in code. The `skprompt.txt` file contains the prompt's text, which can contain natural language or prompt template syntax as defined in the previous section. The `config.json` file specifies the prompt completion configuration. +Each prompt template is a folder with two files, `skprompt.txt` and `config.json`. The folder name is the prompt template's name which can be referred to in your code. The `skprompt.txt` file contains the prompt's text, which can contain natural language or prompt template syntax as defined in the previous section. The `config.json` file specifies the prompt completion configuration. Here's an example of a prompt template from the [Twenty Questions](https://github.com/microsoft/teams-ai/blob/c5ec11842b808e48cd214b3cb52da84e5811da33/js/samples/04.e.twentyQuestions) sample. From e4168f54431be849194e24b70031799b14096017 Mon Sep 17 00:00:00 2001 From: singhk97 <115390646+singhk97@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:22:58 -0800 Subject: [PATCH 86/87] Apply suggestions from code review Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com> --- getting-started/CONCEPTS/ACTION-PLANNER.md | 2 +- getting-started/CONCEPTS/APPLICATION.md | 4 ++-- getting-started/CONCEPTS/AUGMENTATIONS.md | 2 +- getting-started/CONCEPTS/PLANNER.md | 14 +++++++------- getting-started/CONCEPTS/PROMPTS.md | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/getting-started/CONCEPTS/ACTION-PLANNER.md b/getting-started/CONCEPTS/ACTION-PLANNER.md index 7ed9c6b4c..a3d443ef2 100644 --- a/getting-started/CONCEPTS/ACTION-PLANNER.md +++ b/getting-started/CONCEPTS/ACTION-PLANNER.md @@ -4,7 +4,7 @@ The Action Planner is a powerful planner that uses an LLM to generate plans. It ### [Prompt Management](./PROMPTS.md) -The Action Planner has a built-in prompt management system that supports creating prompt templates as folders in the file system. A prompt template is the prompt text along with all the configurations for completion with the LLM model. Dynamic prompts are also supported with template variables and functions. +The Action Planner has a built-in prompt management system that supports creating prompt templates as folders in the file system. A prompt template is the prompt text along with all the configurations for completion with the LLM model. Dynamic prompts also support template variables and functions. ### [Augmentations](./AUGMENTATIONS.md) Augmentations virtually eliminate the need for prompt engineering. Prompts diff --git a/getting-started/CONCEPTS/APPLICATION.md b/getting-started/CONCEPTS/APPLICATION.md index b0848e839..90fc4ef82 100644 --- a/getting-started/CONCEPTS/APPLICATION.md +++ b/getting-started/CONCEPTS/APPLICATION.md @@ -41,7 +41,7 @@ The `Application` groups the route registration methods based on the specific fe | AdaptiveCards | Adaptive card activities like `adaptiveCard/action`. | | General | Generic activites like `message`. | -> To see all the route registration methods supported, see the migration docs ([JS](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/JS.md#activity-handler-methods)/[C#](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md#activity-handler-methods)). +> To see all the route registration methods supported, see the migration docs ([JS](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/JS.md#activity-handler-methods) | [C#](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md#activity-handler-methods)). In general, the activity handler system is all that is needed to have a functional bot or message extension. @@ -57,7 +57,7 @@ When an incoming activity reaches the server, the bot adapter handles the necess 3. The turn state is loaded using the configured turn state factory. 4. If user authentication is configured, then attempt to sign the user in. If the user is already signed in, retrieve the access token and continue to step 5. Otherwise, start the sign in flow and end the current turn. 5. The `beforeTurn` activity handler is executed. If it returns false, save turn state to storage and end the turn. -6. All the routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. +6. All routes are iterated over and if a selector function is triggered, then the corresponding route handler is executed. 7. If no route is triggered, the incoming activity is a message, and an AI System is configured, then it is invoked by calling the `AI.run()` method. 8. The `AfterTurnAsync` activity handler is executed. If it returns true, save turn state to storage. diff --git a/getting-started/CONCEPTS/AUGMENTATIONS.md b/getting-started/CONCEPTS/AUGMENTATIONS.md index ffc672784..c37675980 100644 --- a/getting-started/CONCEPTS/AUGMENTATIONS.md +++ b/getting-started/CONCEPTS/AUGMENTATIONS.md @@ -9,7 +9,7 @@ It is recommended to read the [AI System](./AI-SYSTEM.md) and [Action Planner](. ## Sequence Augmentation -This augmentation allows the model to return a sequence of actions to perform. It does this by appending instructions to the prompt text in runtime. These instructions guide the model to generate a plan object that uses actions defined in the `actions.json` file from the prompt template folder. +This augmentation allows the model to return a sequence of actions to perform. It does this by appending instructions to the prompt text during runtime. These instructions guide the model to generate a plan object that uses actions defined in the `actions.json` file from the prompt template folder. Here's an example of the `actions.json` file from the [Light Bot](https://github.com/microsoft/teams-ai/blob/77339da9e3e03bfd7f629fc796cfebdcd2891afb/js/samples/04.ai.c.actionMapping.lightBot/src/prompts/sequence/actions.json) sample: diff --git a/getting-started/CONCEPTS/PLANNER.md b/getting-started/CONCEPTS/PLANNER.md index 29dc8f273..00e766a7d 100644 --- a/getting-started/CONCEPTS/PLANNER.md +++ b/getting-started/CONCEPTS/PLANNER.md @@ -1,18 +1,18 @@ # Planner -The planner is takes in the user's ask and returns back a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into series of steps that complete a goal. +The planner receives the user's ask and returns a plan on how to accomplish the request. The user's ask is in the form of a prompt or prompt template. It does this by using AI to mix and match atomic functions (called _actions_) registered to the AI system so that it can recombine them into a series of steps that complete a goal. This is a powerful concept because it allows you to create actions that can be used in ways that you as a developer may not have thought of. -For instance, If you have a task and `Summarize` & `SendEmail` action, the planner could combine them to create workflows like "Rewrite the following report into a short paragraph, and email it to johndoe@email.com" without you explicitly having to write code for those scenarios. +For instance, If you have a task with `Summarize` & `SendEmail` actions, the planner could combine them to create workflows like "Rewrite the following report into a short paragraph and email it to johndoe@email.com" without you explicitly having to write code for those scenarios. The planner is an extensible part of the AI system. This means that a custom planner can be created for your specific needs. Out of the box, the Teams AI library supports the following planners. -| Planner | Description | C# | JS/TS | Python | -| ------------------ | --------------------------------------------------------------------------------------- | --- | ----- | ------ | -| [ActionPlanner](./ACTION-PLANNER.md) | Powerful planner that uses LLMs to generate plans. It has a built-in prompt management, LLM modularity, amongst other features. | ✅ | ✅ | ❌ | -| AssistantsPlanner | A planner that uses OpenAI's Assistants APIs to generate plans. | ✅ | ✅ | ❌ | +| Planner | Description | C# | JS/TS | Python | +| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | --- | ----- | ------ | +| [ActionPlanner](./ACTION-PLANNER.md) | Powerful planner that uses LLMs to generate plans. It has a built-in prompt management, LLM modularity, amongst other features. | ✅ | ✅ | ❌ | +| AssistantsPlanner | A planner that uses OpenAI's Assistants APIs to generate plans. | ✅ | ✅ | ❌ | ### Plan @@ -37,7 +37,7 @@ A plan is the entity that is generated by the planner. It is a JSON object of th } ``` -A plan consists of two types of commands: +A plan consists of two types of commands and their entities: - **SAY**: Sends a message to the user. - _response_: The string message to send. diff --git a/getting-started/CONCEPTS/PROMPTS.md b/getting-started/CONCEPTS/PROMPTS.md index c9c40cab3..efdad7742 100644 --- a/getting-started/CONCEPTS/PROMPTS.md +++ b/getting-started/CONCEPTS/PROMPTS.md @@ -147,7 +147,7 @@ GuessCount: {{$conversation.guessCount}} RemainingGuesses: {{$conversation.remainingGuesses}} Secret: {{$conversation.secretWord}} -Answer the humans question but do not mention the secret word. +Answer the human's question but do not mention the secret word. ``` *config.json* @@ -172,7 +172,7 @@ Answer the humans question but do not mention the secret word. > Note that the configuration properties in the file do not include all the possible configurations. To learn more about the description of each configuration and all the supported configurations see the [`PromptTemplatConfig`](https://github.com/microsoft/teams-ai/blob/2d43f5ca5b3bf27844f760663641741cae4a3243/js/packages/teams-ai/src/prompts/PromptTemplate.ts#L46C18-L46C39) Typescript interface. -These files can be found under the `src/prompts/chat/` folder. So this prompt template's name is `chat`. Then to plug these files in the Action Planner, the prompt manager has to be created with the folder path specified and then passed into the Action Planner constructor: +These files can be found under the `src/prompts/chat/` folder. So, this prompt template's name is `chat`. Then, to plug these files in the Action Planner, the prompt manager has to be created with the folder path specified and then passed into the Action Planner constructor: **C#** ```cs From 9be32e75a83fcddcb7cc538891517ccca7de7c77 Mon Sep 17 00:00:00 2001 From: Kavin Singh Date: Fri, 19 Jan 2024 10:25:16 -0800 Subject: [PATCH 87/87] remove uneccessry readme --- js/packages/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 js/packages/README.md diff --git a/js/packages/README.md b/js/packages/README.md deleted file mode 100644 index 7bab131bf..000000000 --- a/js/packages/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# [JS SDK](./teams-ai/README.md) - -# [JS SAMPLES](../samples/)