Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[JS] chore: update setup for chatModeration and mathBot #969

Merged
merged 8 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions js/samples/05.chatModeration/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chat Bot with Moderation Control

This sample shows how to incorporate Azure Open AI Content Safety control into a Microsoft Teams application using [Bot Framework](https://dev.botframework.com) and the Teams AI SDK.
This sample shows how to incorporate Content Safety control into a Microsoft Teams application using [Bot Framework](https://dev.botframework.com) and the Teams AI SDK.

<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} -->

Expand Down Expand Up @@ -40,12 +40,17 @@ This sample shows how to incorporate Azure Open AI Content Safety control into a

```bash
cd teams-ai/js/samples/05.chatModeration/
yarn start
```

4. Duplicate the `sample.env` in the `teams-ai/js/samples/05.chatModeration` folder. Rename the file to `.env`.

5. If you are using OpenAI then only keep the `OPENAI_KEY` and add in your key. Otherwise if you are using AzureOpenAI then only keep the `AZURE_OPENAI_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_MODERATOR_KEY` & `AZURE_MODERATOR_ENDPOINT` variables and fill them in appropriately.

6. Update `config.json` and `bot.ts` with your model deployment name.

## Interacting with the bot

You can interact with this bot by sending it a message, which will echo back to you.
You can interact with this bot by sending it a message, and a moderation report will be sent back to you.

## Multiple ways to test

Expand Down
7 changes: 7 additions & 0 deletions js/samples/05.chatModeration/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is an example file of how to set up environment variables. You can duplicate this file and add the appropriate keys.
OPENAI_KEY=

AZURE_OPENAI_KEY=
AZURE_OPENAI_ENDPOINT=
AZURE_MODERATOR_KEY=
AZURE_MODERATOR_ENDPOINT=
2 changes: 1 addition & 1 deletion js/samples/05.chatModeration/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const model = new OpenAIModel({
let moderator: Moderator;
if (process.env.OPENAI_KEY) {
moderator = new OpenAIModerator({
apiKey: process.env.OPENAI_API_KEY!,
apiKey: process.env.OPENAI_KEY!,
moderate: 'both',
});
} else {
Expand Down
21 changes: 0 additions & 21 deletions js/samples/05.chatModeration/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,6 @@ provision:
# Defines what the `deploy` lifecycle step does with Teams Toolkit.
# Runs after `provision` during Start Debugging (F5) or run manually using `teamsfx deploy --env local`.
deploy:
# Ensures that the project dependencies are installed.
# - uses: cli/runNpmCommand
# with:
# args: install --no-audit
- uses: script
with:
run: yarn
workingDirectory: .
shell: powershell

# Build the project
- uses: script
with:
run: yarn build
workingDirectory: .
shell: powershell

# Provides the Teams Toolkit .env file values to the apps runtime so they can be accessed with `process.env`.
- uses: file/createOrUpdateEnvironmentFile
with:
Expand All @@ -94,7 +77,3 @@ deploy:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
TEAMS_APP_TENANT_ID: ${{TEAMS_APP_TENANT_ID}}
AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}}
AZURE_OPENAI_KEY: ${{AZURE_OPENAI_KEY}}
AZURE_CONTENT_SAFETY_ENDPOINT: ${{AZURE_CONTENT_SAFETY_ENDPOINT}}
AZURE_CONTENT_SAFETY_API_KEY: ${{AZURE_CONTENT_SAFETY_API_KEY}}
6 changes: 4 additions & 2 deletions js/samples/06.assistants.a.mathBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ This example shows how to create a basic conversational experience using OpenAI'

```bash
cd teams-ai/js/samples/06.assistants.a.mathBot/
yarn start
```
4. Duplicate the `sample.env` in the `teams-ai/js/samples/06.assistants.a.mathBot` folder. Rename the file to `.env`.

5. Fill in the variables with your keys.

## Interacting with the bot

You can interact with this bot by sending it a message, which will echo back to you.
You can interact with this bot by sending it a message, and the bot will solve your requested math problem..

## Multiple ways to test

Expand Down
3 changes: 3 additions & 0 deletions js/samples/06.assistants.a.mathBot/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is an example file of how to set up environment variables. You can duplicate this file and add the appropriate keys.
OPENAI_KEY=
ASSISTANT_ID=
2 changes: 1 addition & 1 deletion js/samples/06.assistants.a.mathBot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (!process.env.OPENAI_KEY) {

const { AssistantsPlanner } = preview;

// Create Assistant if no ID is provided
// Create Assistant if no ID is provided, this will require you to restart the program and fill in the process.env.ASSISTANT_ID afterwards.
if (!process.env.ASSISTANT_ID) {
(async () => {
const assistant = await AssistantsPlanner.createAssistant(process.env.OPENAI_KEY!, {
Expand Down
21 changes: 0 additions & 21 deletions js/samples/06.assistants.a.mathBot/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,6 @@ provision:
# Defines what the `deploy` lifecycle step does with Teams Toolkit.
# Runs after `provision` during Start Debugging (F5) or run manually using `teamsfx deploy --env local`.
deploy:
# Ensures that the project dependencies are installed.
# - uses: cli/runNpmCommand
# with:
# args: install --no-audit
- uses: script
with:
run: yarn
workingDirectory: .
shell: powershell

# Build the project
- uses: script
with:
run: yarn build
workingDirectory: .
shell: powershell

# Provides the Teams Toolkit .env file values to the apps runtime so they can be accessed with `process.env`.
- uses: file/createOrUpdateEnvironmentFile
with:
Expand All @@ -94,7 +77,3 @@ deploy:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
TEAMS_APP_TENANT_ID: ${{TEAMS_APP_TENANT_ID}}
AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}}
AZURE_OPENAI_KEY: ${{AZURE_OPENAI_KEY}}
AZURE_CONTENT_SAFETY_ENDPOINT: ${{AZURE_CONTENT_SAFETY_ENDPOINT}}
AZURE_CONTENT_SAFETY_API_KEY: ${{AZURE_CONTENT_SAFETY_API_KEY}}