Skip to content

Commit

Permalink
separated chefbot samples
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyydu committed Sep 16, 2024
1 parent c8244da commit bad48ca
Show file tree
Hide file tree
Showing 67 changed files with 8,062 additions and 5 deletions.
4 changes: 1 addition & 3 deletions js/samples/04.ai-apps/a.teamsChefBot/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Microsoft Teams Conversational Bot with AI: Teams Chef

This is a conversational streaming 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-4o` model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.
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-4o` model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.

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

Expand All @@ -21,8 +21,6 @@ This sample illustrates how to use [Retrieval Augmented Generation (RAG)](https:

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!

In addition, the sample illustrates our streaming feature. This is enabled via using our `DefaultAugmentation` class, and by setting `stream: true` in the OpenAIModel declaration. The informative message can be set in the `ActionPlanner` declaration via the `startStreamingMessage` config. Custom logic is available through the `StreamingResponse` class.

![Teams Chef Bot](./assets/TeamsChef003.png?raw=1)

## Setting up the sample
Expand Down
2 changes: 0 additions & 2 deletions js/samples/04.ai-apps/a.teamsChefBot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const model = new OpenAIModel({
// OpenAI Support
apiKey: process.env.OPENAI_KEY!,
defaultModel: 'gpt-4o',
stream: true,
project: process.env.OPENAI_PROJECT_KEY!,
clientOptions: { apiKey: process.env.OPENAI_KEY! },

Expand All @@ -108,7 +107,6 @@ const planner = new ActionPlanner({
model,
prompts,
defaultPrompt: 'default',
startStreamingMessage: 'Loading stream results...'
});

// Define storage and application
Expand Down
8 changes: 8 additions & 0 deletions js/samples/04.ai-apps/i.teamsChefBot-streaming/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bin
build
demo-packages
dist
manifest
node_modules
package-lock.json
docs/assets/main.js
67 changes: 67 additions & 0 deletions js/samples/04.ai-apps/i.teamsChefBot-streaming/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"parser": "@typescript-eslint/parser",
"root": true,
"env": {
"browser": true,
"node": true,
"es2015": true,
"mocha": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:import/recommended",
"plugin:jsdoc/recommended",
"plugin:prettier/recommended" // Recommended to be last
],
"plugins": [
"@typescript-eslint",
"jsdoc",

"mocha",
"only-warn",
"prettier"
// "react"
],
"parserOptions": {
"ecmaVersion": 2015,
// Allows for the parsing of modern ECMAScript features
"sourceType": "module" // Allows for the use of imports
// "ecmaFeatures": {
// "jsx": true
// }
},
"rules": {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"lodash/prefer-includes": "off",
"no-async-promise-executor": "off",
"no-constant-condition": "off",
"no-undef": "off", // Disabled due to conflicts with @typescript/eslint
"no-unused-vars": "off", // Disabled due to conflicts with @typescript/eslint
"prettier/prettier": "error",
"jsdoc/check-tag-names": [
1,
{
"definedTags": ["remarks"] // Allow @remarks
}
]
},
"overrides": [
{
"files": ["bin/*.js", "lib/*.js"]
}
],
"ignorePatterns": ["node_modules/*"]
}
117 changes: 117 additions & 0 deletions js/samples/04.ai-apps/i.teamsChefBot-streaming/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.zip

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
/**/lib
lib

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Teams Toolkit
env/.env.*.user
env/.env.local
appPackage/build
.deployment
env/.env.testtool
.localConfigs.testTool
devTools/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bin
build
demo-packages
dist
manifest
node_modules
package-lock.json
11 changes: 11 additions & 0 deletions js/samples/04.ai-apps/i.teamsChefBot-streaming/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "always",
"endOfLine": "auto",
"printWidth": 120,
"semi": true,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false
}
107 changes: 107 additions & 0 deletions js/samples/04.ai-apps/i.teamsChefBot-streaming/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Remote (Edge)",
"type": "msedge",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"presentation": {
"group": "remote",
"order": 1
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch Remote (Chrome)",
"type": "chrome",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"presentation": {
"group": "remote",
"order": 2
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch App (Edge)",
"type": "msedge",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch App (Chrome)",
"type": "chrome",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Attach to Local Service",
"type": "node",
"request": "attach",
"port": 9239,
"restart": true,
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "Debug (Edge)",
"configurations": [
"Launch App (Edge)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
"order": 1
},
"stopAll": true
},
{
"name": "Debug (Chrome)",
"configurations": [
"Launch App (Chrome)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
"order": 2
},
"stopAll": true
},
{
"name": "Debug in Test Tool",
"configurations": [
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App (Test Tool)",
"presentation": {
"group": "local",
"order": 1
},
"stopAll": true
}
]
}
Loading

0 comments on commit bad48ca

Please sign in to comment.