From 97c184a86af692b3f61484c652659d415b403cae Mon Sep 17 00:00:00 2001 From: Lily Du Date: Mon, 9 Oct 2023 16:04:14 -0700 Subject: [PATCH] changed to AIOptions and updated getting-started docs --- getting-started/js/00.MIGRATION.md | 10 +++++-- getting-started/js/01.AI-SETUP.md | 29 ------------------- js/packages/teams-ai/src/Application.spec.ts | 2 +- js/packages/teams-ai/src/Application.ts | 2 +- .../src/index.ts | 2 +- js/samples/04.e.twentyQuestions/src/index.ts | 2 +- 6 files changed, 11 insertions(+), 36 deletions(-) diff --git a/getting-started/js/00.MIGRATION.md b/getting-started/js/00.MIGRATION.md index ba1dd6b49..4c0bddb0f 100644 --- a/getting-started/js/00.MIGRATION.md +++ b/getting-started/js/00.MIGRATION.md @@ -30,6 +30,12 @@ const storage = new MemoryStorage(); > `ApplicationTurnState` is the default `TurnState` that includes `ConversationState`, `UserState`, and `TempState` +#### Optional ApplicationBuilder Class + +You may also use the `ApplicationBuilder` class to instantiate your `Application` instance. This option provides greater readability and separates the management of the various configuration options (e.g., storage, turn state, AI module options, etc). + +Follow [this example](#optional-applicationbuilder-class-example) to learn more. + --- ### 2. Message Extensions @@ -96,9 +102,7 @@ app.adaptiveCards.actionSubmit("ChoiceSubmit", async (context, state, data: Subm }); ``` -### Optional ApplicationBuilder Class - -You may also use the `ApplicationBuilder` class to instantiate your `Application` instance. This option provides greater readability and separates the management of the various configuration options (e.g., storage, turn state, AI module options, etc). +### Optional ApplicationBuilder Class Example js `index.ts`: diff --git a/getting-started/js/01.AI-SETUP.md b/getting-started/js/01.AI-SETUP.md index 4e075314e..f0ee32ebd 100644 --- a/getting-started/js/01.AI-SETUP.md +++ b/getting-started/js/01.AI-SETUP.md @@ -51,33 +51,4 @@ const app = new Application({ // ... other options } }); -``` - -### Optional ApplicationBuilder Class - -You may also use the `ApplicationBuilder` class to instantiate your `Application` instance. This option provides greater readability and separates the management of the various configuration options (e.g., storage, turn state, AI module options, etc). - -js `index.ts`: - -```js -// Old method: -// const app = new Application({ -// storage, -// ai: { -// planner, -// promptManager, -// prompt: "defaultPrompt" - // ... other options -// } -// }); - -const app = new ApplicationBuilder() - .withStorage(storage) - .withAI({ - planner, - promptManager, - prompt: "defaultPrompt" - // ... other options - }) - .build(); // this function internally calls the Application constructor ``` \ No newline at end of file diff --git a/js/packages/teams-ai/src/Application.spec.ts b/js/packages/teams-ai/src/Application.spec.ts index 5e12707d9..2d88423f4 100644 --- a/js/packages/teams-ai/src/Application.spec.ts +++ b/js/packages/teams-ai/src/Application.spec.ts @@ -86,7 +86,7 @@ describe('Application', () => { const app = new ApplicationBuilder() .setRemoveRecipientMention(removeRecipientMention) .withStorage(storage) - .withAI(ai) + .withAIOptions(ai) .withLongRunningMessages(adapter, botAppId) .withTurnStateManager(turnStateManager) .withAdaptiveCardOptions(adaptiveCards) diff --git a/js/packages/teams-ai/src/Application.ts b/js/packages/teams-ai/src/Application.ts index a41422f61..2d41e6313 100644 --- a/js/packages/teams-ai/src/Application.ts +++ b/js/packages/teams-ai/src/Application.ts @@ -789,7 +789,7 @@ export class ApplicationBuilder { * @param {AIOptions} aiOptions The options for the AI system. * @returns {this} The ApplicationBuilder instance. */ - public withAI(aiOptions: AIOptions): this { + public withAIOptions(aiOptions: AIOptions): this { this._options.ai = aiOptions; return this; } diff --git a/js/samples/04.ai.b.messageExtensions.AI-ME/src/index.ts b/js/samples/04.ai.b.messageExtensions.AI-ME/src/index.ts index b6decb469..8c102f778 100644 --- a/js/samples/04.ai.b.messageExtensions.AI-ME/src/index.ts +++ b/js/samples/04.ai.b.messageExtensions.AI-ME/src/index.ts @@ -110,7 +110,7 @@ const botAppId = process.env.MicrosoftAppId || ''; const app = new ApplicationBuilder() .withStorage(storage) .withLongRunningMessages(adapter, botAppId) - .withAI({ + .withAIOptions({ planner, promptManager }) diff --git a/js/samples/04.e.twentyQuestions/src/index.ts b/js/samples/04.e.twentyQuestions/src/index.ts index 20f4e81ac..7d81ed085 100644 --- a/js/samples/04.e.twentyQuestions/src/index.ts +++ b/js/samples/04.e.twentyQuestions/src/index.ts @@ -93,7 +93,7 @@ const promptManager = new DefaultPromptManager(path.join(_ const storage = new MemoryStorage(); const app = new ApplicationBuilder() .withStorage(storage) - .withAI({ + .withAIOptions({ planner, promptManager })