Skip to content

Commit

Permalink
[JS] fix: Assistants Planner API version (#2256)
Browse files Browse the repository at this point in the history
## Linked issues

closes: #2233 

## Details

- Fix error where api version was set to api_version instead of
apiVersion
- Update openai package version in all JS samples

## Attestation Checklist

- [x] My code follows the style guidelines of this project

- I have checked for/fixed spelling, linting, and other errors
- I have commented my code for clarity
- I have made corresponding changes to the documentation (updating the
doc strings in the code is sufficient)
- My changes generate no new warnings
- I have added tests that validates my changes, and provides sufficient
test coverage. I have tested with:
  - Local testing
  - E2E testing in Teams
- New and existing unit tests pass locally with my changes

---------

Co-authored-by: Corina Gum <>
  • Loading branch information
corinagum authored Jan 6, 2025
1 parent 6f1288d commit 105f2ee
Show file tree
Hide file tree
Showing 29 changed files with 35 additions and 44 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"botbuilder": "^4.23.1",
"openai": "4.68.2"
"openai": "4.77.3"
},
"devDependencies": {
"@azure/logger": "^1.1.4",
Expand Down
2 changes: 1 addition & 1 deletion js/packages/teams-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"types": "./lib/index.d.ts",
"peerDependencies": {
"botbuilder": "^4.23.1",
"openai": "^4.68.2"
"openai": "4.77.3"
},
"dependencies": {
"@azure/msal-node": "^2.16.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('AssistantsPlanner', () => {
const options: AssistantsPlannerOptions = {
apiKey: 'test-key',
assistant_id: 'test-assistant-id',
api_version: '2024-02-15'
apiVersion: '2024-02-15'
};

planner = new AssistantsPlanner<TurnState>(options);
Expand Down
4 changes: 2 additions & 2 deletions js/packages/teams-ai/src/planners/AssistantsPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface AssistantsPlannerOptions {
/**
* Optional. Version of the API being called. Default is '2024-02-15-preview'.
*/
api_version?: string;
apiVersion?: string;
}

/**
Expand All @@ -97,7 +97,7 @@ export class AssistantsPlanner<TState extends TurnState = TurnState> implements
this._options = {
polling_interval: DEFAULT_POLLING_INTERVAL,
assistants_state_variable: DEFAULT_ASSISTANTS_STATE_VARIABLE,
api_version: '2024-02-15-preview',
apiVersion: '2024-02-15-preview',
...options
};

Expand Down
2 changes: 1 addition & 1 deletion js/samples/01.getting-started/a.echoBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"axios": "^1.7.5",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"axios": "^1.7.5",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion js/samples/03.ai-concepts/a.twentyQuestions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"botbuilder": "^4.23.1",
"@microsoft/teams-ai": "~1.7.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion js/samples/03.ai-concepts/e.customModel-LLAMA/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"botbuilder": "^4.23.1",
"@microsoft/teams-ai": "~1.7.1",
"openai": "4.68.2",
"openai": "4.77.3",
"dotenv": "^16.4.1",
"replace": "~1.2.0",
"restify": "~11.1.0"
Expand Down
2 changes: 1 addition & 1 deletion js/samples/03.ai-concepts/f.chatModeration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"jsonwebtoken": "^9.0.2",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/a.teamsChefBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@microsoft/teams-js": "^2.31.0",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0",
"vectra": "^0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/b.devOpsBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dotenv": "^16.4.5",
"replace": "~1.2.0",
"restify": "~11.1.0",
"openai": "4.68.2"
"openai": "4.77.3"
},
"devDependencies": {
"@types/jsonwebtoken": "^9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/c.vision-cardGazer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/d.assistants-mathBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"jsonwebtoken": "^9.0.2",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
10 changes: 3 additions & 7 deletions js/samples/04.ai-apps/d.assistants-mathBot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ if (!process.env.ASSISTANT_ID) {
tools: [{ type: 'code_interpreter' }],
model: 'gpt-4'
},
endpoint
endpoint ?? undefined,
endpoint ? { apiVersion: process.env.OPENAI_API_VERSION } : undefined
);

console.log(`Created a new assistant with an ID of: ${assistant.id}`);
Expand All @@ -41,7 +42,7 @@ const planner = new AssistantsPlanner({
apiKey: apiKey,
endpoint: endpoint,
assistant_id: process.env.ASSISTANT_ID!,
api_version: '2024-02-15-preview'
apiVersion: process.env.OPENAI_API_VERSION
});

// Define storage and application
Expand All @@ -60,8 +61,3 @@ app.message('/reset', async (context, state) => {
state.deleteConversationState();
await context.sendActivity(`Ok lets start this over.`);
});

app.ai.action(AI.HttpErrorActionName, async (context, state, data) => {
await context.sendActivity('An AI request failed. Please try again later.');
return AI.StopCommandName;
});
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/e.assistants-orderBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"jsonwebtoken": "^9.0.2",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
7 changes: 1 addition & 6 deletions js/samples/04.ai-apps/e.assistants-orderBot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const planner = new AssistantsPlanner({
apiKey: apiKey,
endpoint: endpoint,
assistant_id: process.env.ASSISTANT_ID ?? assistantId,
api_version: '2024-02-15-preview'
apiVersion: process.env.OPENAI_API_VERSION
});

// Define storage and application
Expand All @@ -87,8 +87,3 @@ app.ai.action<Order>('place_order', async (context: TurnContext, state: TurnStat
await context.sendActivity(MessageFactory.attachment(CardFactory.adaptiveCard(card)));
return `order placed`;
});

app.ai.action(AI.HttpErrorActionName, async (context: TurnContext, state: TurnState, _data: unknown) => {
await context.sendActivity('An AI request failed. Please try again later.');
return AI.StopCommandName;
});
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/f.whoBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"botbuilder": "^4.23.1",
"botbuilder-dialogs": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"botbuilder": "^4.23.1",
"debug": "^4.3.7",
"dotenv": "^16.4.1",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0",
"vectra": "^0.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.1",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0",
"vectra": "^0.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@microsoft/teams-ai": "~1.7.1",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"isomorphic-fetch": "^3.0.0",
"replace": "~1.2.0",
"restify": "~11.1.0"
Expand Down
2 changes: 1 addition & 1 deletion js/samples/05.authentication/b.oauth-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"botbuilder": "^4.23.1",
"botbuilder-dialogs": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"isomorphic-fetch": "^3.0.0",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion js/samples/05.authentication/d.teamsSSO-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"botbuilder": "^4.23.1",
"botbuilder-dialogs": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0",
"shx": "^0.3.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"botbuilder-azure-blobs": "^4.23.1",
"dotenv": "^16.4.5",
"isomorphic-fetch": "^3.0.0",
"openai": "4.68.2",
"openai": "4.77.3",
"replace": "~1.2.0",
"restify": "~11.1.0",
"shx": "^0.3.4"
Expand Down
8 changes: 4 additions & 4 deletions js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6818,10 +6818,10 @@ [email protected]:
node-fetch "^2.6.7"
web-streams-polyfill "^3.2.1"

openai@4.68.2:
version "4.68.2"
resolved "https://registry.yarnpkg.com/openai/-/openai-4.68.2.tgz#2443d23127c61dcc9a9356ff8ea5b21acf0ba60d"
integrity sha512-Ys3Jl9vkBUFtrFj4pgrF7rMte4JNekZoMgI6dWkkpOIwNUKGkc4I8jTqv86LB+TcoqkTPzV6DS269dPR9ILWsQ==
openai@4.77.3:
version "4.77.3"
resolved "https://registry.yarnpkg.com/openai/-/openai-4.77.3.tgz#10f6906f2f737a98b656b745a6b710e595ba2e4d"
integrity sha512-wLDy4+KWHz31HRFMW2+9KQuVuT2QWhs0z94w1Gm1h2Ut9vIHr9/rHZggbykZEfyiaJRVgw8ZS9K6AylDWzvPYw==
dependencies:
"@types/node" "^18.11.18"
"@types/node-fetch" "^2.6.4"
Expand Down

0 comments on commit 105f2ee

Please sign in to comment.