@webex/internal-plugin-llm 2.59.3-next.1 → 2.59.4-next.1
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/.eslintrc.js +6 -6
- package/LICENSE +1 -1
- package/README.md +54 -54
- package/babel.config.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/llm.js +48 -48
- package/dist/llm.js.map +1 -1
- package/dist/llm.types.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +6 -6
- package/process +1 -1
- package/src/constants.ts +2 -2
- package/src/index.ts +8 -8
- package/src/llm.ts +135 -135
- package/src/llm.types.ts +9 -9
- package/test/unit/spec/llm.js +98 -98
package/.eslintrc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
root: true,
|
|
3
|
-
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
module.exports = config;
|
|
1
|
+
const config = {
|
|
2
|
+
root: true,
|
|
3
|
+
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
module.exports = config;
|
package/LICENSE
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
All contents are licensed under the Cisco EULA
|
|
1
|
+
All contents are licensed under the Cisco EULA
|
|
2
2
|
(https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)
|
package/README.md
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# @webex/internal-plugin-llm
|
|
2
|
-
|
|
3
|
-
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
-
|
|
5
|
-
> Plugin for the LLM service
|
|
6
|
-
|
|
7
|
-
This is an internal Cisco Webex plugin. As such, it does not strictly adhere to semantic versioning. Use at your own risk. If you're not working on one of our first party clients, please look at our [developer api](https://developer.webex.com/) and stick to our public plugins.
|
|
8
|
-
|
|
9
|
-
- [@webex/internal-plugin-llm](#webexinternal-plugin-llm)
|
|
10
|
-
- [Install](#install)
|
|
11
|
-
- [Usage](#usage)
|
|
12
|
-
- [Maintainers](#maintainers)
|
|
13
|
-
- [Contribute](#contribute)
|
|
14
|
-
- [License](#license)
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install --save @webex/internal-plugin-llm
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
import '@webex/internal-plugin-llm';
|
|
26
|
-
|
|
27
|
-
import WebexCore from '@webex/webex-core';
|
|
28
|
-
|
|
29
|
-
const webex = new WebexCore();
|
|
30
|
-
// locusUrl is got from meeting.locusInfo.url;
|
|
31
|
-
// datachannelUrl is got from meeting.locusInfo.info.datachannelUrl;
|
|
32
|
-
webex.internal.llm.registerAndConnect(locusUrl, datachannelUrl);
|
|
33
|
-
|
|
34
|
-
// Checks if LLM is connected
|
|
35
|
-
webex.internal.llm.isConnected();
|
|
36
|
-
|
|
37
|
-
// Disconnect LLM connection
|
|
38
|
-
webex.internal.llm.disconnectLLM();
|
|
39
|
-
|
|
40
|
-
// Get Locus URL
|
|
41
|
-
webex.internal.llm.getLocusUrl();
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Maintainers
|
|
45
|
-
|
|
46
|
-
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
47
|
-
|
|
48
|
-
## Contribute
|
|
49
|
-
|
|
50
|
-
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
51
|
-
|
|
52
|
-
## License
|
|
53
|
-
|
|
54
|
-
© 2016-2022 Cisco and/or its affiliates. All Rights Reserved.
|
|
1
|
+
# @webex/internal-plugin-llm
|
|
2
|
+
|
|
3
|
+
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
+
|
|
5
|
+
> Plugin for the LLM service
|
|
6
|
+
|
|
7
|
+
This is an internal Cisco Webex plugin. As such, it does not strictly adhere to semantic versioning. Use at your own risk. If you're not working on one of our first party clients, please look at our [developer api](https://developer.webex.com/) and stick to our public plugins.
|
|
8
|
+
|
|
9
|
+
- [@webex/internal-plugin-llm](#webexinternal-plugin-llm)
|
|
10
|
+
- [Install](#install)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [Maintainers](#maintainers)
|
|
13
|
+
- [Contribute](#contribute)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save @webex/internal-plugin-llm
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import '@webex/internal-plugin-llm';
|
|
26
|
+
|
|
27
|
+
import WebexCore from '@webex/webex-core';
|
|
28
|
+
|
|
29
|
+
const webex = new WebexCore();
|
|
30
|
+
// locusUrl is got from meeting.locusInfo.url;
|
|
31
|
+
// datachannelUrl is got from meeting.locusInfo.info.datachannelUrl;
|
|
32
|
+
webex.internal.llm.registerAndConnect(locusUrl, datachannelUrl);
|
|
33
|
+
|
|
34
|
+
// Checks if LLM is connected
|
|
35
|
+
webex.internal.llm.isConnected();
|
|
36
|
+
|
|
37
|
+
// Disconnect LLM connection
|
|
38
|
+
webex.internal.llm.disconnectLLM();
|
|
39
|
+
|
|
40
|
+
// Get Locus URL
|
|
41
|
+
webex.internal.llm.getLocusUrl();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Maintainers
|
|
45
|
+
|
|
46
|
+
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
47
|
+
|
|
48
|
+
## Contribute
|
|
49
|
+
|
|
50
|
+
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
© 2016-2022 Cisco and/or its affiliates. All Rights Reserved.
|
package/babel.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = babelConfigLegacy;
|
|
1
|
+
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = babelConfigLegacy;
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LLM","exports"],"sources":["constants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\
|
|
1
|
+
{"version":3,"names":["LLM","exports"],"sources":["constants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const LLM = 'llm';\n"],"mappings":";;;;;;;AAAA;AACO,IAAMA,GAAG,GAAG,KAAK;AAACC,OAAA,CAAAD,GAAA,GAAAA,GAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebexCore","_interopRequireWildcard","require","_llm","_getRequireWildcardCache","nodeInterop","_WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","_Object$defineProperty","_Object$getOwnPropertyDescriptor","key","Object","prototype","hasOwnProperty","call","desc","set","registerInternalPlugin","LLMChannel","config"],"sources":["index.ts"],"sourcesContent":["import * as WebexCore from '@webex/webex-core';\
|
|
1
|
+
{"version":3,"names":["WebexCore","_interopRequireWildcard","require","_llm","_getRequireWildcardCache","nodeInterop","_WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","_Object$defineProperty","_Object$getOwnPropertyDescriptor","key","Object","prototype","hasOwnProperty","call","desc","set","registerInternalPlugin","LLMChannel","config"],"sources":["index.ts"],"sourcesContent":["import * as WebexCore from '@webex/webex-core';\nimport LLMChannel, {config} from './llm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AAAA,MAAA;AAEzChB,SAAS,CAAC2B,sBAAsB,CAAC,KAAK,EAAEC,YAAU,EAAE;EAClDC,MAAM,EAANA;AACF,CAAC,CAAC"}
|
package/dist/llm.js
CHANGED
|
@@ -20,53 +20,53 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
20
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
21
|
var config = {
|
|
22
22
|
llm: {
|
|
23
|
-
/**
|
|
24
|
-
* Milliseconds between pings sent up the socket
|
|
25
|
-
* @type {number}
|
|
23
|
+
/**
|
|
24
|
+
* Milliseconds between pings sent up the socket
|
|
25
|
+
* @type {number}
|
|
26
26
|
*/
|
|
27
27
|
pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,
|
|
28
|
-
/**
|
|
29
|
-
* Milliseconds to wait for a pong before declaring the connection dead
|
|
30
|
-
* @type {number}
|
|
28
|
+
/**
|
|
29
|
+
* Milliseconds to wait for a pong before declaring the connection dead
|
|
30
|
+
* @type {number}
|
|
31
31
|
*/
|
|
32
32
|
pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,
|
|
33
|
-
/**
|
|
34
|
-
* Maximum milliseconds between connection attempts
|
|
35
|
-
* @type {Number}
|
|
33
|
+
/**
|
|
34
|
+
* Maximum milliseconds between connection attempts
|
|
35
|
+
* @type {Number}
|
|
36
36
|
*/
|
|
37
37
|
backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,
|
|
38
|
-
/**
|
|
39
|
-
* Initial milliseconds between connection attempts
|
|
40
|
-
* @type {Number}
|
|
38
|
+
/**
|
|
39
|
+
* Initial milliseconds between connection attempts
|
|
40
|
+
* @type {Number}
|
|
41
41
|
*/
|
|
42
42
|
backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,
|
|
43
|
-
/**
|
|
44
|
-
* Milliseconds to wait for a close frame before declaring the socket dead and
|
|
45
|
-
* discarding it
|
|
46
|
-
* @type {[type]}
|
|
43
|
+
/**
|
|
44
|
+
* Milliseconds to wait for a close frame before declaring the socket dead and
|
|
45
|
+
* discarding it
|
|
46
|
+
* @type {[type]}
|
|
47
47
|
*/
|
|
48
48
|
forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* LLMChannel to provide socket connections
|
|
52
|
+
/**
|
|
53
|
+
* LLMChannel to provide socket connections
|
|
54
54
|
*/
|
|
55
55
|
exports.config = config;
|
|
56
56
|
var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
57
57
|
(0, _inherits2.default)(LLMChannel, _ref);
|
|
58
58
|
var _super = _createSuper(LLMChannel);
|
|
59
|
-
/**
|
|
60
|
-
* If the LLM plugin has been registered and listening
|
|
61
|
-
* @instance
|
|
62
|
-
* @type {Boolean}
|
|
63
|
-
* @public
|
|
59
|
+
/**
|
|
60
|
+
* If the LLM plugin has been registered and listening
|
|
61
|
+
* @instance
|
|
62
|
+
* @type {Boolean}
|
|
63
|
+
* @public
|
|
64
64
|
*/
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* Initializes the LLM Plugin
|
|
68
|
-
* @constructor
|
|
69
|
-
* @public
|
|
66
|
+
/**
|
|
67
|
+
* Initializes the LLM Plugin
|
|
68
|
+
* @constructor
|
|
69
|
+
* @public
|
|
70
70
|
*/
|
|
71
71
|
function LLMChannel() {
|
|
72
72
|
var _this;
|
|
@@ -81,10 +81,10 @@ var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
|
81
81
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "webSocketUrl", void 0);
|
|
82
82
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "binding", void 0);
|
|
83
83
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "locusUrl", void 0);
|
|
84
|
-
/**
|
|
85
|
-
* Register to the websocket
|
|
86
|
-
* @param {string} llmSocketUrl
|
|
87
|
-
* @returns {Promise<void>}
|
|
84
|
+
/**
|
|
85
|
+
* Register to the websocket
|
|
86
|
+
* @param {string} llmSocketUrl
|
|
87
|
+
* @returns {Promise<void>}
|
|
88
88
|
*/
|
|
89
89
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "register", function (llmSocketUrl) {
|
|
90
90
|
return _this.request({
|
|
@@ -98,11 +98,11 @@ var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
|
98
98
|
throw error;
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
|
-
/**
|
|
102
|
-
* Register and connect to the websocket
|
|
103
|
-
* @param {string} locusUrl
|
|
104
|
-
* @param {string} datachannelUrl
|
|
105
|
-
* @returns {Promise<void>}
|
|
101
|
+
/**
|
|
102
|
+
* Register and connect to the websocket
|
|
103
|
+
* @param {string} locusUrl
|
|
104
|
+
* @param {string} datachannelUrl
|
|
105
|
+
* @returns {Promise<void>}
|
|
106
106
|
*/
|
|
107
107
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "registerAndConnect", function (locusUrl, datachannelUrl) {
|
|
108
108
|
return _this.register(datachannelUrl).then(function () {
|
|
@@ -113,30 +113,30 @@ var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
/**
|
|
117
|
-
* Tells if LLM socket is connected
|
|
118
|
-
* @returns {boolean} isRegistered
|
|
116
|
+
/**
|
|
117
|
+
* Tells if LLM socket is connected
|
|
118
|
+
* @returns {boolean} isRegistered
|
|
119
119
|
*/
|
|
120
120
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isConnected", function () {
|
|
121
121
|
return _this.registered;
|
|
122
122
|
});
|
|
123
|
-
/**
|
|
124
|
-
* Tells if LLM socket is connected
|
|
125
|
-
* @returns {bool} isRegistered
|
|
123
|
+
/**
|
|
124
|
+
* Tells if LLM socket is connected
|
|
125
|
+
* @returns {bool} isRegistered
|
|
126
126
|
*/
|
|
127
127
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getBinding", function () {
|
|
128
128
|
return _this.binding;
|
|
129
129
|
});
|
|
130
|
-
/**
|
|
131
|
-
* Get Locus URL for the connection
|
|
132
|
-
* @returns {string} locus Url
|
|
130
|
+
/**
|
|
131
|
+
* Get Locus URL for the connection
|
|
132
|
+
* @returns {string} locus Url
|
|
133
133
|
*/
|
|
134
134
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLocusUrl", function () {
|
|
135
135
|
return _this.locusUrl;
|
|
136
136
|
});
|
|
137
|
-
/**
|
|
138
|
-
* Disconnects websocket connection
|
|
139
|
-
* @returns {Promise<void>}
|
|
137
|
+
/**
|
|
138
|
+
* Disconnects websocket connection
|
|
139
|
+
* @returns {Promise<void>}
|
|
140
140
|
*/
|
|
141
141
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "disconnectLLM", function () {
|
|
142
142
|
return _this.disconnect().then(function () {
|
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_internalPluginMercury","_interopRequireDefault","require","_constants","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","config","llm","pingInterval","process","env","MERCURY_PING_INTERVAL","pongTimeout","MERCURY_PONG_TIMEOUT","backoffTimeMax","MERCURY_BACKOFF_TIME_MAX","backoffTimeReset","MERCURY_BACKOFF_TIME_RESET","forceCloseDelay","MERCURY_FORCE_CLOSE_DELAY","exports","LLMChannel","_ref","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","LLM","llmSocketUrl","request","method","url","then","res","webSocketUrl","body","binding","catch","error","logger","locusUrl","datachannelUrl","register","undefined","connect","registered","disconnect","_createClass2","Mercury"],"sources":["llm.ts"],"sourcesContent":["/* eslint-disable consistent-return */\
|
|
1
|
+
{"version":3,"names":["_internalPluginMercury","_interopRequireDefault","require","_constants","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","config","llm","pingInterval","process","env","MERCURY_PING_INTERVAL","pongTimeout","MERCURY_PONG_TIMEOUT","backoffTimeMax","MERCURY_BACKOFF_TIME_MAX","backoffTimeReset","MERCURY_BACKOFF_TIME_RESET","forceCloseDelay","MERCURY_FORCE_CLOSE_DELAY","exports","LLMChannel","_ref","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","LLM","llmSocketUrl","request","method","url","then","res","webSocketUrl","body","binding","catch","error","logger","locusUrl","datachannelUrl","register","undefined","connect","registered","disconnect","_createClass2","Mercury"],"sources":["llm.ts"],"sourcesContent":["/* eslint-disable consistent-return */\n\nimport Mercury from '@webex/internal-plugin-mercury';\n\nimport {LLM} from './constants';\n// eslint-disable-next-line no-unused-vars\nimport {ILLMChannel} from './llm.types';\n\nexport const config = {\n llm: {\n /**\n * Milliseconds between pings sent up the socket\n * @type {number}\n */\n pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,\n /**\n * Milliseconds to wait for a pong before declaring the connection dead\n * @type {number}\n */\n pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,\n /**\n * Maximum milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,\n /**\n * Initial milliseconds between connection attempts\n * @type {Number}\n */\n backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,\n /**\n * Milliseconds to wait for a close frame before declaring the socket dead and\n * discarding it\n * @type {[type]}\n */\n forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000,\n },\n};\n\n/**\n * LLMChannel to provide socket connections\n */\nexport default class LLMChannel extends (Mercury as any) implements ILLMChannel {\n namespace = LLM;\n\n /**\n * If the LLM plugin has been registered and listening\n * @instance\n * @type {Boolean}\n * @public\n */\n private registered = false;\n\n private webSocketUrl?: string;\n\n private binding?: string;\n\n private locusUrl?: string;\n\n /**\n * Initializes the LLM Plugin\n * @constructor\n * @public\n */\n constructor(...args) {\n // eslint-disable-next-line constructor-super\n super(...args);\n\n this.registered = false;\n }\n\n /**\n * Register to the websocket\n * @param {string} llmSocketUrl\n * @returns {Promise<void>}\n */\n private register = (llmSocketUrl: string): Promise<void> =>\n this.request({\n method: 'POST',\n url: llmSocketUrl,\n })\n .then((res: {body: {webSocketUrl: string; binding: string}}) => {\n this.webSocketUrl = res.body.webSocketUrl;\n this.binding = res.body.binding;\n })\n .catch((error: any) => {\n this.logger.error(`Error connecting to websocket: ${error}`);\n throw error;\n });\n\n /**\n * Register and connect to the websocket\n * @param {string} locusUrl\n * @param {string} datachannelUrl\n * @returns {Promise<void>}\n */\n public registerAndConnect = (locusUrl: string, datachannelUrl: string): Promise<void> =>\n this.register(datachannelUrl).then(() => {\n if (!locusUrl || !datachannelUrl) return undefined;\n this.locusUrl = locusUrl;\n this.connect(this.webSocketUrl).then(() => {\n this.registered = true;\n });\n });\n\n /**\n * Tells if LLM socket is connected\n * @returns {boolean} isRegistered\n */\n public isConnected = (): boolean => this.registered;\n\n /**\n * Tells if LLM socket is connected\n * @returns {bool} isRegistered\n */\n public getBinding = (): string => this.binding;\n\n /**\n * Get Locus URL for the connection\n * @returns {string} locus Url\n */\n public getLocusUrl = (): string => this.locusUrl;\n\n /**\n * Disconnects websocket connection\n * @returns {Promise<void>}\n */\n public disconnectLLM = (): Promise<void> =>\n this.disconnect().then(() => {\n this.registered = false;\n this.locusUrl = undefined;\n this.binding = undefined;\n this.webSocketUrl = undefined;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAEA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAAgC,SAAAE,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAAH,KAAA,CAAAQ,KAAA,OAAAD,SAAA,gBAAAE,2BAAA,CAAAP,OAAA,QAAAC,MAAA;AAAA,SAAAL,0BAAA,eAAAY,OAAA,qBAAAJ,kBAAA,oBAAAA,kBAAA,CAAAK,IAAA,2BAAAC,KAAA,oCAAAC,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAV,kBAAA,CAAAO,OAAA,8CAAAI,CAAA;AAIzB,IAAMC,MAAM,GAAG;EACpBC,GAAG,EAAE;IACH;AACJ;AACA;AACA;IACIC,YAAY,EAAEC,OAAO,CAACC,GAAG,CAACC,qBAAqB,IAAI,KAAK;IACxD;AACJ;AACA;AACA;IACIC,WAAW,EAAEH,OAAO,CAACC,GAAG,CAACG,oBAAoB,IAAI,KAAK;IACtD;AACJ;AACA;AACA;IACIC,cAAc,EAAEL,OAAO,CAACC,GAAG,CAACK,wBAAwB,IAAI,KAAK;IAC7D;AACJ;AACA;AACA;IACIC,gBAAgB,EAAEP,OAAO,CAACC,GAAG,CAACO,0BAA0B,IAAI,IAAI;IAChE;AACJ;AACA;AACA;AACA;IACIC,eAAe,EAAET,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;MAAA,OAAcA,KAAA,CAAKmB,OAAO;IAAA;IAE9C;AACF;AACA;AACA;IAHE,IAAAX,gBAAA,CAAA3C,OAAA,MAAA4C,uBAAA,CAAA5C,OAAA,EAAAmC,KAAA,kBAIqB;MAAA,OAAcA,KAAA,CAAKuB,QAAQ;IAAA;IAEhD;AACF;AACA;AACA;IAHE,IAAAf,gBAAA,CAAA3C,OAAA,MAAA4C,uBAAA,CAAA5C,OAAA,EAAAmC,KAAA,oBAIuB;MAAA,OACrBA,KAAA,CAAK6B,UAAU,EAAE,CAACd,IAAI,CAAC,YAAM;QAC3Bf,KAAA,CAAK4B,UAAU,GAAG,KAAK;QACvB5B,KAAA,CAAKuB,QAAQ,GAAGG,SAAS;QACzB1B,KAAA,CAAKmB,OAAO,GAAGO,SAAS;QACxB1B,KAAA,CAAKiB,YAAY,GAAGS,SAAS;MAC/B,CAAC,CAAC;IAAA;IAjEF1B,KAAA,CAAK4B,UAAU,GAAG,KAAK;IAAC,OAAA5B,KAAA;EAC1B;EAAC,WAAA8B,aAAA,CAAAjE,OAAA,EAAA+B,UAAA;AAAA,EA3BsCmC,8BAAO;AAAApC,OAAA,CAAA9B,OAAA,GAAA+B,UAAA"}
|
package/dist/llm.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["llm.types.ts"],"sourcesContent":["interface ILLMChannel {\
|
|
1
|
+
{"version":3,"names":[],"sources":["llm.types.ts"],"sourcesContent":["interface ILLMChannel {\n registerAndConnect: (locusUrl: string, datachannelUrl: string) => Promise<void>;\n isConnected: () => boolean;\n getBinding: () => string;\n getLocusUrl: () => string;\n disconnectLLM: () => Promise<void>;\n}\n// eslint-disable-next-line import/prefer-default-export\nexport type {ILLMChannel};\n"],"mappings":""}
|
package/jest.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const config = require('@webex/jest-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = config;
|
|
1
|
+
const config = require('@webex/jest-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"node": ">=14"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webex/internal-plugin-mercury": "^2.59.
|
|
16
|
+
"@webex/internal-plugin-mercury": "^2.59.4-next.1"
|
|
17
17
|
},
|
|
18
18
|
"browserify": {
|
|
19
19
|
"transform": [
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@webex/eslint-config-legacy": "^0.0.0",
|
|
28
28
|
"@webex/jest-config-legacy": "^0.0.0",
|
|
29
29
|
"@webex/legacy-tools": "^0.0.0",
|
|
30
|
-
"@webex/test-helper-chai": "^2.59.
|
|
31
|
-
"@webex/test-helper-mocha": "^2.59.
|
|
32
|
-
"@webex/test-helper-mock-webex": "^2.59.
|
|
33
|
-
"@webex/test-helper-test-users": "^2.59.
|
|
30
|
+
"@webex/test-helper-chai": "^2.59.4-next.1",
|
|
31
|
+
"@webex/test-helper-mocha": "^2.59.4-next.1",
|
|
32
|
+
"@webex/test-helper-mock-webex": "^2.59.4-next.1",
|
|
33
|
+
"@webex/test-helper-test-users": "^2.59.4-next.1",
|
|
34
34
|
"eslint": "^8.24.0",
|
|
35
35
|
"prettier": "^2.7.1",
|
|
36
36
|
"sinon": "^9.2.4"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"test:style": "eslint ./src/**/*.*",
|
|
46
46
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
47
47
|
},
|
|
48
|
-
"version": "2.59.
|
|
48
|
+
"version": "2.59.4-next.1"
|
|
49
49
|
}
|
package/process
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = {browser: true};
|
|
1
|
+
module.exports = {browser: true};
|
package/src/constants.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
-
export const LLM = 'llm';
|
|
1
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
+
export const LLM = 'llm';
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as WebexCore from '@webex/webex-core';
|
|
2
|
-
import LLMChannel, {config} from './llm';
|
|
3
|
-
|
|
4
|
-
WebexCore.registerInternalPlugin('llm', LLMChannel, {
|
|
5
|
-
config,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export {default} from './llm';
|
|
1
|
+
import * as WebexCore from '@webex/webex-core';
|
|
2
|
+
import LLMChannel, {config} from './llm';
|
|
3
|
+
|
|
4
|
+
WebexCore.registerInternalPlugin('llm', LLMChannel, {
|
|
5
|
+
config,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {default} from './llm';
|
package/src/llm.ts
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
|
-
|
|
3
|
-
import Mercury from '@webex/internal-plugin-mercury';
|
|
4
|
-
|
|
5
|
-
import {LLM} from './constants';
|
|
6
|
-
// eslint-disable-next-line no-unused-vars
|
|
7
|
-
import {ILLMChannel} from './llm.types';
|
|
8
|
-
|
|
9
|
-
export const config = {
|
|
10
|
-
llm: {
|
|
11
|
-
/**
|
|
12
|
-
* Milliseconds between pings sent up the socket
|
|
13
|
-
* @type {number}
|
|
14
|
-
*/
|
|
15
|
-
pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,
|
|
16
|
-
/**
|
|
17
|
-
* Milliseconds to wait for a pong before declaring the connection dead
|
|
18
|
-
* @type {number}
|
|
19
|
-
*/
|
|
20
|
-
pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,
|
|
21
|
-
/**
|
|
22
|
-
* Maximum milliseconds between connection attempts
|
|
23
|
-
* @type {Number}
|
|
24
|
-
*/
|
|
25
|
-
backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,
|
|
26
|
-
/**
|
|
27
|
-
* Initial milliseconds between connection attempts
|
|
28
|
-
* @type {Number}
|
|
29
|
-
*/
|
|
30
|
-
backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,
|
|
31
|
-
/**
|
|
32
|
-
* Milliseconds to wait for a close frame before declaring the socket dead and
|
|
33
|
-
* discarding it
|
|
34
|
-
* @type {[type]}
|
|
35
|
-
*/
|
|
36
|
-
forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* LLMChannel to provide socket connections
|
|
42
|
-
*/
|
|
43
|
-
export default class LLMChannel extends (Mercury as any) implements ILLMChannel {
|
|
44
|
-
namespace = LLM;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* If the LLM plugin has been registered and listening
|
|
48
|
-
* @instance
|
|
49
|
-
* @type {Boolean}
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
private registered = false;
|
|
53
|
-
|
|
54
|
-
private webSocketUrl?: string;
|
|
55
|
-
|
|
56
|
-
private binding?: string;
|
|
57
|
-
|
|
58
|
-
private locusUrl?: string;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Initializes the LLM Plugin
|
|
62
|
-
* @constructor
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
constructor(...args) {
|
|
66
|
-
// eslint-disable-next-line constructor-super
|
|
67
|
-
super(...args);
|
|
68
|
-
|
|
69
|
-
this.registered = false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Register to the websocket
|
|
74
|
-
* @param {string} llmSocketUrl
|
|
75
|
-
* @returns {Promise<void>}
|
|
76
|
-
*/
|
|
77
|
-
private register = (llmSocketUrl: string): Promise<void> =>
|
|
78
|
-
this.request({
|
|
79
|
-
method: 'POST',
|
|
80
|
-
url: llmSocketUrl,
|
|
81
|
-
})
|
|
82
|
-
.then((res: {body: {webSocketUrl: string; binding: string}}) => {
|
|
83
|
-
this.webSocketUrl = res.body.webSocketUrl;
|
|
84
|
-
this.binding = res.body.binding;
|
|
85
|
-
})
|
|
86
|
-
.catch((error: any) => {
|
|
87
|
-
this.logger.error(`Error connecting to websocket: ${error}`);
|
|
88
|
-
throw error;
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Register and connect to the websocket
|
|
93
|
-
* @param {string} locusUrl
|
|
94
|
-
* @param {string} datachannelUrl
|
|
95
|
-
* @returns {Promise<void>}
|
|
96
|
-
*/
|
|
97
|
-
public registerAndConnect = (locusUrl: string, datachannelUrl: string): Promise<void> =>
|
|
98
|
-
this.register(datachannelUrl).then(() => {
|
|
99
|
-
if (!locusUrl || !datachannelUrl) return undefined;
|
|
100
|
-
this.locusUrl = locusUrl;
|
|
101
|
-
this.connect(this.webSocketUrl).then(() => {
|
|
102
|
-
this.registered = true;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Tells if LLM socket is connected
|
|
108
|
-
* @returns {boolean} isRegistered
|
|
109
|
-
*/
|
|
110
|
-
public isConnected = (): boolean => this.registered;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Tells if LLM socket is connected
|
|
114
|
-
* @returns {bool} isRegistered
|
|
115
|
-
*/
|
|
116
|
-
public getBinding = (): string => this.binding;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get Locus URL for the connection
|
|
120
|
-
* @returns {string} locus Url
|
|
121
|
-
*/
|
|
122
|
-
public getLocusUrl = (): string => this.locusUrl;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Disconnects websocket connection
|
|
126
|
-
* @returns {Promise<void>}
|
|
127
|
-
*/
|
|
128
|
-
public disconnectLLM = (): Promise<void> =>
|
|
129
|
-
this.disconnect().then(() => {
|
|
130
|
-
this.registered = false;
|
|
131
|
-
this.locusUrl = undefined;
|
|
132
|
-
this.binding = undefined;
|
|
133
|
-
this.webSocketUrl = undefined;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
1
|
+
/* eslint-disable consistent-return */
|
|
2
|
+
|
|
3
|
+
import Mercury from '@webex/internal-plugin-mercury';
|
|
4
|
+
|
|
5
|
+
import {LLM} from './constants';
|
|
6
|
+
// eslint-disable-next-line no-unused-vars
|
|
7
|
+
import {ILLMChannel} from './llm.types';
|
|
8
|
+
|
|
9
|
+
export const config = {
|
|
10
|
+
llm: {
|
|
11
|
+
/**
|
|
12
|
+
* Milliseconds between pings sent up the socket
|
|
13
|
+
* @type {number}
|
|
14
|
+
*/
|
|
15
|
+
pingInterval: process.env.MERCURY_PING_INTERVAL || 15000,
|
|
16
|
+
/**
|
|
17
|
+
* Milliseconds to wait for a pong before declaring the connection dead
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
pongTimeout: process.env.MERCURY_PONG_TIMEOUT || 14000,
|
|
21
|
+
/**
|
|
22
|
+
* Maximum milliseconds between connection attempts
|
|
23
|
+
* @type {Number}
|
|
24
|
+
*/
|
|
25
|
+
backoffTimeMax: process.env.MERCURY_BACKOFF_TIME_MAX || 32000,
|
|
26
|
+
/**
|
|
27
|
+
* Initial milliseconds between connection attempts
|
|
28
|
+
* @type {Number}
|
|
29
|
+
*/
|
|
30
|
+
backoffTimeReset: process.env.MERCURY_BACKOFF_TIME_RESET || 1000,
|
|
31
|
+
/**
|
|
32
|
+
* Milliseconds to wait for a close frame before declaring the socket dead and
|
|
33
|
+
* discarding it
|
|
34
|
+
* @type {[type]}
|
|
35
|
+
*/
|
|
36
|
+
forceCloseDelay: process.env.MERCURY_FORCE_CLOSE_DELAY || 2000,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* LLMChannel to provide socket connections
|
|
42
|
+
*/
|
|
43
|
+
export default class LLMChannel extends (Mercury as any) implements ILLMChannel {
|
|
44
|
+
namespace = LLM;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If the LLM plugin has been registered and listening
|
|
48
|
+
* @instance
|
|
49
|
+
* @type {Boolean}
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
private registered = false;
|
|
53
|
+
|
|
54
|
+
private webSocketUrl?: string;
|
|
55
|
+
|
|
56
|
+
private binding?: string;
|
|
57
|
+
|
|
58
|
+
private locusUrl?: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Initializes the LLM Plugin
|
|
62
|
+
* @constructor
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
constructor(...args) {
|
|
66
|
+
// eslint-disable-next-line constructor-super
|
|
67
|
+
super(...args);
|
|
68
|
+
|
|
69
|
+
this.registered = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Register to the websocket
|
|
74
|
+
* @param {string} llmSocketUrl
|
|
75
|
+
* @returns {Promise<void>}
|
|
76
|
+
*/
|
|
77
|
+
private register = (llmSocketUrl: string): Promise<void> =>
|
|
78
|
+
this.request({
|
|
79
|
+
method: 'POST',
|
|
80
|
+
url: llmSocketUrl,
|
|
81
|
+
})
|
|
82
|
+
.then((res: {body: {webSocketUrl: string; binding: string}}) => {
|
|
83
|
+
this.webSocketUrl = res.body.webSocketUrl;
|
|
84
|
+
this.binding = res.body.binding;
|
|
85
|
+
})
|
|
86
|
+
.catch((error: any) => {
|
|
87
|
+
this.logger.error(`Error connecting to websocket: ${error}`);
|
|
88
|
+
throw error;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Register and connect to the websocket
|
|
93
|
+
* @param {string} locusUrl
|
|
94
|
+
* @param {string} datachannelUrl
|
|
95
|
+
* @returns {Promise<void>}
|
|
96
|
+
*/
|
|
97
|
+
public registerAndConnect = (locusUrl: string, datachannelUrl: string): Promise<void> =>
|
|
98
|
+
this.register(datachannelUrl).then(() => {
|
|
99
|
+
if (!locusUrl || !datachannelUrl) return undefined;
|
|
100
|
+
this.locusUrl = locusUrl;
|
|
101
|
+
this.connect(this.webSocketUrl).then(() => {
|
|
102
|
+
this.registered = true;
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Tells if LLM socket is connected
|
|
108
|
+
* @returns {boolean} isRegistered
|
|
109
|
+
*/
|
|
110
|
+
public isConnected = (): boolean => this.registered;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Tells if LLM socket is connected
|
|
114
|
+
* @returns {bool} isRegistered
|
|
115
|
+
*/
|
|
116
|
+
public getBinding = (): string => this.binding;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get Locus URL for the connection
|
|
120
|
+
* @returns {string} locus Url
|
|
121
|
+
*/
|
|
122
|
+
public getLocusUrl = (): string => this.locusUrl;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Disconnects websocket connection
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
*/
|
|
128
|
+
public disconnectLLM = (): Promise<void> =>
|
|
129
|
+
this.disconnect().then(() => {
|
|
130
|
+
this.registered = false;
|
|
131
|
+
this.locusUrl = undefined;
|
|
132
|
+
this.binding = undefined;
|
|
133
|
+
this.webSocketUrl = undefined;
|
|
134
|
+
});
|
|
135
|
+
}
|
package/src/llm.types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
interface ILLMChannel {
|
|
2
|
-
registerAndConnect: (locusUrl: string, datachannelUrl: string) => Promise<void>;
|
|
3
|
-
isConnected: () => boolean;
|
|
4
|
-
getBinding: () => string;
|
|
5
|
-
getLocusUrl: () => string;
|
|
6
|
-
disconnectLLM: () => Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
9
|
-
export type {ILLMChannel};
|
|
1
|
+
interface ILLMChannel {
|
|
2
|
+
registerAndConnect: (locusUrl: string, datachannelUrl: string) => Promise<void>;
|
|
3
|
+
isConnected: () => boolean;
|
|
4
|
+
getBinding: () => string;
|
|
5
|
+
getLocusUrl: () => string;
|
|
6
|
+
disconnectLLM: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
9
|
+
export type {ILLMChannel};
|
package/test/unit/spec/llm.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import MockWebex from '@webex/test-helper-mock-webex';
|
|
2
|
-
import {assert} from '@webex/test-helper-chai';
|
|
3
|
-
import sinon from 'sinon';
|
|
4
|
-
import Mercury from '@webex/internal-plugin-mercury';
|
|
5
|
-
import LLMService from '@webex/internal-plugin-llm';
|
|
6
|
-
|
|
7
|
-
describe('plugin-llm', () => {
|
|
8
|
-
const locusUrl = 'locusUrl';
|
|
9
|
-
const datachannelUrl = 'datachannelUrl';
|
|
10
|
-
|
|
11
|
-
describe('llm', () => {
|
|
12
|
-
let webex, llmService;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
webex = new MockWebex({
|
|
16
|
-
children: {
|
|
17
|
-
mercury: Mercury,
|
|
18
|
-
llm: LLMService,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
llmService = webex.internal.llm;
|
|
23
|
-
llmService.connect = sinon.stub().resolves(true);
|
|
24
|
-
llmService.disconnect = sinon.stub().resolves(true);
|
|
25
|
-
llmService.request = sinon.stub().resolves({
|
|
26
|
-
headers: {},
|
|
27
|
-
body: {
|
|
28
|
-
binding: 'binding',
|
|
29
|
-
webSocketUrl: 'url',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('#registerAndConnect', () => {
|
|
35
|
-
it('registers connection', async () => {
|
|
36
|
-
llmService.register = sinon.stub().resolves({
|
|
37
|
-
body: {
|
|
38
|
-
binding: 'binding',
|
|
39
|
-
webSocketUrl: 'url',
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
assert.equal(llmService.isConnected(), false);
|
|
43
|
-
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
44
|
-
assert.equal(llmService.isConnected(), true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("doesn't registers connection for invalid input", async () => {
|
|
48
|
-
llmService.register = sinon.stub().resolves({
|
|
49
|
-
body: {
|
|
50
|
-
binding: 'binding',
|
|
51
|
-
webSocketUrl: 'url',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
await llmService.registerAndConnect();
|
|
55
|
-
assert.equal(llmService.isConnected(), false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('#register', () => {
|
|
60
|
-
it('registers connection', async () => {
|
|
61
|
-
await llmService.register(datachannelUrl);
|
|
62
|
-
|
|
63
|
-
sinon.assert.calledOnceWithExactly(
|
|
64
|
-
llmService.request,
|
|
65
|
-
sinon.match({
|
|
66
|
-
method: 'POST',
|
|
67
|
-
url: `${datachannelUrl}`,
|
|
68
|
-
})
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
assert.equal(llmService.getBinding(), 'binding');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe('#getLocusUrl', () => {
|
|
76
|
-
it('gets LocusUrl', async () => {
|
|
77
|
-
llmService.register = sinon.stub().resolves({
|
|
78
|
-
body: {
|
|
79
|
-
binding: 'binding',
|
|
80
|
-
webSocketUrl: 'url',
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
84
|
-
assert.equal(llmService.getLocusUrl(), locusUrl);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('#disconnect', () => {
|
|
89
|
-
it('disconnects mercury', async () => {
|
|
90
|
-
await llmService.disconnect();
|
|
91
|
-
sinon.assert.calledOnce(llmService.disconnect);
|
|
92
|
-
assert.equal(llmService.isConnected(), false);
|
|
93
|
-
assert.equal(llmService.getLocusUrl(), undefined);
|
|
94
|
-
assert.equal(llmService.getBinding(), undefined);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
1
|
+
import MockWebex from '@webex/test-helper-mock-webex';
|
|
2
|
+
import {assert} from '@webex/test-helper-chai';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import Mercury from '@webex/internal-plugin-mercury';
|
|
5
|
+
import LLMService from '@webex/internal-plugin-llm';
|
|
6
|
+
|
|
7
|
+
describe('plugin-llm', () => {
|
|
8
|
+
const locusUrl = 'locusUrl';
|
|
9
|
+
const datachannelUrl = 'datachannelUrl';
|
|
10
|
+
|
|
11
|
+
describe('llm', () => {
|
|
12
|
+
let webex, llmService;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
webex = new MockWebex({
|
|
16
|
+
children: {
|
|
17
|
+
mercury: Mercury,
|
|
18
|
+
llm: LLMService,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
llmService = webex.internal.llm;
|
|
23
|
+
llmService.connect = sinon.stub().resolves(true);
|
|
24
|
+
llmService.disconnect = sinon.stub().resolves(true);
|
|
25
|
+
llmService.request = sinon.stub().resolves({
|
|
26
|
+
headers: {},
|
|
27
|
+
body: {
|
|
28
|
+
binding: 'binding',
|
|
29
|
+
webSocketUrl: 'url',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('#registerAndConnect', () => {
|
|
35
|
+
it('registers connection', async () => {
|
|
36
|
+
llmService.register = sinon.stub().resolves({
|
|
37
|
+
body: {
|
|
38
|
+
binding: 'binding',
|
|
39
|
+
webSocketUrl: 'url',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
assert.equal(llmService.isConnected(), false);
|
|
43
|
+
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
44
|
+
assert.equal(llmService.isConnected(), true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("doesn't registers connection for invalid input", async () => {
|
|
48
|
+
llmService.register = sinon.stub().resolves({
|
|
49
|
+
body: {
|
|
50
|
+
binding: 'binding',
|
|
51
|
+
webSocketUrl: 'url',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
await llmService.registerAndConnect();
|
|
55
|
+
assert.equal(llmService.isConnected(), false);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('#register', () => {
|
|
60
|
+
it('registers connection', async () => {
|
|
61
|
+
await llmService.register(datachannelUrl);
|
|
62
|
+
|
|
63
|
+
sinon.assert.calledOnceWithExactly(
|
|
64
|
+
llmService.request,
|
|
65
|
+
sinon.match({
|
|
66
|
+
method: 'POST',
|
|
67
|
+
url: `${datachannelUrl}`,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
assert.equal(llmService.getBinding(), 'binding');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('#getLocusUrl', () => {
|
|
76
|
+
it('gets LocusUrl', async () => {
|
|
77
|
+
llmService.register = sinon.stub().resolves({
|
|
78
|
+
body: {
|
|
79
|
+
binding: 'binding',
|
|
80
|
+
webSocketUrl: 'url',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
84
|
+
assert.equal(llmService.getLocusUrl(), locusUrl);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('#disconnect', () => {
|
|
89
|
+
it('disconnects mercury', async () => {
|
|
90
|
+
await llmService.disconnect();
|
|
91
|
+
sinon.assert.calledOnce(llmService.disconnect);
|
|
92
|
+
assert.equal(llmService.isConnected(), false);
|
|
93
|
+
assert.equal(llmService.getLocusUrl(), undefined);
|
|
94
|
+
assert.equal(llmService.getBinding(), undefined);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|