Skip to content

Commit

Permalink
Merge branch 'main' into PYTHON
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebo committed Oct 5, 2023
2 parents d73eed0 + a170848 commit d904aa2
Show file tree
Hide file tree
Showing 28 changed files with 297 additions and 230 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Initialize CodeQL
uses: github/codeql-action/init@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
uses: github/codeql-action/init@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9
with:
languages: csharp
- name: Setup .NET
Expand All @@ -49,6 +49,6 @@ jobs:
working-directory: dotnet/packages/Microsoft.TeamsAI/
run: dotnet build Microsoft.TeamsAI.sln --configuration Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
uses: github/codeql-action/analyze@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9
with:
category: "/language:csharp"
4 changes: 2 additions & 2 deletions .github/workflows/js-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Initialize CodeQL
uses: github/codeql-action/init@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
uses: github/codeql-action/init@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
uses: github/codeql-action/analyze@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9
with:
category: "/language:javascript"
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
uses: github/codeql-action/upload-sarif@ddccb873888234080b77e9bc2d4764d5ccaaccf9 # v2.21.9
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion dotnet/samples/01.messaging.echoBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It also illustrates a few of the Teams specific calls you can make from your bot

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way: You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way: You can find the step by step instructions here:
[Setup Instructions](../README.md).

## Interacting with the Bot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This sample shows how to incorporate a basic Message Extension app into a Micros

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
[Setup Instructions](../README.md).

## Interacting with the Message Extension
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/03.adaptiveCards.a.typeAheadBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This sample shows how to incorporate the typeahead search functionality in Adapt

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).

## Interacting with the bot

Expand Down
112 changes: 57 additions & 55 deletions dotnet/samples/04.ai.a.teamsChefBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,9 @@ This is a conversational bot for Microsoft Teams that thinks it's a Chef to help

This sample illustrates basic conversational bot behavior in Microsoft Teams. The bot is built to allow GPT to facilitate the conversation on its behalf, using only a natural language prompt file to guide it.

It shows SDK capabilities like:

<details open>
<summary><h3>Bot scaffolding</h3></summary>
Throughout the 'Program.cs' file you'll see the scaffolding created to run a simple conversational bot, e.g. storage, authentication, and conversation state.
</details>

</details>
<details open>
<summary><h3>Prompt engineering</h3></summary>
The 'Prompts/Chat/skprompt.txt' file has descriptive prompt engineering that, in plain language and with minor training, instructs GPT how the bot should conduct itself and facilitate conversation.

#### skprompt.txt

```text
The following is a conversation with an AI assistant, its name is Teams Chef.
Teams Chef is an expert in Microsoft Teams apps development and the Human is junior developer learning Microsoft Teams development for the first time.
Teams Chef should always reply by explaining new concepts in simple terms using cooking as parallel concepts.
Teams Chef should always greet the human, ask them their name, and then guide the junior developer in his journey to build new apps for Microsoft Teams.
{{$history}}
Human: {{$input}}
AI:
```

- The major section ("*The following is ... for Microsoft Teams.*") defines the basic direction, to tell how AI should behave on human's input.
- The final section ("*Human: ... AI: ...*") defines the input of current turn. The variable "*{{$history}}*" lets AI know the context about previous turns.
- The variables "*{{input}}*", and "*{{history}}*" are automatically resolved from `TurnState.Temp`.

</details>
<details open>
<summary><h3>Conversational session history</h3></summary>
Because this sample leaves the conversation to GPT, the bot simply facilitates user conversation as-is. But because it includes the 'skprompt.txt' file to guide it, GPT will store and leverage session history appropriately.

For example, let's say the user's name is "Dave". The bot might carry on the following conversation:

```
AI: Hi there! My name is Teams Chef. It's nice to meet you. What's your name?
DAVE: My name is Dave.
AI:Hi Dave! It's great to meet you. Let me help you get started with Microsoft Teams app development. Have you ever cooked before?
DAVE: No, not yet, why?
AI:Cooking is a great way to learn ...
DAVE: Which kind of apps can I build for Microsoft Teams?
AI: Great question! You can build a variety ...
```

Notice that the bot remembered Dave's first message when responding to the second.

</details>
<details open>
<summary><h3>Localization across languages</h3></summary>
Because this sample leverages GPT for all its natural language modelling, the user can talk to an AI bot in any language of their choosing. The bot will understand and respond appropriately with no additional code required.
</details>

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).

Expand Down Expand Up @@ -129,6 +75,62 @@ To configure the Azure resources to have OpenAI environment variables:

1. In `./env/.env.dev.user` file, paste your [OpenAI API Key](https://openai.com/api/) to the environment variable `SECRET_OPENAI_KEY=`.

## Appendix

Here's a list of the different capabilities shown in this sample:

<details close>
<summary><h5>Bot scaffolding</h5></summary>
Throughout the 'Program.cs' file you'll see the scaffolding created to run a simple conversational bot, e.g. storage, authentication, and conversation state.
</details>

</details>
<details close>
<summary><h5>Prompt engineering</h5></summary>
The 'Prompts/Chat/skprompt.txt' file has descriptive prompt engineering that, in plain language and with minor training, instructs GPT how the bot should conduct itself and facilitate conversation.

#### skprompt.txt

```text
The following is a conversation with an AI assistant, its name is Teams Chef.
Teams Chef is an expert in Microsoft Teams apps development and the Human is junior developer learning Microsoft Teams development for the first time.
Teams Chef should always reply by explaining new concepts in simple terms using cooking as parallel concepts.
Teams Chef should always greet the human, ask them their name, and then guide the junior developer in his journey to build new apps for Microsoft Teams.

{{$history}}
Human: {{$input}}
AI:
```

- The major section ("*The following is ... for Microsoft Teams.*") defines the basic direction, to tell how AI should behave on human's input.
- The final section ("*Human: ... AI: ...*") defines the input of current turn. The variable "*{{$history}}*" lets AI know the context about previous turns.
- The variables "*{{input}}*", and "*{{history}}*" are automatically resolved from `TurnState.Temp`.

</details>
<details close>
<summary><h5>Conversational session history</h5></summary>
Because this sample leaves the conversation to GPT, the bot simply facilitates user conversation as-is. But because it includes the 'skprompt.txt' file to guide it, GPT will store and leverage session history appropriately.

For example, let's say the user's name is "Dave". The bot might carry on the following conversation:

```
AI: Hi there! My name is Teams Chef. It's nice to meet you. What's your name?
DAVE: My name is Dave.
AI:Hi Dave! It's great to meet you. Let me help you get started with Microsoft Teams app development. Have you ever cooked before?
DAVE: No, not yet, why?
AI:Cooking is a great way to learn ...
DAVE: Which kind of apps can I build for Microsoft Teams?
AI: Great question! You can build a variety ...
```

Notice that the bot remembered Dave's first message when responding to the second.

</details>
<details close>
<summary><h5>Localization across languages</h5></summary>
Because this sample leverages GPT for all its natural language modelling, the user can talk to an AI bot in any language of their choosing. The bot will understand and respond appropriately with no additional code required.
</details>

## Further reading

- [Teams Toolkit overview](https://aka.ms/vs-teams-toolkit-getting-started)
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04.ai.b.messageExtensions.gptME/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Post:

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
[Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04.ai.d.chainedActions.listBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This sample shows how to incorporate basic conversational flow into a Teams appl

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here: [Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).

Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04.ai.e.chainedActions.devOpsBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ AI:

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
[Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04.e.twentyQuestions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AI:

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
[Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04.q.questBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The following player actions are supported:

## Set up instructions

All the samples in for the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
All the samples in the C# .NET SDK can be set up in the same way. You can find the step by step instructions here:
[Setup Instructions](../README.md).

Note that, this sample requires AI service so you need one more pre-step before Local Debug (F5).
Expand Down
19 changes: 9 additions & 10 deletions dotnet/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ In this folder you will find various examples showcasing the different capabilit

`git clone https://github.com/Microsoft/teams-ai.git`

2. Navigate to the `teams-ai/dotnet/samples` folder, pick a sample (ex. `01.a.echoBot`) and open the `.sln` file.

By this point you should have your sample open in your IDE of choice.
2. Pick your sample from the `dotnet/samples/` folder.

There are a few ways to get the application up and running. The latest way is using Teams ToolKit with Visual Studio. However you can also set it up manually. You can find instructions for both below:

Expand All @@ -24,16 +22,17 @@ There are a few ways to get the application up and running. The latest way is us

#### Additional Prerequisites

- [Visual Studio 2022 17.7.0 Preview 3.0](https://visualstudio.microsoft.com/vs/preview/)
- Teams Toolkit extension (installed through the Visual Studio installer)
- Select Microsoft Teams development tools under ASP.NET and web development.
- ![Teams Toolkit Installation](/dotnet/samples/assets/ttk-install.png)
- Visual Studio 2022 17.7.0 (or a greater version)
- [Teams Toolkit extension](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)

#### Steps

1. Open the solution in Visual Studio. (For example `EchoBot.sln`).
- Ensure that you set the appropriate config values (ex Azure OpenAI API key). You can find specific instructions in the sample readme under the `Set up instructions` section.
1. In the debug dropdown menu, select `Dev Tunnels > Create A Tunnel` (set authentication type to Public) or select an existing public dev tunnel
- Ensure that you set the appropriate config values (ex Azure OpenAI API key). You can find specific instructions in the sample readme under the `Set up instructions` section. If you can't find this section, then it means that the bot does not need them.
1. In the debug dropdown menu, select `Dev Tunnels > Create A Tunnel` (set authentication type to Public) or select an existing public dev tunnel.

![image](https://github.com/microsoft/teams-ai/assets/115390646/d7246d38-8276-4b2a-bc22-b72f36aa41b9)

1. Right-click your project and select `Teams Toolkit > Prepare Teams App Dependencies`
1. If prompted, sign in with a Microsoft 365 account for the Teams organization you want
to install the app to.
Expand All @@ -43,7 +42,7 @@ There are a few ways to get the application up and running. The latest way is us
> a free program to get your own dev environment sandbox that includes Teams.
4. Press F5, or select the `Debug > Start` Debugging menu in Visual Studio
5. In the launched browser, select the Add button to load the app in Teams
5. In the launched browser, select the `Add` button to load the app in Teams
6. This should redirect you to a chat window with the bot.
</details>

Expand Down
14 changes: 7 additions & 7 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
"devDependencies": {
"@azure/logger": "^1.0.2",
"@azure/ms-rest-js": "2.7.0",
"@microsoft/api-extractor": "^7.37.0",
"@microsoft/api-extractor": "^7.38.0",
"@standardlabs/is-private": "^1.0.1",
"@types/jsonwebtoken": "9.0.3",
"@types/lodash": "^4.14.199",
"@types/mocha": "^10.0.1",
"@types/sinon": "^10.0.17",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"applicationinsights": "^2.7.3",
"@types/mocha": "^10.0.2",
"@types/sinon": "^10.0.18",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"applicationinsights": "^2.8.0",
"browserify": "^17.0.0",
"chai": "^4.3.8",
"chai": "^4.3.10",
"depcheck": "^1.4.6",
"eslint": "^8.50.0",
"eslint-config-prettier": "^8.10.0",
Expand Down
6 changes: 3 additions & 3 deletions js/packages/teams-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"dependencies": {
"axios": "^1.5.0",
"axios": "^1.5.1",
"botbuilder": "^4.20.1",
"botbuilder-dialogs": "^4.20.1",
"gpt-3-encoder": "^1.1.4",
Expand All @@ -33,11 +33,11 @@
},
"devDependencies": {
"@types/jsonwebtoken": "^9.0.3",
"@types/node": "^20.6.5",
"@types/node": "^20.8.2",
"eslint": "^8.50.0",
"jsonwebtoken": "^9.0.2",
"typescript": "^5.2.2",
"@types/mocha": "^10.0.1",
"@types/mocha": "^10.0.2",
"@types/assert": "^1.5.7",
"mocha": "10.2.0",
"nyc": "^15.1.0",
Expand Down
2 changes: 1 addition & 1 deletion js/samples/01.messaging.a.echoBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/dotenv": "8.2.0",
"@types/restify": "8.5.7",
"@types/restify": "8.5.8",
"nodemon": "~3.0.1",
"typescript": "^5.2.2",
"ts-node": "^10.9.1"
Expand Down
4 changes: 2 additions & 2 deletions js/samples/02.messageExtensions.a.searchCommand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"dotenv": "^16.3.1",
"replace": "~1.2.0",
"restify": "~11.1.0",
"axios": "^1.5.0"
"axios": "^1.5.1"
},
"devDependencies": {
"@types/dotenv": "6.1.1",
"@types/restify": "8.5.7",
"@types/restify": "8.5.8",
"nodemon": "~1.19.4",
"typescript": "^5.2.2",
"ts-node": "^10.9.1"
Expand Down
4 changes: 2 additions & 2 deletions js/samples/03.adaptiveCards.a.typeAheadBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"dotenv": "^16.3.1",
"replace": "~1.2.0",
"restify": "~11.1.0",
"axios": "^1.5.0"
"axios": "^1.5.1"
},
"devDependencies": {
"@types/dotenv": "6.1.1",
"@types/restify": "8.5.7",
"@types/restify": "8.5.8",
"nodemon": "~1.19.4",
"typescript": "^5.2.2",
"ts-node": "^10.9.1"
Expand Down
6 changes: 3 additions & 3 deletions js/samples/04.ai.a.teamsChefBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"dotenv": "^16.3.1",
"replace": "~1.2.0",
"restify": "~11.1.0",
"vectra": "^0.4.1"
"vectra": "^0.4.4"
},
"devDependencies": {
"@types/dotenv": "6.1.1",
"@types/restify": "8.5.7",
"@types/node": "^20.6.5",
"@types/restify": "8.5.8",
"@types/node": "^20.8.2",
"ts-node": "^10.9.1",
"env-cmd": "^10.1.0",
"nodemon": "~1.19.4",
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai.b.messageExtensions.AI-ME/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/dotenv": "6.1.1",
"@types/restify": "8.5.7",
"@types/restify": "8.5.8",
"nodemon": "~1.19.4",
"typescript": "^5.2.2",
"shx": "^0.3.4",
Expand Down
Loading

0 comments on commit d904aa2

Please sign in to comment.