@microsoft/agents-hosting 0.5.1-g2e246ff274 → 0.5.4-ga4d0401645
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/app/streaming/AIEntity.d.ts +36 -0
- package/dist/src/app/streaming/AIEntity.js +7 -0
- package/dist/src/app/streaming/AIEntity.js.map +1 -0
- package/dist/src/app/streaming/actionCall.d.ts +33 -0
- package/dist/src/app/streaming/actionCall.js +7 -0
- package/dist/src/app/streaming/actionCall.js.map +1 -0
- package/dist/src/app/streaming/clientCitation.d.ts +68 -0
- package/dist/src/app/streaming/clientCitation.js +10 -0
- package/dist/src/app/streaming/clientCitation.js.map +1 -0
- package/dist/src/app/streaming/message.d.ts +106 -0
- package/dist/src/app/streaming/message.js +7 -0
- package/dist/src/app/streaming/message.js.map +1 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.d.ts +40 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.js +3 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.d.ts +141 -0
- package/dist/src/app/streaming/streamingResponse.js +331 -0
- package/dist/src/app/streaming/streamingResponse.js.map +1 -0
- package/dist/src/app/streaming/utilities.d.ts +31 -0
- package/dist/src/app/streaming/utilities.js +101 -0
- package/dist/src/app/streaming/utilities.js.map +1 -0
- package/dist/src/turnContext.d.ts +3 -0
- package/dist/src/turnContext.js +5 -0
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +2 -2
- package/src/app/streaming/AIEntity.ts +44 -0
- package/src/app/streaming/actionCall.ts +37 -0
- package/src/app/streaming/clientCitation.ts +102 -0
- package/src/app/streaming/message.ts +125 -0
- package/src/app/streaming/sensitivityUsageInfo.ts +48 -0
- package/src/app/streaming/streamingResponse.ts +406 -0
- package/src/app/streaming/utilities.ts +108 -0
- package/src/turnContext.ts +7 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.StreamingResponse = void 0;
|
|
8
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
9
|
+
const utilities_1 = require("./utilities");
|
|
10
|
+
/**
|
|
11
|
+
* A helper class for streaming responses to the client.
|
|
12
|
+
* @remarks
|
|
13
|
+
* This class is used to send a series of updates to the client in a single response. The expected
|
|
14
|
+
* sequence of calls is:
|
|
15
|
+
*
|
|
16
|
+
* `sendInformativeUpdate()`, `sendTextChunk()`, `sendTextChunk()`, ..., `endStream()`.
|
|
17
|
+
*
|
|
18
|
+
* Once `endStream()` is called, the stream is considered ended and no further updates can be sent.
|
|
19
|
+
*/
|
|
20
|
+
class StreamingResponse {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new StreamingResponse instance.
|
|
23
|
+
* @param {TurnContext} context - Context for the current turn of conversation with the user.
|
|
24
|
+
* @returns {TurnContext} - The context for the current turn of conversation with the user.
|
|
25
|
+
*/
|
|
26
|
+
constructor(context) {
|
|
27
|
+
this._nextSequence = 1;
|
|
28
|
+
this._message = '';
|
|
29
|
+
this._ended = false;
|
|
30
|
+
// Queue for outgoing activities
|
|
31
|
+
this._queue = [];
|
|
32
|
+
this._chunkQueued = false;
|
|
33
|
+
// Powered by AI feature flags
|
|
34
|
+
this._enableFeedbackLoop = false;
|
|
35
|
+
this._enableGeneratedByAILabel = false;
|
|
36
|
+
this._citations = [];
|
|
37
|
+
this._context = context;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the stream ID of the current response.
|
|
41
|
+
* @returns {string | undefined} - The stream ID of the current response.
|
|
42
|
+
* @remarks
|
|
43
|
+
* Assigned after the initial update is sent.
|
|
44
|
+
*/
|
|
45
|
+
get streamId() {
|
|
46
|
+
return this._streamId;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets the citations of the current response.
|
|
50
|
+
*/
|
|
51
|
+
get citations() {
|
|
52
|
+
return this._citations;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the number of updates sent for the stream.
|
|
56
|
+
* @returns {number} - The number of updates sent for the stream.
|
|
57
|
+
*/
|
|
58
|
+
get updatesSent() {
|
|
59
|
+
return this._nextSequence - 1;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Queues an informative update to be sent to the client.
|
|
63
|
+
* @param {string} text Text of the update to send.
|
|
64
|
+
*/
|
|
65
|
+
queueInformativeUpdate(text) {
|
|
66
|
+
if (this._ended) {
|
|
67
|
+
throw new Error('The stream has already ended.');
|
|
68
|
+
}
|
|
69
|
+
// Queue a typing activity
|
|
70
|
+
this.queueActivity(() => agents_activity_1.Activity.fromObject({
|
|
71
|
+
type: 'typing',
|
|
72
|
+
text,
|
|
73
|
+
channelData: {
|
|
74
|
+
streamType: 'informative',
|
|
75
|
+
streamSequence: this._nextSequence++
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Queues a chunk of partial message text to be sent to the client
|
|
81
|
+
* @remarks
|
|
82
|
+
* The text we be sent as quickly as possible to the client. Chunks may be combined before
|
|
83
|
+
* delivery to the client.
|
|
84
|
+
* @param {string} text Partial text of the message to send.
|
|
85
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
86
|
+
*/
|
|
87
|
+
queueTextChunk(text, citations) {
|
|
88
|
+
if (this._ended) {
|
|
89
|
+
throw new Error('The stream has already ended.');
|
|
90
|
+
}
|
|
91
|
+
// Update full message text
|
|
92
|
+
this._message += text;
|
|
93
|
+
// If there are citations, modify the content so that the sources are numbers instead of [doc1], [doc2], etc.
|
|
94
|
+
this._message = utilities_1.Utilities.formatCitationsResponse(this._message);
|
|
95
|
+
// Queue the next chunk
|
|
96
|
+
this.queueNextChunk();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Ends the stream by sending the final message to the client.
|
|
100
|
+
* @returns {Promise<void>} - A promise representing the async operation
|
|
101
|
+
*/
|
|
102
|
+
endStream() {
|
|
103
|
+
if (this._ended) {
|
|
104
|
+
throw new Error('The stream has already ended.');
|
|
105
|
+
}
|
|
106
|
+
// Queue final message
|
|
107
|
+
this._ended = true;
|
|
108
|
+
this.queueNextChunk();
|
|
109
|
+
// Wait for the queue to drain
|
|
110
|
+
return this.waitForQueue();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets the attachments to attach to the final chunk.
|
|
114
|
+
* @param attachments List of attachments.
|
|
115
|
+
*/
|
|
116
|
+
setAttachments(attachments) {
|
|
117
|
+
this._attachments = attachments;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Sets the sensitivity label to attach to the final chunk.
|
|
121
|
+
* @param sensitivityLabel The sensitivty label.
|
|
122
|
+
*/
|
|
123
|
+
setSensitivityLabel(sensitivityLabel) {
|
|
124
|
+
this._sensitivityLabel = sensitivityLabel;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Sets the citations for the full message.
|
|
128
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
129
|
+
*/
|
|
130
|
+
setCitations(citations) {
|
|
131
|
+
if (citations.length > 0) {
|
|
132
|
+
if (!this._citations) {
|
|
133
|
+
this._citations = [];
|
|
134
|
+
}
|
|
135
|
+
let currPos = this._citations.length;
|
|
136
|
+
for (const citation of citations) {
|
|
137
|
+
const clientCitation = {
|
|
138
|
+
'@type': 'Claim',
|
|
139
|
+
position: currPos + 1,
|
|
140
|
+
appearance: {
|
|
141
|
+
'@type': 'DigitalDocument',
|
|
142
|
+
name: citation.title || `Document #${currPos + 1}`,
|
|
143
|
+
abstract: utilities_1.Utilities.snippet(citation.content, 477)
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
currPos++;
|
|
147
|
+
this._citations.push(clientCitation);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Sets the Feedback Loop in Teams that allows a user to
|
|
153
|
+
* give thumbs up or down to a response.
|
|
154
|
+
* Default is `false`.
|
|
155
|
+
* @param enableFeedbackLoop If true, the feedback loop is enabled.
|
|
156
|
+
*/
|
|
157
|
+
setFeedbackLoop(enableFeedbackLoop) {
|
|
158
|
+
this._enableFeedbackLoop = enableFeedbackLoop;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Sets the type of UI to use for the feedback loop.
|
|
162
|
+
* @param feedbackLoopType The type of the feedback loop.
|
|
163
|
+
*/
|
|
164
|
+
setFeedbackLoopType(feedbackLoopType) {
|
|
165
|
+
this._feedbackLoopType = feedbackLoopType;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Sets the the Generated by AI label in Teams
|
|
169
|
+
* Default is `false`.
|
|
170
|
+
* @param enableGeneratedByAILabel If true, the label is added.
|
|
171
|
+
*/
|
|
172
|
+
setGeneratedByAILabel(enableGeneratedByAILabel) {
|
|
173
|
+
this._enableGeneratedByAILabel = enableGeneratedByAILabel;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Returns the most recently streamed message.
|
|
177
|
+
* @returns The streamed message.
|
|
178
|
+
*/
|
|
179
|
+
getMessage() {
|
|
180
|
+
return this._message;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Waits for the outgoing activity queue to be empty.
|
|
184
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
185
|
+
*/
|
|
186
|
+
waitForQueue() {
|
|
187
|
+
return this._queueSync || Promise.resolve();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Queues the next chunk of text to be sent to the client.
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
193
|
+
queueNextChunk() {
|
|
194
|
+
// Are we already waiting to send a chunk?
|
|
195
|
+
if (this._chunkQueued) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
// Queue a chunk of text to be sent
|
|
199
|
+
this._chunkQueued = true;
|
|
200
|
+
this.queueActivity(() => {
|
|
201
|
+
this._chunkQueued = false;
|
|
202
|
+
if (this._ended) {
|
|
203
|
+
// Send final message
|
|
204
|
+
return agents_activity_1.Activity.fromObject({
|
|
205
|
+
type: 'message',
|
|
206
|
+
text: this._message,
|
|
207
|
+
attachments: this._attachments,
|
|
208
|
+
channelData: {
|
|
209
|
+
streamType: 'final'
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// Send typing activity
|
|
215
|
+
return agents_activity_1.Activity.fromObject({
|
|
216
|
+
type: 'typing',
|
|
217
|
+
text: this._message,
|
|
218
|
+
channelData: {
|
|
219
|
+
streamType: 'streaming',
|
|
220
|
+
streamSequence: this._nextSequence++
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Queues an activity to be sent to the client.
|
|
228
|
+
*/
|
|
229
|
+
queueActivity(factory) {
|
|
230
|
+
this._queue.push(factory);
|
|
231
|
+
// If there's no sync in progress, start one
|
|
232
|
+
if (!this._queueSync) {
|
|
233
|
+
this._queueSync = this.drainQueue().catch((err) => {
|
|
234
|
+
console.error(`Error occured when sending activity while streaming: "${err}".`);
|
|
235
|
+
throw err;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Sends any queued activities to the client until the queue is empty.
|
|
241
|
+
* @returns {Promise<void>} - A promise that will be resolved once the queue is empty.
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
async drainQueue() {
|
|
245
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
246
|
+
return new Promise(async (resolve, reject) => {
|
|
247
|
+
try {
|
|
248
|
+
while (this._queue.length > 0) {
|
|
249
|
+
// Get next activity from queue
|
|
250
|
+
const factory = this._queue.shift();
|
|
251
|
+
const activity = factory();
|
|
252
|
+
// Send activity
|
|
253
|
+
await this.sendActivity(activity);
|
|
254
|
+
}
|
|
255
|
+
resolve();
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
reject(err);
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
// Queue is empty, mark as idle
|
|
262
|
+
this._queueSync = undefined;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Sends an activity to the client and saves the stream ID returned.
|
|
268
|
+
* @param {Activity} activity - The activity to send.
|
|
269
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
270
|
+
* @private
|
|
271
|
+
*/
|
|
272
|
+
async sendActivity(activity) {
|
|
273
|
+
var _a;
|
|
274
|
+
// Set activity ID to the assigned stream ID
|
|
275
|
+
if (this._streamId) {
|
|
276
|
+
activity.id = this._streamId;
|
|
277
|
+
activity.channelData = Object.assign({}, activity.channelData, { streamId: this._streamId });
|
|
278
|
+
}
|
|
279
|
+
activity.entities = [
|
|
280
|
+
{
|
|
281
|
+
type: 'streaminfo',
|
|
282
|
+
...activity.channelData
|
|
283
|
+
}
|
|
284
|
+
];
|
|
285
|
+
if (this._citations && this._citations.length > 0 && !this._ended) {
|
|
286
|
+
// Filter out the citations unused in content.
|
|
287
|
+
const currCitations = (_a = utilities_1.Utilities.getUsedCitations(this._message, this._citations)) !== null && _a !== void 0 ? _a : undefined;
|
|
288
|
+
activity.entities.push({
|
|
289
|
+
type: 'https://schema.org/Message',
|
|
290
|
+
'@type': 'Message',
|
|
291
|
+
'@context': 'https://schema.org',
|
|
292
|
+
'@id': '',
|
|
293
|
+
citation: currCitations
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
// Add in Powered by AI feature flags
|
|
297
|
+
if (this._ended) {
|
|
298
|
+
if (this._enableFeedbackLoop && this._feedbackLoopType) {
|
|
299
|
+
activity.channelData = Object.assign({}, activity.channelData, {
|
|
300
|
+
feedbackLoop: { type: this._feedbackLoopType }
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
activity.channelData = Object.assign({}, activity.channelData, {
|
|
305
|
+
feedbackLoopEnabled: this._enableFeedbackLoop
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
// Add in Generated by AI
|
|
309
|
+
if (this._enableGeneratedByAILabel) {
|
|
310
|
+
activity.entities.push({
|
|
311
|
+
type: 'https://schema.org/Message',
|
|
312
|
+
'@type': 'Message',
|
|
313
|
+
'@context': 'https://schema.org',
|
|
314
|
+
'@id': '',
|
|
315
|
+
additionalType: ['AIGeneratedContent'],
|
|
316
|
+
citation: this._citations && this._citations.length > 0 ? this._citations : [],
|
|
317
|
+
usageInfo: this._sensitivityLabel
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// Send activity
|
|
322
|
+
const response = await this._context.sendActivity(activity);
|
|
323
|
+
// await new Promise((resolve) => setTimeout(resolve, 1500))
|
|
324
|
+
// Save assigned stream ID
|
|
325
|
+
if (!this._streamId) {
|
|
326
|
+
this._streamId = response === null || response === void 0 ? void 0 : response.id;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
exports.StreamingResponse = StreamingResponse;
|
|
331
|
+
//# sourceMappingURL=streamingResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamingResponse.js","sourceRoot":"","sources":["../../../../src/app/streaming/streamingResponse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAAyE;AAKzE,2CAAuC;AAEvC;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IAoB5B;;;;SAIK;IACL,YAAoB,OAAoB;QAvBhC,kBAAa,GAAW,CAAC,CAAA;QAEzB,aAAQ,GAAW,EAAE,CAAA;QAErB,WAAM,GAAG,KAAK,CAAA;QAEtB,gCAAgC;QACx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BAC7D,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;iBAC9C,CAAC,CAAA;YACJ,CAAC;YAED,yBAAyB;YACzB,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;gBACnC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACrB,IAAI,EAAE,4BAA4B;oBAClC,OAAO,EAAE,SAAS;oBAClB,UAAU,EAAE,oBAAoB;oBAChC,KAAK,EAAE,EAAE;oBACT,cAAc,EAAE,CAAC,oBAAoB,CAAC;oBACtC,QAAQ,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;oBAC9E,SAAS,EAAE,IAAI,CAAC,iBAAiB;iBACb,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAC3D,4DAA4D;QAE5D,0BAA0B;QAC1B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAA;QAC/B,CAAC;IACH,CAAC;CACF;AA5VD,8CA4VC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ClientCitation } from './clientCitation';
|
|
6
|
+
/**
|
|
7
|
+
* Utility functions for manipulating .
|
|
8
|
+
*/
|
|
9
|
+
export declare class Utilities {
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* Clips the text to a maximum length in case it exceeds the limit.
|
|
13
|
+
* @param {string} text The text to clip.
|
|
14
|
+
* @param {number} maxLength The maximum length of the text to return, cutting off the last whole word.
|
|
15
|
+
* @returns {string} The modified text
|
|
16
|
+
*/
|
|
17
|
+
static snippet(text: string, maxLength: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert citation tags `[doc(s)n]` to `[n]` where n is a number.
|
|
20
|
+
* @param {string} text The text to format.
|
|
21
|
+
* @returns {string} The formatted text.
|
|
22
|
+
*/
|
|
23
|
+
static formatCitationsResponse(text: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the citations used in the text. This will remove any citations that are included in the citations array from the response but not referenced in the text.
|
|
26
|
+
* @param {string} text - The text to search for citation references, i.e. [1], [2], etc.
|
|
27
|
+
* @param {ClientCitation[]} citations - The list of citations to search for.
|
|
28
|
+
* @returns {ClientCitation[] | undefined} The list of citations used in the text.
|
|
29
|
+
*/
|
|
30
|
+
static getUsedCitations(text: string, citations: ClientCitation[]): ClientCitation[] | undefined;
|
|
31
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Utilities = void 0;
|
|
8
|
+
// import { stringify } from 'yaml'
|
|
9
|
+
// import { Tokenizer } from './tokenizers'
|
|
10
|
+
/**
|
|
11
|
+
* Utility functions for manipulating .
|
|
12
|
+
*/
|
|
13
|
+
class Utilities {
|
|
14
|
+
// /**
|
|
15
|
+
// * Converts a value to a string.
|
|
16
|
+
// * @remarks
|
|
17
|
+
// * Dates are converted to ISO strings and Objects are converted to JSON or YAML, whichever is shorter.
|
|
18
|
+
// * @param {Tokenizer} tokenizer Tokenizer to use for encoding.
|
|
19
|
+
// * @param {any} value Value to convert.
|
|
20
|
+
// * @param {boolean} asJSON Optional. If true objects will always be converted to JSON instead of YAML. Defaults to false.
|
|
21
|
+
// * @returns {string} Converted value.
|
|
22
|
+
// */
|
|
23
|
+
// public static toString (tokenizer: Tokenizer, value: any, asJSON: boolean = false): string {
|
|
24
|
+
// if (value === undefined || value === null) {
|
|
25
|
+
// return ''
|
|
26
|
+
// } else if (typeof value === 'object') {
|
|
27
|
+
// if (typeof value.toISOString === 'function') {
|
|
28
|
+
// return value.toISOString()
|
|
29
|
+
// } else if (asJSON) {
|
|
30
|
+
// return JSON.stringify(value)
|
|
31
|
+
// } else {
|
|
32
|
+
// // Return shorter version of object
|
|
33
|
+
// const asYaml = stringify(value)
|
|
34
|
+
// const asJSON = JSON.stringify(value)
|
|
35
|
+
// if (tokenizer.encode(asYaml).length <= tokenizer.encode(asJSON).length) {
|
|
36
|
+
// return asYaml
|
|
37
|
+
// } else {
|
|
38
|
+
// return asJSON
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
// } else {
|
|
42
|
+
// return value.toString()
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* Clips the text to a maximum length in case it exceeds the limit.
|
|
48
|
+
* @param {string} text The text to clip.
|
|
49
|
+
* @param {number} maxLength The maximum length of the text to return, cutting off the last whole word.
|
|
50
|
+
* @returns {string} The modified text
|
|
51
|
+
*/
|
|
52
|
+
static snippet(text, maxLength) {
|
|
53
|
+
if (text.length <= maxLength) {
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
let snippet = text.slice(0, maxLength);
|
|
57
|
+
snippet = snippet.slice(0, Math.min(snippet.length, snippet.lastIndexOf(' ')));
|
|
58
|
+
snippet += '...';
|
|
59
|
+
return snippet;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Convert citation tags `[doc(s)n]` to `[n]` where n is a number.
|
|
63
|
+
* @param {string} text The text to format.
|
|
64
|
+
* @returns {string} The formatted text.
|
|
65
|
+
*/
|
|
66
|
+
static formatCitationsResponse(text) {
|
|
67
|
+
return text.replace(/\[docs?(\d+)\]/gi, '[$1]');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the citations used in the text. This will remove any citations that are included in the citations array from the response but not referenced in the text.
|
|
71
|
+
* @param {string} text - The text to search for citation references, i.e. [1], [2], etc.
|
|
72
|
+
* @param {ClientCitation[]} citations - The list of citations to search for.
|
|
73
|
+
* @returns {ClientCitation[] | undefined} The list of citations used in the text.
|
|
74
|
+
*/
|
|
75
|
+
static getUsedCitations(text, citations) {
|
|
76
|
+
const regex = /\[(\d+)\]/gi;
|
|
77
|
+
const matches = text.match(regex);
|
|
78
|
+
if (!matches) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
// Remove duplicates
|
|
82
|
+
const filteredMatches = new Set();
|
|
83
|
+
matches.forEach((match) => {
|
|
84
|
+
if (filteredMatches.has(match)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
filteredMatches.add(match);
|
|
88
|
+
});
|
|
89
|
+
// Add citations
|
|
90
|
+
const usedCitations = [];
|
|
91
|
+
filteredMatches.forEach((match) => {
|
|
92
|
+
const found = citations.find((citation) => `[${citation.position}]` === match);
|
|
93
|
+
if (found) {
|
|
94
|
+
usedCitations.push(found);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return usedCitations;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.Utilities = Utilities;
|
|
101
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/app/streaming/utilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,mCAAmC;AAEnC,2CAA2C;AAE3C;;GAEG;AACH,MAAa,SAAS;IACtB,QAAQ;IACR,uCAAuC;IACvC,kBAAkB;IAClB,6GAA6G;IAC7G,qEAAqE;IACrE,8CAA8C;IAC9C,gIAAgI;IAChI,4CAA4C;IAC5C,UAAU;IACV,iGAAiG;IACjG,mDAAmD;IACn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,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAM;YACR,CAAC;YAED,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;QAEF,gBAAgB;QAChB,MAAM,aAAa,GAAqB,EAAE,CAAA;QAC1C,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAChC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAA;YAC9E,IAAI,KAAK,EAAE,CAAC;gBACV,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO,aAAa,CAAA;IACtB,CAAC;CACF;AA7FD,8BA6FC"}
|
|
@@ -4,6 +4,7 @@ import { ResourceResponse } from './connector-client/resourceResponse';
|
|
|
4
4
|
import { TurnContextStateCollection } from './turnContextStateCollection';
|
|
5
5
|
import { AttachmentInfo } from './connector-client/attachmentInfo';
|
|
6
6
|
import { AttachmentData } from './connector-client/attachmentData';
|
|
7
|
+
import { StreamingResponse } from './app/streaming/streamingResponse';
|
|
7
8
|
/**
|
|
8
9
|
* Defines a handler for processing and sending activities.
|
|
9
10
|
* Used for middleware that needs to intercept or modify activities being sent.
|
|
@@ -66,6 +67,7 @@ export declare class TurnContext {
|
|
|
66
67
|
private readonly _onDeleteActivity;
|
|
67
68
|
private readonly _turn;
|
|
68
69
|
private readonly _locale;
|
|
70
|
+
private readonly _streamingResponse;
|
|
69
71
|
/**
|
|
70
72
|
* Initializes a new instance of the TurnContext class.
|
|
71
73
|
*
|
|
@@ -229,6 +231,7 @@ export declare class TurnContext {
|
|
|
229
231
|
* the processing of the current turn.
|
|
230
232
|
*/
|
|
231
233
|
get turnState(): TurnContextStateCollection;
|
|
234
|
+
get streamingResponse(): StreamingResponse;
|
|
232
235
|
/**
|
|
233
236
|
* Emits events to registered middleware handlers.
|
|
234
237
|
*
|
package/dist/src/turnContext.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.TurnContext = exports.AgentCallbackHandlerKey = void 0;
|
|
|
5
5
|
const activityHandler_1 = require("./activityHandler");
|
|
6
6
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
7
7
|
const turnContextStateCollection_1 = require("./turnContextStateCollection");
|
|
8
|
+
const streamingResponse_1 = require("./app/streaming/streamingResponse");
|
|
8
9
|
/**
|
|
9
10
|
* Key for the agent callback handler in TurnState collection.
|
|
10
11
|
*/
|
|
@@ -48,6 +49,7 @@ class TurnContext {
|
|
|
48
49
|
this._adapter = adapterOrContext;
|
|
49
50
|
this._activity = request;
|
|
50
51
|
}
|
|
52
|
+
this._streamingResponse = new streamingResponse_1.StreamingResponse(this);
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Sends a trace activity for debugging purposes.
|
|
@@ -327,6 +329,9 @@ class TurnContext {
|
|
|
327
329
|
get turnState() {
|
|
328
330
|
return this._turnState;
|
|
329
331
|
}
|
|
332
|
+
get streamingResponse() {
|
|
333
|
+
return this._streamingResponse;
|
|
334
|
+
}
|
|
330
335
|
/**
|
|
331
336
|
* Emits events to registered middleware handlers.
|
|
332
337
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,uDAAuD;AAEvD,gEAAsH;AAEtH,6EAAyE;
|
|
1
|
+
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,uDAAuD;AAEvD,gEAAsH;AAEtH,6EAAyE;AAGzE,yEAAqE;AAgCrE;;GAEG;AACU,QAAA,uBAAuB,GAAG,sBAAsB,CAAA;AAO7D;;;;;;;;;;;;;;;GAeG;A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,IAAI,CAAO,QAAqF,EAAE,GAAM,EAAE,IAAsB;QAC5I,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAkB,EAAc,EAAE;YACjF,IAAI,CAAC;gBACH,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;YACrH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,CAAA;QACD,OAAO,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAxWD,kCAwWC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.4-ga4d0401645",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/msal-node": "^3.5.3",
|
|
23
|
-
"@microsoft/agents-activity": "0.5.
|
|
23
|
+
"@microsoft/agents-activity": "0.5.4-ga4d0401645",
|
|
24
24
|
"axios": "^1.9.0",
|
|
25
25
|
"debug": "^4.3.7",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ClientCitation } from './clientCitation'
|
|
7
|
+
import { SensitivityUsageInfo } from './sensitivityUsageInfo'
|
|
8
|
+
|
|
9
|
+
export interface AIEntity {
|
|
10
|
+
/**
|
|
11
|
+
* Required as 'https://schema.org/Message'
|
|
12
|
+
*/
|
|
13
|
+
type: 'https://schema.org/Message';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Required as 'Message
|
|
17
|
+
*/
|
|
18
|
+
'@type': 'Message';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Required as 'https://schema.org
|
|
22
|
+
*/
|
|
23
|
+
'@context': 'https://schema.org';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Must be left blank. This is for Bot Framework schema.
|
|
27
|
+
*/
|
|
28
|
+
'@id': '';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Indicate that the content was generated by AI.
|
|
32
|
+
*/
|
|
33
|
+
additionalType: ['AIGeneratedContent'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Optional; if citations object is included, the sent activity will include the citations, referenced in the activity text.
|
|
37
|
+
*/
|
|
38
|
+
citation?: ClientCitation[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Optional; if usage_info object is included, the sent activity will include the sensitivity usage information.
|
|
42
|
+
*/
|
|
43
|
+
usageInfo?: SensitivityUsageInfo;
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An action call to be requested by the LLM model. This type is a generic meant to be the equivalent of OpenAI's [`ChatCompletionMessageToolCall`](https://github.com/openai/openai-node/blob/master/src/resources/chat/completions.ts#L477), but is not tied to OpenAI's implementation in order to allow for flexibility for other models in the future.
|
|
8
|
+
*/
|
|
9
|
+
export interface ActionCall {
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the tool call.
|
|
12
|
+
*/
|
|
13
|
+
id: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The function that the model called.
|
|
17
|
+
*/
|
|
18
|
+
function: {
|
|
19
|
+
/**
|
|
20
|
+
* The name of the function.
|
|
21
|
+
*/
|
|
22
|
+
name: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The arguments to call the function with, as generated by the model in JSON
|
|
26
|
+
* format. Note that the model does not always generate valid JSON, and may
|
|
27
|
+
* hallucinate parameters not defined by your function schema. Validate the
|
|
28
|
+
* arguments in your code before calling your function.
|
|
29
|
+
*/
|
|
30
|
+
arguments: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The type of the tool. Currently, only `function` is supported.
|
|
35
|
+
*/
|
|
36
|
+
type: 'function';
|
|
37
|
+
}
|