Skip to content

Commit

Permalink
changed to AIOptions and updated getting-started docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyydu committed Oct 9, 2023
1 parent 1118442 commit 97c184a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 36 deletions.
10 changes: 7 additions & 3 deletions getting-started/js/00.MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`:
Expand Down
29 changes: 0 additions & 29 deletions getting-started/js/01.AI-SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()<ApplicationTurnState>
.withStorage(storage)
.withAI({
planner,
promptManager,
prompt: "defaultPrompt"
// ... other options
})
.build(); // this function internally calls the Application constructor
```
2 changes: 1 addition & 1 deletion js/packages/teams-ai/src/Application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion js/packages/teams-ai/src/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ export class ApplicationBuilder<TState extends TurnState = DefaultTurnState> {
* @param {AIOptions<TState>} aiOptions The options for the AI system.
* @returns {this} The ApplicationBuilder instance.
*/
public withAI(aiOptions: AIOptions<TState>): this {
public withAIOptions(aiOptions: AIOptions<TState>): this {
this._options.ai = aiOptions;
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai.b.messageExtensions.AI-ME/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const botAppId = process.env.MicrosoftAppId || '';
const app = new ApplicationBuilder<ApplicationTurnState>()
.withStorage(storage)
.withLongRunningMessages(adapter, botAppId)
.withAI({
.withAIOptions({
planner,
promptManager
})
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.e.twentyQuestions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const promptManager = new DefaultPromptManager<ApplicationTurnState>(path.join(_
const storage = new MemoryStorage();
const app = new ApplicationBuilder<ApplicationTurnState>()
.withStorage(storage)
.withAI({
.withAIOptions({
planner,
promptManager
})
Expand Down

0 comments on commit 97c184a

Please sign in to comment.