Skip to content

Commit f247e60

Browse files
authored
Merge branch 'main' into cg/cardGazer-4o
2 parents 40ac3eb + 4c6abf7 commit f247e60

File tree

44 files changed

+423
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+423
-559
lines changed

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Checkout
3535
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3636
- name: Setup NodeJS ${{ env.node-version }}
37-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
37+
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
3838
with:
3939
node-version: ${{ env.node-version }}
4040
- name: Install Dependencies

.github/workflows/dotnet-codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Checkout
4040
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
42+
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
4343
with:
4444
languages: csharp
4545
- name: Setup .NET
@@ -50,6 +50,6 @@ jobs:
5050
working-directory: dotnet/packages/Microsoft.TeamsAI/
5151
run: dotnet build Microsoft.Teams.AI.sln --configuration Release
5252
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
53+
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
5454
with:
5555
category: "/language:csharp"

.github/workflows/js-build-test-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Checkout
3131
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3232
- name: Setup NodeJS ${{ matrix.node-version }}
33-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
33+
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
3434
with:
3535
node-version: ${{ matrix.node-version }}
3636
- name: Install Dependencies

.github/workflows/js-codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
- name: Checkout
3939
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
41+
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
4242
with:
4343
languages: javascript
4444
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
45+
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
4646
with:
4747
category: "/language:javascript"

.github/workflows/python-codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
- name: Checkout
3939
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
41+
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
4242
with:
4343
languages: python
4444
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
45+
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
4646
with:
4747
category: "/language:python"

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ jobs:
6666

6767
# Upload the results to GitHub's code scanning dashboard.
6868
- name: "Upload to code-scanning"
69-
uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7
69+
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
7070
with:
7171
sarif_file: results.sarif

js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:nyc:report": "npx rimraf coverage && yarn test:mocha && nyc report"
2121
},
2222
"dependencies": {
23-
"botbuilder": "^4.23.0",
23+
"botbuilder": "^4.23.1",
2424
"openai": "4.61.0"
2525
},
2626
"devDependencies": {
@@ -29,7 +29,7 @@
2929
"@microsoft/api-extractor": "^7.47.7",
3030
"@standardlabs/is-private": "^1.0.1",
3131
"@types/jsonwebtoken": "9.0.4",
32-
"@types/lodash": "^4.17.7",
32+
"@types/lodash": "^4.17.9",
3333
"@types/mocha": "^10.0.7",
3434
"@types/node": "^20.16.1",
3535
"@types/sinon": "^10.0.19",

js/packages/teams-ai/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@microsoft/teams-ai",
33
"author": "Microsoft Corp.",
44
"description": "SDK focused on building AI based applications for Microsoft Teams.",
5-
"version": "1.4.1",
5+
"version": "1.5.0",
66
"license": "MIT",
77
"keywords": [
88
"botbuilder",
@@ -29,14 +29,14 @@
2929
"openai": "^4.61.0"
3030
},
3131
"dependencies": {
32-
"@azure/openai-assistants": "1.0.0-beta.5",
33-
"@azure/msal-node": "^2.13.1",
32+
"@azure/openai-assistants": "1.0.0-beta.6",
33+
"@azure/msal-node": "^2.14.0",
3434
"axios": "^1.7.5",
35-
"botbuilder-dialogs": "^4.23.0",
35+
"botbuilder-dialogs": "^4.23.1",
3636
"botframework-connector": "^4.23.0",
3737
"botframework-schema": "^4.23.0",
3838
"botframework-streaming": "^4.23.0",
39-
"gpt-tokenizer": "^2.2.1",
39+
"gpt-tokenizer": "^2.4.0",
4040
"json-colorizer": "^2.2.2",
4141
"jsonschema": "1.4.1",
4242
"uuid": "^9.0.1",

js/packages/teams-ai/src/StreamingResponse.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import assert from 'assert';
22
import { TestAdapter } from 'botbuilder';
3+
import { CardFactory } from 'botbuilder-core';
34
import { StreamingResponse } from './StreamingResponse';
45

56
describe('StreamingResponse', function () {
@@ -157,5 +158,48 @@ describe('StreamingResponse', function () {
157158
);
158159
});
159160
});
161+
162+
it('should send a final message with text and attachments', async () => {
163+
const adapter = new TestAdapter();
164+
const adaptiveCard = {
165+
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
166+
version: '1.6',
167+
type: 'AdaptiveCard',
168+
body: [
169+
{
170+
text: 'This is an example of an attachment..',
171+
wrap: true,
172+
type: 'TextBlock'
173+
}
174+
]
175+
};
176+
await adapter.sendTextToBot('test', async (context) => {
177+
const response = new StreamingResponse(context);
178+
response.queueTextChunk('first');
179+
response.queueTextChunk('second');
180+
await response.waitForQueue();
181+
await response.setAttachments([CardFactory.adaptiveCard(adaptiveCard)]);
182+
await response.endStream();
183+
assert(response.updatesSent == 2, 'updatesSent should be 2');
184+
185+
// Validate sent activities
186+
const activities = adapter.activeQueue;
187+
assert.equal(activities.length, 3, 'should have sent 3 activities');
188+
assert.equal(activities[0].channelData.streamSequence, 1, 'first activity streamSequence should be 1');
189+
assert.equal(activities[1].channelData.streamSequence, 2, 'second activity streamSequence should be 2');
190+
assert.equal(activities[2].type, 'message', 'final activity type should be "message"');
191+
assert.equal(activities[2].text, 'firstsecond', 'final activity text should be "firstsecond"');
192+
assert.deepEqual(
193+
activities[2].channelData,
194+
{ streamType: 'final', streamId: response.streamId },
195+
'final activity channelData should match'
196+
);
197+
assert.notEqual(activities[2].attachments, null);
198+
if (activities[2].attachments) {
199+
assert.equal(activities[2].attachments.length, 1, 'should have 1 attachment');
200+
assert.deepEqual(activities[2].attachments[0].content, adaptiveCard, 'adaptive card should match');
201+
}
202+
});
203+
});
160204
});
161205
});

js/packages/teams-ai/src/StreamingResponse.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Licensed under the MIT License.
77
*/
88

9-
import { Activity, TurnContext } from 'botbuilder-core';
9+
import { Activity, Attachment, TurnContext } from 'botbuilder-core';
1010

1111
/**
1212
* A helper class for streaming responses to the client.
@@ -23,6 +23,7 @@ export class StreamingResponse {
2323
private _nextSequence: number = 1;
2424
private _streamId?: string;
2525
private _message: string = '';
26+
private _attachments?: Attachment[];
2627
private _ended = false;
2728

2829
// Queue for outgoing activities
@@ -113,6 +114,22 @@ export class StreamingResponse {
113114
return this._queueSync!;
114115
}
115116

117+
/**
118+
* Sets the attachments to attach to the final chunk.
119+
* @param attachments List of attachments.
120+
*/
121+
public setAttachments(attachments: Attachment[]): void {
122+
this._attachments = attachments;
123+
}
124+
125+
/**
126+
* Returns the most recently streamed message.
127+
* @returns The streamed message.
128+
*/
129+
public getMessage(): string {
130+
return this._message;
131+
}
132+
116133
/**
117134
* Waits for the outgoing activity queue to be empty.
118135
* @returns {Promise<void>} - A promise representing the async operation.
@@ -140,6 +157,7 @@ export class StreamingResponse {
140157
return {
141158
type: 'message',
142159
text: this._message,
160+
attachments: this._attachments,
143161
channelData: {
144162
streamType: 'final'
145163
} as StreamingChannelData

0 commit comments

Comments
 (0)