@microsoft/agents-hosting 0.4.3 → 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/activityWireCompat.js +1 -1
- package/dist/src/activityWireCompat.js.map +1 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.d.ts +115 -0
- package/dist/src/app/adaptiveCards/activityValueParsers.js +224 -0
- package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.d.ts +21 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js +26 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +57 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +272 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.d.ts +20 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js +7 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.d.ts +31 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js +16 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js.map +1 -0
- package/dist/src/app/adaptiveCards/index.d.ts +3 -0
- package/dist/src/app/adaptiveCards/index.js +20 -0
- package/dist/src/app/adaptiveCards/index.js.map +1 -0
- package/dist/src/app/adaptiveCards/query.d.ts +22 -0
- package/dist/src/app/adaptiveCards/query.js +7 -0
- package/dist/src/app/adaptiveCards/query.js.map +1 -0
- package/dist/src/app/agentApplication.d.ts +56 -8
- package/dist/src/app/agentApplication.js +88 -11
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +2 -2
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +17 -2
- package/dist/src/app/appRoute.d.ts +5 -0
- package/dist/src/app/attachmentDownloader.js +1 -0
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/extensions.d.ts +9 -0
- package/dist/src/app/extensions.js +16 -0
- package/dist/src/app/extensions.js.map +1 -0
- package/dist/src/app/index.d.ts +2 -0
- package/dist/src/app/index.js +2 -0
- package/dist/src/app/index.js.map +1 -1
- 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/auth/jwt-middleware.js +1 -0
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/baseAdapter.js +1 -1
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cards/adaptiveCard.d.ts +15 -0
- package/dist/src/cards/adaptiveCard.js +7 -0
- package/dist/src/cards/adaptiveCard.js.map +1 -0
- package/dist/src/cards/index.d.ts +1 -0
- package/dist/src/cards/index.js +1 -0
- package/dist/src/cards/index.js.map +1 -1
- package/dist/src/cloudAdapter.js +6 -7
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.d.ts +6 -4
- package/dist/src/connector-client/connectorClient.js +34 -17
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- 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/activityWireCompat.ts +1 -1
- package/src/app/adaptiveCards/activityValueParsers.ts +249 -0
- package/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.ts +24 -0
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +320 -0
- package/src/app/adaptiveCards/adaptiveCardsOptions.ts +23 -0
- package/src/app/adaptiveCards/adaptiveCardsSearchParams.ts +28 -0
- package/src/app/adaptiveCards/index.ts +3 -0
- package/src/app/adaptiveCards/query.ts +25 -0
- package/src/app/agentApplication.ts +109 -29
- package/src/app/agentApplicationBuilder.ts +2 -2
- package/src/app/agentApplicationOptions.ts +20 -2
- package/src/app/appRoute.ts +6 -0
- package/src/app/attachmentDownloader.ts +1 -0
- package/src/app/extensions.ts +19 -0
- package/src/app/index.ts +2 -0
- 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/auth/jwt-middleware.ts +1 -1
- package/src/baseAdapter.ts +2 -2
- package/src/cards/adaptiveCard.ts +16 -0
- package/src/cards/index.ts +1 -0
- package/src/cloudAdapter.ts +5 -7
- package/src/connector-client/connectorClient.ts +38 -19
- package/src/turnContext.ts +7 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ActionCall } from './actionCall';
|
|
6
|
+
/**
|
|
7
|
+
* A message object sent to or received from an LLM.
|
|
8
|
+
* @param TContent Optional. Type of the message content. Defaults to `string`
|
|
9
|
+
*/
|
|
10
|
+
export interface Message<TContent = string> {
|
|
11
|
+
/**
|
|
12
|
+
* The messages role. Typically 'system', 'user', 'assistant', 'tool', 'function'.
|
|
13
|
+
*/
|
|
14
|
+
role: string;
|
|
15
|
+
/**
|
|
16
|
+
* Text of the message.
|
|
17
|
+
*/
|
|
18
|
+
content: TContent | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Optional. A named function to call.
|
|
21
|
+
*/
|
|
22
|
+
function_call?: FunctionCall;
|
|
23
|
+
/**
|
|
24
|
+
* The context used for the message.
|
|
25
|
+
*/
|
|
26
|
+
context?: MessageContext;
|
|
27
|
+
/**
|
|
28
|
+
* Optional. Name of the function that was called.
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional. The action or tool to be called by the model when using 'tools' augmentation. In OpenAI, this is the tool_calls property returned from the model.
|
|
33
|
+
*/
|
|
34
|
+
action_calls?: ActionCall[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional. The id of the action called.
|
|
37
|
+
*/
|
|
38
|
+
action_call_id?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A named function to call.
|
|
42
|
+
*/
|
|
43
|
+
export interface FunctionCall {
|
|
44
|
+
/**
|
|
45
|
+
* Name of the function to call.
|
|
46
|
+
*/
|
|
47
|
+
name?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Optional. Arguments to pass to the function. Must be deserialized.
|
|
50
|
+
*/
|
|
51
|
+
arguments?: string;
|
|
52
|
+
}
|
|
53
|
+
export type MessageContentParts = TextContentPart | ImageContentPart;
|
|
54
|
+
export interface TextContentPart {
|
|
55
|
+
/**
|
|
56
|
+
* Type of the message content. Should always be 'text'.
|
|
57
|
+
*/
|
|
58
|
+
type: 'text';
|
|
59
|
+
/**
|
|
60
|
+
* The text of the message.
|
|
61
|
+
*/
|
|
62
|
+
text: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ImageContentPart {
|
|
65
|
+
/**
|
|
66
|
+
* Type of the message content. Should always be 'image_url'.
|
|
67
|
+
*/
|
|
68
|
+
type: 'image_url';
|
|
69
|
+
/**
|
|
70
|
+
* The URL of the image.
|
|
71
|
+
*/
|
|
72
|
+
image_url: string | {
|
|
73
|
+
url: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Citations returned by the model.
|
|
78
|
+
*/
|
|
79
|
+
export interface Citation {
|
|
80
|
+
/**
|
|
81
|
+
* The content of the citation.
|
|
82
|
+
*/
|
|
83
|
+
content: string;
|
|
84
|
+
/**
|
|
85
|
+
* The title of the citation.
|
|
86
|
+
*/
|
|
87
|
+
title: string | null;
|
|
88
|
+
/**
|
|
89
|
+
* The URL of the citation.
|
|
90
|
+
*/
|
|
91
|
+
url: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The filepath of the document.
|
|
94
|
+
*/
|
|
95
|
+
filepath: string | null;
|
|
96
|
+
}
|
|
97
|
+
export interface MessageContext {
|
|
98
|
+
/**
|
|
99
|
+
* Citations used in the message.
|
|
100
|
+
*/
|
|
101
|
+
citations: Citation[];
|
|
102
|
+
/**
|
|
103
|
+
* The intent of the message (what the user wrote).
|
|
104
|
+
*/
|
|
105
|
+
intent: string;
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/app/streaming/message.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitivity usage info for content sent to the user. This is used to provide information about the content to the user. See ClientCitation for more information.
|
|
3
|
+
*/
|
|
4
|
+
export interface SensitivityUsageInfo {
|
|
5
|
+
/**
|
|
6
|
+
* Must be "https://schema.org/Message"
|
|
7
|
+
*/
|
|
8
|
+
type: 'https://schema.org/Message';
|
|
9
|
+
/**
|
|
10
|
+
* Required; Set to CreativeWork;
|
|
11
|
+
*/
|
|
12
|
+
'@type': 'CreativeWork';
|
|
13
|
+
/**
|
|
14
|
+
* Sensitivity description of the content
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Sensitivity title of the content
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional; ignored in Teams.
|
|
23
|
+
*/
|
|
24
|
+
position?: number;
|
|
25
|
+
pattern?: {
|
|
26
|
+
/**
|
|
27
|
+
* Set to DefinedTerm
|
|
28
|
+
*/
|
|
29
|
+
'@type': 'DefinedTerm';
|
|
30
|
+
inDefinedTermSet: string;
|
|
31
|
+
/**
|
|
32
|
+
* Color
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* e.g. #454545
|
|
37
|
+
*/
|
|
38
|
+
termCode: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitivityUsageInfo.js","sourceRoot":"","sources":["../../../../src/app/streaming/sensitivityUsageInfo.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Attachment } from '@microsoft/agents-activity';
|
|
6
|
+
import { TurnContext } from '../../turnContext';
|
|
7
|
+
import { ClientCitation } from './clientCitation';
|
|
8
|
+
import { SensitivityUsageInfo } from './sensitivityUsageInfo';
|
|
9
|
+
import { Citation } from './message';
|
|
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
|
+
export declare class StreamingResponse {
|
|
21
|
+
private readonly _context;
|
|
22
|
+
private _nextSequence;
|
|
23
|
+
private _streamId?;
|
|
24
|
+
private _message;
|
|
25
|
+
private _attachments?;
|
|
26
|
+
private _ended;
|
|
27
|
+
private _queue;
|
|
28
|
+
private _queueSync;
|
|
29
|
+
private _chunkQueued;
|
|
30
|
+
private _enableFeedbackLoop;
|
|
31
|
+
private _feedbackLoopType?;
|
|
32
|
+
private _enableGeneratedByAILabel;
|
|
33
|
+
private _citations?;
|
|
34
|
+
private _sensitivityLabel?;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new StreamingResponse instance.
|
|
37
|
+
* @param {TurnContext} context - Context for the current turn of conversation with the user.
|
|
38
|
+
* @returns {TurnContext} - The context for the current turn of conversation with the user.
|
|
39
|
+
*/
|
|
40
|
+
constructor(context: TurnContext);
|
|
41
|
+
/**
|
|
42
|
+
* Gets the stream ID of the current response.
|
|
43
|
+
* @returns {string | undefined} - The stream ID of the current response.
|
|
44
|
+
* @remarks
|
|
45
|
+
* Assigned after the initial update is sent.
|
|
46
|
+
*/
|
|
47
|
+
get streamId(): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the citations of the current response.
|
|
50
|
+
*/
|
|
51
|
+
get citations(): ClientCitation[] | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the number of updates sent for the stream.
|
|
54
|
+
* @returns {number} - The number of updates sent for the stream.
|
|
55
|
+
*/
|
|
56
|
+
get updatesSent(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Queues an informative update to be sent to the client.
|
|
59
|
+
* @param {string} text Text of the update to send.
|
|
60
|
+
*/
|
|
61
|
+
queueInformativeUpdate(text: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Queues a chunk of partial message text to be sent to the client
|
|
64
|
+
* @remarks
|
|
65
|
+
* The text we be sent as quickly as possible to the client. Chunks may be combined before
|
|
66
|
+
* delivery to the client.
|
|
67
|
+
* @param {string} text Partial text of the message to send.
|
|
68
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
69
|
+
*/
|
|
70
|
+
queueTextChunk(text: string, citations?: Citation[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Ends the stream by sending the final message to the client.
|
|
73
|
+
* @returns {Promise<void>} - A promise representing the async operation
|
|
74
|
+
*/
|
|
75
|
+
endStream(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Sets the attachments to attach to the final chunk.
|
|
78
|
+
* @param attachments List of attachments.
|
|
79
|
+
*/
|
|
80
|
+
setAttachments(attachments: Attachment[]): void;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the sensitivity label to attach to the final chunk.
|
|
83
|
+
* @param sensitivityLabel The sensitivty label.
|
|
84
|
+
*/
|
|
85
|
+
setSensitivityLabel(sensitivityLabel: SensitivityUsageInfo): void;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the citations for the full message.
|
|
88
|
+
* @param {Citation[]} citations Citations to be included in the message.
|
|
89
|
+
*/
|
|
90
|
+
setCitations(citations: Citation[]): void;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the Feedback Loop in Teams that allows a user to
|
|
93
|
+
* give thumbs up or down to a response.
|
|
94
|
+
* Default is `false`.
|
|
95
|
+
* @param enableFeedbackLoop If true, the feedback loop is enabled.
|
|
96
|
+
*/
|
|
97
|
+
setFeedbackLoop(enableFeedbackLoop: boolean): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the type of UI to use for the feedback loop.
|
|
100
|
+
* @param feedbackLoopType The type of the feedback loop.
|
|
101
|
+
*/
|
|
102
|
+
setFeedbackLoopType(feedbackLoopType: 'default' | 'custom'): void;
|
|
103
|
+
/**
|
|
104
|
+
* Sets the the Generated by AI label in Teams
|
|
105
|
+
* Default is `false`.
|
|
106
|
+
* @param enableGeneratedByAILabel If true, the label is added.
|
|
107
|
+
*/
|
|
108
|
+
setGeneratedByAILabel(enableGeneratedByAILabel: boolean): void;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the most recently streamed message.
|
|
111
|
+
* @returns The streamed message.
|
|
112
|
+
*/
|
|
113
|
+
getMessage(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Waits for the outgoing activity queue to be empty.
|
|
116
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
117
|
+
*/
|
|
118
|
+
waitForQueue(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Queues the next chunk of text to be sent to the client.
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
private queueNextChunk;
|
|
124
|
+
/**
|
|
125
|
+
* Queues an activity to be sent to the client.
|
|
126
|
+
*/
|
|
127
|
+
private queueActivity;
|
|
128
|
+
/**
|
|
129
|
+
* Sends any queued activities to the client until the queue is empty.
|
|
130
|
+
* @returns {Promise<void>} - A promise that will be resolved once the queue is empty.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
private drainQueue;
|
|
134
|
+
/**
|
|
135
|
+
* Sends an activity to the client and saves the stream ID returned.
|
|
136
|
+
* @param {Activity} activity - The activity to send.
|
|
137
|
+
* @returns {Promise<void>} - A promise representing the async operation.
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
private sendActivity;
|
|
141
|
+
}
|
|
@@ -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;QACxB,WAAM,GAA0B,EAAE,CAAA;QAElC,iBAAY,GAAG,KAAK,CAAA;QAE5B,8BAA8B;QACtB,wBAAmB,GAAG,KA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I,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
|
+
}
|