diff --git a/js/samples/04.ai.a.teamsChefBot/README.md b/js/samples/04.ai.a.teamsChefBot/README.md index 6824c887f..caa8ec3fe 100644 --- a/js/samples/04.ai.a.teamsChefBot/README.md +++ b/js/samples/04.ai.a.teamsChefBot/README.md @@ -1,6 +1,5 @@ # Microsoft Teams Conversational Bot with AI: Teams Chef - -> Please note: this sample is still being tweaked and therefore not setup with Teams Toolkit yet. We'll get it updated ASAP! +This is a conversational bot for Microsoft Teams that thinks it's a Chef to help you cook apps using the Teams AI Library. The bot uses the `gpt-3.5-turbo` model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation. @@ -23,9 +22,6 @@ ## Summary - -This is a conversational bot for Microsoft Teams that thinks it's a Chef to help you cook apps using the Teams AI Library. The bot uses the `gpt-3.5-turbo` model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation. - This sample illustrates how to use [Retrieval Augmented Generation (RAG)](https://en.wikipedia.org/wiki/Prompt_engineering#Retrieval-augmented_generation) to easily inject contextual relevant information into the prompt sent to the model. This results in better and more accurate replies from the bot. The sample uses a local Vector Database, called [Vectra](https://github.com/Stevenic/vectra), and [Semantic Search](https://en.wikipedia.org/wiki/Semantic_search) to find the most relevant information to include in the prompt for the users input. The index can be found in `./index/teams-ai` and includes all of the projects Getting Started docs and the source code for the Teams AI Library. This means you can ask the Teams Chef Bot anything about the library and it can answer it. You can even ask it to write sample code for you! @@ -46,7 +42,7 @@ Open the panel below to learn fine-tuned details on how this sample works. ```javascript // Create AI components const planner = new OpenAIPlanner({ - apiKey: process.env.OPENAI_API_KEY || '', + apiKey: process.env.OPENAI_KEY || '', defaultModel: 'gpt-3.5-turbo', logRequests: true }); @@ -149,6 +145,11 @@ Notice that the bot remembered Dave's first message when responding to the secon ```bash cd teams-ai/js/samples/04.ai.a.teamsChefBot/ ``` +4. Duplicate the `sample.env` in the `teams-ai/js/samples/04.ai.a.teamsChefBot` folder. Rename the file to `.env`. + +5. Add in your `OPENAI_KEY` key. + +6. Update `config.json` and `index.ts` with your model deployment name. ## Multiple ways to test diff --git a/js/samples/04.ai.a.teamsChefBot/env/.env.dev b/js/samples/04.ai.a.teamsChefBot/env/.env.dev index eb3f03df4..80754dfad 100644 --- a/js/samples/04.ai.a.teamsChefBot/env/.env.dev +++ b/js/samples/04.ai.a.teamsChefBot/env/.env.dev @@ -10,5 +10,4 @@ RESOURCE_SUFFIX= # Generated during provision, you can also add your own variables. BOT_ID= -BOT_PASSWORD= -OPENAI_API_KEY= \ No newline at end of file +BOT_PASSWORD= \ No newline at end of file diff --git a/js/samples/04.ai.a.teamsChefBot/sample.env b/js/samples/04.ai.a.teamsChefBot/sample.env new file mode 100644 index 000000000..8a75c2544 --- /dev/null +++ b/js/samples/04.ai.a.teamsChefBot/sample.env @@ -0,0 +1,2 @@ +# This is an example file of how to set up environment variables. You can duplicate this file and add the appropriate keys. +OPENAI_KEY= \ No newline at end of file diff --git a/js/samples/04.ai.a.teamsChefBot/src/index.ts b/js/samples/04.ai.a.teamsChefBot/src/index.ts index 2a0f27f8b..418a80c88 100644 --- a/js/samples/04.ai.a.teamsChefBot/src/index.ts +++ b/js/samples/04.ai.a.teamsChefBot/src/index.ts @@ -113,25 +113,19 @@ const planner = new ActionPlanner({ defaultPrompt: 'chat', }); -// const moderator = new OpenAIModerator({ -// apiKey: process.env.OPENAI_API_KEY || '', -// moderate: 'both' -// }); - // Define storage and application const storage = new MemoryStorage(); const app = new Application({ storage, ai: { planner, - // moderator } }); // Register your data source with planner planner.prompts.addDataSource(new VectraDataSource({ name: 'teams-ai', - apiKey: process.env.OPENAI_API_KEY!, + apiKey: process.env.OPENAI_KEY!, indexFolder: path.join(__dirname, '../index'), })); diff --git a/js/samples/04.ai.a.teamsChefBot/teamsapp.local.yml b/js/samples/04.ai.a.teamsChefBot/teamsapp.local.yml index 3809bb1f5..814024c8b 100644 --- a/js/samples/04.ai.a.teamsChefBot/teamsapp.local.yml +++ b/js/samples/04.ai.a.teamsChefBot/teamsapp.local.yml @@ -40,20 +40,10 @@ provision: appPackagePath: ./build/appPackage/appPackage.${{TEAMSFX_ENV}}.zip # Relative path to this file. This is the path for built zip file. deploy: - - uses: script +# Provides the Teams Toolkit .env file values to the apps runtime so they can be accessed with `process.env`. + - uses: file/createOrUpdateEnvironmentFile with: - run: "yarn install" - timeout: 180000 # timeout in ms - - - uses: script - with: - run: "yarn build" - timeout: 180000 # timeout in ms - - - uses: file/createOrUpdateEnvironmentFile # Generate runtime environment variables - with: - target: ./.localSettings + target: ./.env envs: BOT_ID: ${{BOT_ID}} - BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} - OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} \ No newline at end of file + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} \ No newline at end of file diff --git a/js/samples/04.ai.a.teamsChefBot/teamsapp.yml b/js/samples/04.ai.a.teamsChefBot/teamsapp.yml index 4d51294e8..0409fac0c 100644 --- a/js/samples/04.ai.a.teamsChefBot/teamsapp.yml +++ b/js/samples/04.ai.a.teamsChefBot/teamsapp.yml @@ -76,4 +76,3 @@ publish: writeToEnvironmentFile: # Write the information of installed dependencies into environment file for the specified environment variable(s). publishedAppId: TEAMS_APP_PUBLISHED_APP_ID -projectId: f76f76ab-fa47-46f5-a401-5d5deb608718