@webex/internal-plugin-ai-assistant 0.0.0-next.9 → 3.11.0-next.10
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/README.md +44 -1
- package/dist/ai-assistant.js +168 -152
- package/dist/ai-assistant.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.js +15 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.js +172 -0
- package/dist/utils.js.map +1 -0
- package/package.json +8 -8
- package/src/ai-assistant.ts +120 -89
- package/src/config.ts +1 -1
- package/src/constants.ts +11 -0
- package/src/types.ts +12 -1
- package/src/utils.ts +74 -0
- package/test/unit/data/messages.ts +745 -0
- package/test/unit/spec/ai-assistant.ts +1034 -130
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm install --save @webex/internal-plugin-ai-assistant
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
The responses from the AI assistant service are delivered asynchronously via mercury. The methods in this plugin return a stream ID which can then be used to listen to the updates for a given request. The service will
|
|
25
|
+
The responses from the AI assistant service are delivered asynchronously via mercury. The methods in this plugin return a stream ID which can then be used to listen to the updates for a given request. The service will respond in chunks. The latest response for a given request will contain the full response.
|
|
26
26
|
|
|
27
27
|
The data used for the arguments to the methods in this plugin is obtained from either Locus or the Meeting Container.
|
|
28
28
|
```js
|
|
@@ -123,8 +123,51 @@ webex.internal.aiAssistant.askMeAnything({
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
|
+
|
|
127
|
+
// Advanced: Use the common makeAiAssistantRequest method for custom requests
|
|
128
|
+
webex.internal.aiAssistant.makeAiAssistantRequest({
|
|
129
|
+
sessionId: '<session-id>', // Optional for first request
|
|
130
|
+
encryptionKeyUrl: '<encryption-key-url>',
|
|
131
|
+
contextResources: [{
|
|
132
|
+
id: '<meeting-instance-id>',
|
|
133
|
+
type: 'meeting',
|
|
134
|
+
url: 'company.webex.com'
|
|
135
|
+
}],
|
|
136
|
+
contentType: 'message', // 'action' or 'message'
|
|
137
|
+
contentValue: 'What were the key takeaways?',
|
|
138
|
+
requestId: 'custom-id', // Optional
|
|
139
|
+
locale: 'en_US', // Optional
|
|
140
|
+
assistant: 'meeting-assistant' // Optional
|
|
141
|
+
}).then((response) => {
|
|
142
|
+
const { requestId, sessionId, streamEventName } = response;
|
|
143
|
+
|
|
144
|
+
// Listen for streaming responses
|
|
145
|
+
webex.internal.aiAssistant.on(streamEventName, (data) => {
|
|
146
|
+
console.log('Custom AI Response:', data.message);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Optional Parameters
|
|
152
|
+
|
|
153
|
+
All AI Assistant methods support an optional `requestId` parameter that allows you to specify a custom request identifier:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
// Example with custom requestId
|
|
157
|
+
webex.internal.aiAssistant.summarizeMeeting({
|
|
158
|
+
meetingInstanceId: '<meeting-instance-id>',
|
|
159
|
+
meetingSite: 'company.webex.com',
|
|
160
|
+
sessionId: '<session-id>',
|
|
161
|
+
encryptionKeyUrl: '<encryption-key-url>',
|
|
162
|
+
requestId: 'my-custom-request-id' // Optional: specify your own request ID
|
|
163
|
+
}).then((response) => {
|
|
164
|
+
// The response will contain your custom requestId
|
|
165
|
+
console.log('Request ID:', response.requestId); // 'my-custom-request-id'
|
|
166
|
+
});
|
|
126
167
|
```
|
|
127
168
|
|
|
169
|
+
If `requestId` is not provided, a new UUID will be automatically generated for each request.
|
|
170
|
+
|
|
128
171
|
### Response Format
|
|
129
172
|
|
|
130
173
|
All AI Assistant methods return a Promise that resolves with:
|
package/dist/ai-assistant.js
CHANGED
|
@@ -22,6 +22,7 @@ require("@webex/internal-plugin-mercury");
|
|
|
22
22
|
var _lodash = require("lodash");
|
|
23
23
|
var _commonTimers = require("@webex/common-timers");
|
|
24
24
|
var _constants = require("./constants");
|
|
25
|
+
var _utils = require("./utils");
|
|
25
26
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /*!
|
|
27
28
|
* Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
|
|
@@ -80,16 +81,14 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
80
81
|
* @memberof AIAssistant
|
|
81
82
|
*/
|
|
82
83
|
unregister: function unregister() {
|
|
83
|
-
var _this2 = this;
|
|
84
84
|
if (!this.registered) {
|
|
85
85
|
this.logger.info('AI assistant->unregister#INFO, AI assistant plugin already unregistered');
|
|
86
86
|
return _promise.default.resolve();
|
|
87
87
|
}
|
|
88
88
|
this.stopListeningForEvents();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
89
|
+
this.trigger(_constants.AI_ASSISTANT_UNREGISTERED);
|
|
90
|
+
this.registered = false;
|
|
91
|
+
return _promise.default.resolve();
|
|
93
92
|
},
|
|
94
93
|
/**
|
|
95
94
|
* registers for Assistant API events through mercury
|
|
@@ -97,9 +96,12 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
97
96
|
* @private
|
|
98
97
|
*/
|
|
99
98
|
listenForEvents: function listenForEvents() {
|
|
100
|
-
var
|
|
99
|
+
var _this2 = this;
|
|
101
100
|
this.webex.internal.mercury.on(_constants.ASSISTANT_API_RESPONSE_EVENT, function (envelope) {
|
|
102
|
-
|
|
101
|
+
_this2._handleEvent(envelope.data);
|
|
102
|
+
});
|
|
103
|
+
this.webex.internal.mercury.on(_constants.ASSISTANT_API_ACTIVITY, function (envelope) {
|
|
104
|
+
_this2._handleAssistantActivity(envelope.data);
|
|
103
105
|
});
|
|
104
106
|
},
|
|
105
107
|
/**
|
|
@@ -109,6 +111,7 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
109
111
|
*/
|
|
110
112
|
stopListeningForEvents: function stopListeningForEvents() {
|
|
111
113
|
this.webex.internal.mercury.off(_constants.ASSISTANT_API_RESPONSE_EVENT);
|
|
114
|
+
this.webex.internal.mercury.off(_constants.ASSISTANT_API_ACTIVITY);
|
|
112
115
|
},
|
|
113
116
|
/**
|
|
114
117
|
* constructs the event name based on request id
|
|
@@ -137,50 +140,94 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
137
140
|
this.trigger(this._getResultEventName(data.clientRequestId), data);
|
|
138
141
|
},
|
|
139
142
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param {Object}
|
|
142
|
-
* @
|
|
143
|
-
* @param {string} options.encryptionKeyUrl the encryption key URL to use for
|
|
144
|
-
* @returns {Promise<Object>} returns a promise that resolves with the decrypted value
|
|
143
|
+
* Handles an incoming activity event from the assistant API and triggers the correct event for consumers to listen to
|
|
144
|
+
* @param {Object} data the event data
|
|
145
|
+
* @returns {undefined}
|
|
145
146
|
*/
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
return (0, _asyncToGenerator2.default)(
|
|
149
|
-
|
|
150
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
147
|
+
_handleAssistantActivity: function _handleAssistantActivity(data) {
|
|
148
|
+
var _this3 = this;
|
|
149
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
150
|
+
return _regenerator.default.wrap(function (_context) {
|
|
151
151
|
while (1) switch (_context.prev = _context.next) {
|
|
152
152
|
case 0:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return _context.abrupt("return", result);
|
|
159
|
-
case 5:
|
|
153
|
+
_context.next = 1;
|
|
154
|
+
return (0, _utils.decryptAssistantActivity)(data.activity, _this3.webex);
|
|
155
|
+
case 1:
|
|
156
|
+
_this3.trigger(_constants.AI_ASSISTANT_ACTIVITY_RECEIVED, data);
|
|
157
|
+
case 2:
|
|
160
158
|
case "end":
|
|
161
159
|
return _context.stop();
|
|
162
160
|
}
|
|
163
161
|
}, _callee);
|
|
164
162
|
}))();
|
|
165
163
|
},
|
|
164
|
+
/**
|
|
165
|
+
* Decrypts the response content in place
|
|
166
|
+
* @param {any} responseContent the content object from the assistant-api response
|
|
167
|
+
* @returns {Promise} resolves once decryption is complete
|
|
168
|
+
*/
|
|
169
|
+
_decryptContent: function _decryptContent(responseContent) {
|
|
170
|
+
var _this4 = this;
|
|
171
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
172
|
+
var _t;
|
|
173
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
174
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
175
|
+
case 0:
|
|
176
|
+
_t = responseContent.name;
|
|
177
|
+
_context2.next = _t === _constants.RESPONSE_NAMES.MESSAGE ? 1 : _t === _constants.RESPONSE_NAMES.CITED_ANSWER ? 3 : _t === _constants.RESPONSE_NAMES.SCHEDULE_MEETING ? 5 : _t === _constants.RESPONSE_NAMES.TOOL_RESULT ? 7 : _t === _constants.RESPONSE_NAMES.TOOL_USE ? 8 : _t === _constants.RESPONSE_NAMES.WORKSPACE ? 10 : 12;
|
|
178
|
+
break;
|
|
179
|
+
case 1:
|
|
180
|
+
_context2.next = 2;
|
|
181
|
+
return (0, _utils.decryptMessage)(responseContent, _this4.webex);
|
|
182
|
+
case 2:
|
|
183
|
+
return _context2.abrupt("continue", 13);
|
|
184
|
+
case 3:
|
|
185
|
+
_context2.next = 4;
|
|
186
|
+
return (0, _utils.decryptCitedAnswer)(responseContent, _this4.webex);
|
|
187
|
+
case 4:
|
|
188
|
+
return _context2.abrupt("continue", 13);
|
|
189
|
+
case 5:
|
|
190
|
+
_context2.next = 6;
|
|
191
|
+
return (0, _utils.decryptScheduleMeeting)(responseContent, _this4.webex);
|
|
192
|
+
case 6:
|
|
193
|
+
return _context2.abrupt("continue", 13);
|
|
194
|
+
case 7:
|
|
195
|
+
return _context2.abrupt("continue", 13);
|
|
196
|
+
case 8:
|
|
197
|
+
_context2.next = 9;
|
|
198
|
+
return (0, _utils.decryptToolUse)(responseContent, _this4.webex);
|
|
199
|
+
case 9:
|
|
200
|
+
return _context2.abrupt("continue", 13);
|
|
201
|
+
case 10:
|
|
202
|
+
_context2.next = 11;
|
|
203
|
+
return (0, _utils.decryptWorkspace)(responseContent, _this4.webex);
|
|
204
|
+
case 11:
|
|
205
|
+
return _context2.abrupt("continue", 13);
|
|
206
|
+
case 12:
|
|
207
|
+
_this4.logger.error("AI assistant->_decryptContent#ERROR, Unknown response content name: ".concat(responseContent.name));
|
|
208
|
+
case 13:
|
|
209
|
+
case "end":
|
|
210
|
+
return _context2.stop();
|
|
211
|
+
}
|
|
212
|
+
}, _callee2);
|
|
213
|
+
}))();
|
|
214
|
+
},
|
|
166
215
|
/**
|
|
167
216
|
* Makes the request to the AI assistant service
|
|
168
217
|
* @param {Object} options
|
|
169
218
|
* @param {string} options.resource the URL to query
|
|
170
219
|
* @param {Mixed} options.params additional params for the body of the request
|
|
171
|
-
* @param {string} options.dataPath the path to get the data in the result object
|
|
172
220
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
173
221
|
*/
|
|
174
222
|
_request: function _request(options) {
|
|
175
223
|
var _this5 = this;
|
|
176
224
|
var resource = options.resource,
|
|
177
225
|
params = options.params,
|
|
178
|
-
|
|
226
|
+
headers = options.headers;
|
|
179
227
|
var timeout = this.config.requestTimeout;
|
|
180
|
-
var requestId = _uuid.default.v4();
|
|
228
|
+
var requestId = options.requestId || _uuid.default.v4();
|
|
181
229
|
var eventName = this._getResultEventName(requestId);
|
|
182
230
|
var streamEventName = this._getStreamEventName(requestId);
|
|
183
|
-
var concatenatedMessage = '';
|
|
184
231
|
|
|
185
232
|
// eslint-disable-next-line no-async-promise-executor
|
|
186
233
|
return new _promise.default(function (resolve, reject) {
|
|
@@ -194,98 +241,50 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
194
241
|
});
|
|
195
242
|
}, timeout);
|
|
196
243
|
_this5.listenTo(_this5, eventName, /*#__PURE__*/function () {
|
|
197
|
-
var
|
|
198
|
-
var resultData, errorMessage, errorCode,
|
|
199
|
-
return _regenerator.default.wrap(function
|
|
200
|
-
while (1) switch (
|
|
244
|
+
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(data) {
|
|
245
|
+
var resultData, errorMessage, errorCode, responseType, decryptErrorMessage, _t2;
|
|
246
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
247
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
201
248
|
case 0:
|
|
202
249
|
timer.reset();
|
|
203
|
-
resultData = (0, _lodash.get)(data,
|
|
250
|
+
resultData = (0, _lodash.get)(data, 'response.content', {});
|
|
204
251
|
errorMessage = (0, _lodash.get)(data, 'response.errorMessage');
|
|
205
252
|
errorCode = (0, _lodash.get)(data, 'response.errorCode');
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
253
|
+
responseType = (0, _lodash.get)(data, 'responseType');
|
|
254
|
+
if (data.finished) {
|
|
255
|
+
timer.cancel();
|
|
256
|
+
_this5.stopListening(_this5, eventName);
|
|
209
257
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (!(resultData !== null && resultData !== void 0 && resultData.value)) {
|
|
214
|
-
_context2.next = 11;
|
|
258
|
+
_context3.prev = 1;
|
|
259
|
+
if (errorCode) {
|
|
260
|
+
_context3.next = 2;
|
|
215
261
|
break;
|
|
216
262
|
}
|
|
217
|
-
|
|
218
|
-
return _this5.
|
|
219
|
-
case
|
|
220
|
-
|
|
221
|
-
case 11:
|
|
222
|
-
// Emit the final message
|
|
223
|
-
_this5.trigger(streamEventName, {
|
|
224
|
-
message: decryptedMessage || '',
|
|
225
|
-
requestId: requestId,
|
|
226
|
-
finished: true,
|
|
227
|
-
errorMessage: errorMessage,
|
|
228
|
-
errorCode: errorCode
|
|
229
|
-
});
|
|
230
|
-
_this5.stopListening(_this5, eventName);
|
|
231
|
-
_context2.next = 18;
|
|
263
|
+
_context3.next = 2;
|
|
264
|
+
return _this5._decryptContent(resultData);
|
|
265
|
+
case 2:
|
|
266
|
+
_context3.next = 4;
|
|
232
267
|
break;
|
|
233
|
-
case
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
268
|
+
case 3:
|
|
269
|
+
_context3.prev = 3;
|
|
270
|
+
_t2 = _context3["catch"](1);
|
|
271
|
+
decryptErrorMessage = _t2.message;
|
|
272
|
+
case 4:
|
|
273
|
+
_this5.trigger(streamEventName, (0, _lodash.merge)({}, data.response, {
|
|
274
|
+
responseType: responseType,
|
|
238
275
|
requestId: requestId,
|
|
239
|
-
finished:
|
|
240
|
-
errorMessage: errorMessage ||
|
|
276
|
+
finished: data.finished,
|
|
277
|
+
errorMessage: errorMessage || decryptErrorMessage,
|
|
241
278
|
errorCode: errorCode
|
|
242
|
-
});
|
|
243
|
-
case
|
|
244
|
-
_context2.next = 33;
|
|
245
|
-
break;
|
|
246
|
-
case 20:
|
|
247
|
-
_context2.prev = 20;
|
|
248
|
-
_decryptedMessage = '';
|
|
249
|
-
if (!(resultData !== null && resultData !== void 0 && resultData.value)) {
|
|
250
|
-
_context2.next = 26;
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
_context2.next = 25;
|
|
254
|
-
return _this5._decryptData(resultData);
|
|
255
|
-
case 25:
|
|
256
|
-
_decryptedMessage = _context2.sent;
|
|
257
|
-
case 26:
|
|
258
|
-
concatenatedMessage += _decryptedMessage;
|
|
259
|
-
|
|
260
|
-
// Emit the concatenated message so far
|
|
261
|
-
_this5.trigger(streamEventName, {
|
|
262
|
-
message: concatenatedMessage,
|
|
263
|
-
requestId: requestId,
|
|
264
|
-
finished: false,
|
|
265
|
-
errorMessage: errorMessage,
|
|
266
|
-
errorCode: errorCode
|
|
267
|
-
});
|
|
268
|
-
_context2.next = 33;
|
|
269
|
-
break;
|
|
270
|
-
case 30:
|
|
271
|
-
_context2.prev = 30;
|
|
272
|
-
_context2.t1 = _context2["catch"](20);
|
|
273
|
-
// If decryption fails, we still want to continue listening for more messages
|
|
274
|
-
_this5.trigger(streamEventName, {
|
|
275
|
-
message: concatenatedMessage,
|
|
276
|
-
requestId: requestId,
|
|
277
|
-
finished: false,
|
|
278
|
-
errorMessage: errorMessage || _context2.t1.message,
|
|
279
|
-
errorCode: errorCode
|
|
280
|
-
});
|
|
281
|
-
case 33:
|
|
279
|
+
}));
|
|
280
|
+
case 5:
|
|
282
281
|
case "end":
|
|
283
|
-
return
|
|
282
|
+
return _context3.stop();
|
|
284
283
|
}
|
|
285
|
-
},
|
|
284
|
+
}, _callee3, null, [[1, 3]]);
|
|
286
285
|
}));
|
|
287
286
|
return function (_x) {
|
|
288
|
-
return
|
|
287
|
+
return _ref.apply(this, arguments);
|
|
289
288
|
};
|
|
290
289
|
}());
|
|
291
290
|
_this5.webex.request({
|
|
@@ -295,19 +294,18 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
295
294
|
contentType: 'application/json',
|
|
296
295
|
body: _objectSpread({
|
|
297
296
|
clientRequestId: requestId
|
|
298
|
-
}, params)
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
var sessionId = body.sessionId;
|
|
304
|
-
resolve({
|
|
297
|
+
}, params),
|
|
298
|
+
headers: headers
|
|
299
|
+
}).then(function (_ref2) {
|
|
300
|
+
var body = _ref2.body;
|
|
301
|
+
resolve(_objectSpread(_objectSpread({}, body), {}, {
|
|
305
302
|
requestId: requestId,
|
|
306
|
-
sessionId: sessionId,
|
|
307
303
|
streamEventName: streamEventName
|
|
308
|
-
});
|
|
309
|
-
|
|
304
|
+
}));
|
|
305
|
+
}).catch(function (error) {
|
|
306
|
+
reject(error);
|
|
310
307
|
});
|
|
308
|
+
timer.start();
|
|
311
309
|
});
|
|
312
310
|
},
|
|
313
311
|
/**
|
|
@@ -321,28 +319,33 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
321
319
|
* @param {Object} options.parameters optional parameters to include in the request (for action type only)
|
|
322
320
|
* @param {Object} options.assistant optional parameter to specify the assistant to use
|
|
323
321
|
* @param {Object} options.locale optional locale to use for the request, defaults to 'en_US'
|
|
322
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
323
|
+
* @param {string} options.entryPoint optional entryPoint to use for this request
|
|
324
|
+
* @param {string} options.renderProtocolVersion optional render protocol version to use for this request
|
|
324
325
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
326
|
+
* @public
|
|
327
|
+
* @memberof AIAssistant
|
|
325
328
|
*/
|
|
326
|
-
|
|
329
|
+
makeAiAssistantRequest: function makeAiAssistantRequest(options) {
|
|
327
330
|
var _this6 = this;
|
|
328
|
-
return (0, _asyncToGenerator2.default)(
|
|
329
|
-
var value, content;
|
|
330
|
-
return _regenerator.default.wrap(function
|
|
331
|
-
while (1) switch (
|
|
331
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
332
|
+
var value, content, headers;
|
|
333
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
334
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
332
335
|
case 0:
|
|
333
336
|
value = options.contentValue;
|
|
334
337
|
if (!(options.contentType === 'message')) {
|
|
335
|
-
|
|
338
|
+
_context4.next = 2;
|
|
336
339
|
break;
|
|
337
340
|
}
|
|
338
|
-
|
|
341
|
+
_context4.next = 1;
|
|
339
342
|
return _this6._encryptData({
|
|
340
343
|
text: options.contentValue,
|
|
341
344
|
encryptionKeyUrl: options.encryptionKeyUrl
|
|
342
345
|
});
|
|
343
|
-
case
|
|
344
|
-
value =
|
|
345
|
-
case
|
|
346
|
+
case 1:
|
|
347
|
+
value = _context4.sent;
|
|
348
|
+
case 2:
|
|
346
349
|
content = {
|
|
347
350
|
context: {
|
|
348
351
|
resources: options.contextResources
|
|
@@ -351,25 +354,34 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
351
354
|
type: options.contentType,
|
|
352
355
|
value: value
|
|
353
356
|
};
|
|
354
|
-
if (options.
|
|
357
|
+
if (options.parameters) {
|
|
355
358
|
content.parameters = options.parameters;
|
|
356
359
|
}
|
|
357
|
-
|
|
360
|
+
headers = {};
|
|
361
|
+
if (options.renderProtocolVersion) {
|
|
362
|
+
headers['AI-Assistant-Render-Protocol'] = options.renderProtocolVersion;
|
|
363
|
+
}
|
|
364
|
+
return _context4.abrupt("return", _this6._request(_objectSpread(_objectSpread({
|
|
358
365
|
resource: options.sessionId ? "sessions/".concat(options.sessionId, "/messages") : 'sessions/messages',
|
|
359
|
-
|
|
360
|
-
params: _objectSpread({
|
|
366
|
+
params: _objectSpread(_objectSpread({
|
|
361
367
|
async: 'chunked',
|
|
362
368
|
locale: options.locale || 'en_US',
|
|
363
369
|
content: content
|
|
364
|
-
}, options.
|
|
370
|
+
}, options.entryPoint ? {
|
|
371
|
+
entryPoint: options.entryPoint
|
|
372
|
+
} : {}), options.assistant ? {
|
|
365
373
|
assistant: options.assistant
|
|
366
374
|
} : {})
|
|
367
|
-
}
|
|
368
|
-
|
|
375
|
+
}, options.requestId ? {
|
|
376
|
+
requestId: options.requestId
|
|
377
|
+
} : {}), {}, {
|
|
378
|
+
headers: headers
|
|
379
|
+
})));
|
|
380
|
+
case 3:
|
|
369
381
|
case "end":
|
|
370
|
-
return
|
|
382
|
+
return _context4.stop();
|
|
371
383
|
}
|
|
372
|
-
},
|
|
384
|
+
}, _callee4);
|
|
373
385
|
}))();
|
|
374
386
|
},
|
|
375
387
|
/**
|
|
@@ -380,10 +392,11 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
380
392
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
381
393
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
382
394
|
* @param {number} options.lastMinutes Optional number of minutes to summarize from the end of the meeting. If not included, summarizes from the start.
|
|
395
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
383
396
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
384
397
|
*/
|
|
385
398
|
summarizeMeeting: function summarizeMeeting(options) {
|
|
386
|
-
return this.
|
|
399
|
+
return this.makeAiAssistantRequest(_objectSpread(_objectSpread({}, options), {}, {
|
|
387
400
|
contentType: _constants.CONTENT_TYPES.ACTION,
|
|
388
401
|
contentValue: _constants.ACTION_TYPES.SUMMARIZE_FOR_ME,
|
|
389
402
|
contextResources: [{
|
|
@@ -404,10 +417,11 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
404
417
|
* @param {string} options.meetingSite the name.webex.com site for the meeting
|
|
405
418
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
406
419
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
420
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
407
421
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
408
422
|
*/
|
|
409
423
|
wasMyNameMentioned: function wasMyNameMentioned(options) {
|
|
410
|
-
return this.
|
|
424
|
+
return this.makeAiAssistantRequest(_objectSpread(_objectSpread({}, options), {}, {
|
|
411
425
|
contextResources: [{
|
|
412
426
|
id: options.meetingInstanceId,
|
|
413
427
|
type: _constants.CONTEXT_RESOURCE_TYPES.MEETING,
|
|
@@ -424,10 +438,11 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
424
438
|
* @param {string} options.meetingSite the name.webex.com site for the meeting
|
|
425
439
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
426
440
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
441
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
427
442
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
428
443
|
*/
|
|
429
444
|
showAllActionItems: function showAllActionItems(options) {
|
|
430
|
-
return this.
|
|
445
|
+
return this.makeAiAssistantRequest(_objectSpread(_objectSpread({}, options), {}, {
|
|
431
446
|
contextResources: [{
|
|
432
447
|
id: options.meetingInstanceId,
|
|
433
448
|
type: _constants.CONTEXT_RESOURCE_TYPES.MEETING,
|
|
@@ -444,24 +459,24 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
444
459
|
* @param {string} options.encryptionKeyUrl the encryption key URL to use for encryption
|
|
445
460
|
* @returns {Promise<string>} returns a promise that resolves with the encrypted text
|
|
446
461
|
*/
|
|
447
|
-
_encryptData: function _encryptData(
|
|
462
|
+
_encryptData: function _encryptData(_ref3) {
|
|
448
463
|
var _this7 = this;
|
|
449
|
-
return (0, _asyncToGenerator2.default)(
|
|
464
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
450
465
|
var text, encryptionKeyUrl, result;
|
|
451
|
-
return _regenerator.default.wrap(function
|
|
452
|
-
while (1) switch (
|
|
466
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
467
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
453
468
|
case 0:
|
|
454
|
-
text =
|
|
455
|
-
|
|
469
|
+
text = _ref3.text, encryptionKeyUrl = _ref3.encryptionKeyUrl;
|
|
470
|
+
_context5.next = 1;
|
|
456
471
|
return _this7.webex.internal.encryption.encryptText(encryptionKeyUrl, text);
|
|
457
|
-
case
|
|
458
|
-
result =
|
|
459
|
-
return
|
|
460
|
-
case
|
|
472
|
+
case 1:
|
|
473
|
+
result = _context5.sent;
|
|
474
|
+
return _context5.abrupt("return", result);
|
|
475
|
+
case 2:
|
|
461
476
|
case "end":
|
|
462
|
-
return
|
|
477
|
+
return _context5.stop();
|
|
463
478
|
}
|
|
464
|
-
},
|
|
479
|
+
}, _callee5);
|
|
465
480
|
}))();
|
|
466
481
|
},
|
|
467
482
|
/**
|
|
@@ -472,10 +487,11 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
472
487
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
473
488
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
474
489
|
* @param {string} options.question the question to ask about the meeting content
|
|
490
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
475
491
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
476
492
|
*/
|
|
477
493
|
askMeAnything: function askMeAnything(options) {
|
|
478
|
-
return this.
|
|
494
|
+
return this.makeAiAssistantRequest(_objectSpread(_objectSpread({}, options), {}, {
|
|
479
495
|
contextResources: [{
|
|
480
496
|
id: options.meetingInstanceId,
|
|
481
497
|
type: _constants.CONTEXT_RESOURCE_TYPES.MEETING,
|
|
@@ -485,7 +501,7 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
|
|
|
485
501
|
contentValue: options.question
|
|
486
502
|
}));
|
|
487
503
|
},
|
|
488
|
-
version: "
|
|
504
|
+
version: "3.11.0-next.10"
|
|
489
505
|
});
|
|
490
506
|
var _default = exports.default = AIAssistant;
|
|
491
507
|
//# sourceMappingURL=ai-assistant.js.map
|