diff --git a/js/samples/05.chatModeration/README.md b/js/samples/05.chatModeration/README.md index 92ee98166..6d1822235 100644 --- a/js/samples/05.chatModeration/README.md +++ b/js/samples/05.chatModeration/README.md @@ -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. @@ -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 diff --git a/js/samples/05.chatModeration/sample.env b/js/samples/05.chatModeration/sample.env new file mode 100644 index 000000000..10369dde6 --- /dev/null +++ b/js/samples/05.chatModeration/sample.env @@ -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= \ No newline at end of file diff --git a/js/samples/05.chatModeration/src/bot.ts b/js/samples/05.chatModeration/src/bot.ts index f0934efd6..c61916143 100644 --- a/js/samples/05.chatModeration/src/bot.ts +++ b/js/samples/05.chatModeration/src/bot.ts @@ -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 { diff --git a/js/samples/05.chatModeration/teamsapp.local.yml b/js/samples/05.chatModeration/teamsapp.local.yml index 9bfc43c62..c307557dd 100644 --- a/js/samples/05.chatModeration/teamsapp.local.yml +++ b/js/samples/05.chatModeration/teamsapp.local.yml @@ -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: @@ -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}} diff --git a/js/samples/06.assistants.a.mathBot/README.md b/js/samples/06.assistants.a.mathBot/README.md index 450b9162f..ac9cc9710 100644 --- a/js/samples/06.assistants.a.mathBot/README.md +++ b/js/samples/06.assistants.a.mathBot/README.md @@ -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 diff --git a/js/samples/06.assistants.a.mathBot/sample.env b/js/samples/06.assistants.a.mathBot/sample.env new file mode 100644 index 000000000..45d655b15 --- /dev/null +++ b/js/samples/06.assistants.a.mathBot/sample.env @@ -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= \ No newline at end of file diff --git a/js/samples/06.assistants.a.mathBot/src/bot.ts b/js/samples/06.assistants.a.mathBot/src/bot.ts index 5ec7b79be..fbc6411bc 100644 --- a/js/samples/06.assistants.a.mathBot/src/bot.ts +++ b/js/samples/06.assistants.a.mathBot/src/bot.ts @@ -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!, { diff --git a/js/samples/06.assistants.a.mathBot/teamsapp.local.yml b/js/samples/06.assistants.a.mathBot/teamsapp.local.yml index 2c9ab718b..c8c21ffff 100644 --- a/js/samples/06.assistants.a.mathBot/teamsapp.local.yml +++ b/js/samples/06.assistants.a.mathBot/teamsapp.local.yml @@ -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: @@ -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}}