@webex/internal-plugin-llm 2.31.0 → 2.31.2
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/llm.js +11 -6
- package/dist/llm.js.map +1 -1
- package/package.json +5 -5
- package/src/llm.ts +39 -32
- package/test/unit/spec/llm.js +19 -17
package/dist/llm.js
CHANGED
|
@@ -82,11 +82,11 @@ var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
|
82
82
|
var _super = _createSuper(LLMChannel);
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
* If the LLM plugin has been registered and listening
|
|
86
|
+
* @instance
|
|
87
|
+
* @type {Boolean}
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Initializes the LLM Plugin
|
|
@@ -142,7 +142,12 @@ var LLMChannel = /*#__PURE__*/function (_ref) {
|
|
|
142
142
|
return _this.locusUrl;
|
|
143
143
|
});
|
|
144
144
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "disconnectLLM", function () {
|
|
145
|
-
return _this.disconnect()
|
|
145
|
+
return _this.disconnect().then(function () {
|
|
146
|
+
_this.registered = false;
|
|
147
|
+
_this.locusUrl = undefined;
|
|
148
|
+
_this.binding = undefined;
|
|
149
|
+
_this.webSocketUrl = undefined;
|
|
150
|
+
});
|
|
146
151
|
});
|
|
147
152
|
_this.registered = false;
|
|
148
153
|
return _this;
|
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["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","LLMChannel","args","LLM","llmSocketUrl","request","method","url","then","res","webSocketUrl","body","binding","catch","error","LoggerProxy","logger","locusUrl","datachannelUrl","register","undefined","connect","registered","disconnect","Mercury"],"sources":["llm.ts"],"sourcesContent":["import Mercury from '@webex/internal-plugin-mercury';\nimport {LoggerProxy} from '@webex/plugin-meetings';\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
|
|
1
|
+
{"version":3,"names":["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","LLMChannel","args","LLM","llmSocketUrl","request","method","url","then","res","webSocketUrl","body","binding","catch","error","LoggerProxy","logger","locusUrl","datachannelUrl","register","undefined","connect","registered","disconnect","Mercury"],"sources":["llm.ts"],"sourcesContent":["import Mercury from '@webex/internal-plugin-mercury';\nimport {LoggerProxy} from '@webex/plugin-meetings';\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: boolean = 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 LoggerProxy.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;AAIO,IAAMA,MAAM,GAAG;EACpBC,GAAG,EAAE;IACH;AACJ;AACA;AACA;IACIC,YAAY,EAAEC,OAAO,CAACC,GAAR,CAAYC,qBAAZ,IAAqC,KALhD;;IAMH;AACJ;AACA;AACA;IACIC,WAAW,EAAEH,OAAO,CAACC,GAAR,CAAYG,oBAAZ,IAAoC,KAV9C;;IAWH;AACJ;AACA;AACA;IACIC,cAAc,EAAEL,OAAO,CAACC,GAAR,CAAYK,wBAAZ,IAAwC,KAfrD;;IAgBH;AACJ;AACA;AACA;IACIC,gBAAgB,EAAEP,OAAO,CAACC,GAAR,CAAYO,0BAAZ,IAA0C,IApBzD;;IAqBH;AACJ;AACA;AACA;AACA;IACIC,eAAe,EAAET,OAAO,CAACC,GAAR,CAAYS,yBAAZ,IAAyC;EA1BvD;AADe,CAAf;AA+BP;AACA;AACA;;;;IACqBC,U;;;;;EAGnB;AACF;AACA;AACA;AACA;AACA;;EASE;AACF;AACA;AACA;AACA;EACE,sBAAqB;IAAA;;IAAA;;IAAA,kCAANC,IAAM;MAANA,IAAM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SAApB;MACD,CALD,CADqB;IAAA,CA/DF;IAInB,MAAKE,UAAL,GAAkB,KAAlB;IAJmB;EAKpB;EAED;AACF;AACA;AACA;AACA;;;;EAjCyCE,8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-llm",
|
|
3
|
-
"version": "2.31.
|
|
3
|
+
"version": "2.31.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"node": ">=14"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webex/internal-plugin-llm": "2.31.
|
|
14
|
-
"@webex/internal-plugin-mercury": "2.31.
|
|
13
|
+
"@webex/internal-plugin-llm": "2.31.2",
|
|
14
|
+
"@webex/internal-plugin-mercury": "2.31.2"
|
|
15
15
|
},
|
|
16
16
|
"browserify": {
|
|
17
17
|
"transform": [
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@webex/test-helper-chai": "2.31.
|
|
24
|
-
"@webex/test-helper-mock-webex": "2.31.
|
|
23
|
+
"@webex/test-helper-chai": "2.31.2",
|
|
24
|
+
"@webex/test-helper-mock-webex": "2.31.2",
|
|
25
25
|
"sinon": "^9.2.4"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/llm.ts
CHANGED
|
@@ -43,19 +43,18 @@ export default class LLMChannel extends (Mercury as any) implements ILLMChannel
|
|
|
43
43
|
namespace = LLM;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
private registered:boolean = false;
|
|
52
|
-
|
|
53
|
-
private webSocketUrl: string;
|
|
46
|
+
* If the LLM plugin has been registered and listening
|
|
47
|
+
* @instance
|
|
48
|
+
* @type {Boolean}
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
private registered: boolean = false;
|
|
54
52
|
|
|
55
|
-
private
|
|
53
|
+
private webSocketUrl?: string;
|
|
56
54
|
|
|
57
|
-
private
|
|
55
|
+
private binding?: string;
|
|
58
56
|
|
|
57
|
+
private locusUrl?: string;
|
|
59
58
|
|
|
60
59
|
/**
|
|
61
60
|
* Initializes the LLM Plugin
|
|
@@ -66,7 +65,6 @@ export default class LLMChannel extends (Mercury as any) implements ILLMChannel
|
|
|
66
65
|
// eslint-disable-next-line constructor-super
|
|
67
66
|
super(...args);
|
|
68
67
|
|
|
69
|
-
|
|
70
68
|
this.registered = false;
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -75,16 +73,19 @@ export default class LLMChannel extends (Mercury as any) implements ILLMChannel
|
|
|
75
73
|
* @param {string} llmSocketUrl
|
|
76
74
|
* @returns {Promise<void>}
|
|
77
75
|
*/
|
|
78
|
-
private register = (llmSocketUrl:string):Promise<void> =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
private register = (llmSocketUrl: string): Promise<void> =>
|
|
77
|
+
this.request({
|
|
78
|
+
method: 'POST',
|
|
79
|
+
url: llmSocketUrl,
|
|
80
|
+
})
|
|
81
|
+
.then((res: {body: {webSocketUrl: string; binding: string}}) => {
|
|
82
|
+
this.webSocketUrl = res.body.webSocketUrl;
|
|
83
|
+
this.binding = res.body.binding;
|
|
84
|
+
})
|
|
85
|
+
.catch((error: any) => {
|
|
86
|
+
LoggerProxy.logger.error(`Error connecting to websocket: ${error}`);
|
|
87
|
+
throw error;
|
|
88
|
+
});
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
91
|
* Register and connect to the websocket
|
|
@@ -92,36 +93,42 @@ export default class LLMChannel extends (Mercury as any) implements ILLMChannel
|
|
|
92
93
|
* @param {string} datachannelUrl
|
|
93
94
|
* @returns {Promise<void>}
|
|
94
95
|
*/
|
|
95
|
-
public registerAndConnect = (locusUrl:string, datachannelUrl:string):Promise<void> =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.
|
|
96
|
+
public registerAndConnect = (locusUrl: string, datachannelUrl: string): Promise<void> =>
|
|
97
|
+
this.register(datachannelUrl).then(() => {
|
|
98
|
+
if (!locusUrl || !datachannelUrl) return undefined;
|
|
99
|
+
this.locusUrl = locusUrl;
|
|
100
|
+
this.connect(this.webSocketUrl).then(() => {
|
|
101
|
+
this.registered = true;
|
|
102
|
+
});
|
|
100
103
|
});
|
|
101
|
-
});
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* Tells if LLM socket is connected
|
|
105
107
|
* @returns {boolean} isRegistered
|
|
106
108
|
*/
|
|
107
|
-
public isConnected = ():boolean => this.registered;
|
|
109
|
+
public isConnected = (): boolean => this.registered;
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
112
|
* Tells if LLM socket is connected
|
|
111
113
|
* @returns {bool} isRegistered
|
|
112
114
|
*/
|
|
113
|
-
public getBinding = ():string => this.binding;
|
|
115
|
+
public getBinding = (): string => this.binding;
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
118
|
* Get Locus URL for the connection
|
|
117
119
|
* @returns {string} locus Url
|
|
118
120
|
*/
|
|
119
|
-
public getLocusUrl = ():string => this.locusUrl;
|
|
121
|
+
public getLocusUrl = (): string => this.locusUrl;
|
|
120
122
|
|
|
121
123
|
/**
|
|
122
124
|
* Disconnects websocket connection
|
|
123
125
|
* @returns {Promise<void>}
|
|
124
126
|
*/
|
|
125
|
-
public disconnectLLM = (): Promise<void> =>
|
|
127
|
+
public disconnectLLM = (): Promise<void> =>
|
|
128
|
+
this.disconnect().then(() => {
|
|
129
|
+
this.registered = false;
|
|
130
|
+
this.locusUrl = undefined;
|
|
131
|
+
this.binding = undefined;
|
|
132
|
+
this.webSocketUrl = undefined;
|
|
133
|
+
});
|
|
126
134
|
}
|
|
127
|
-
|
package/test/unit/spec/llm.js
CHANGED
|
@@ -2,10 +2,8 @@ import MockWebex from '@webex/test-helper-mock-webex';
|
|
|
2
2
|
import {assert} from '@webex/test-helper-chai';
|
|
3
3
|
import sinon from 'sinon';
|
|
4
4
|
import Mercury from '@webex/internal-plugin-mercury';
|
|
5
|
-
|
|
6
5
|
import LLMService from '@webex/internal-plugin-llm';
|
|
7
6
|
|
|
8
|
-
|
|
9
7
|
describe('plugin-llm', () => {
|
|
10
8
|
const locusUrl = 'locusUrl';
|
|
11
9
|
const datachannelUrl = 'datachannelUrl';
|
|
@@ -28,31 +26,30 @@ describe('plugin-llm', () => {
|
|
|
28
26
|
headers: {},
|
|
29
27
|
body: {
|
|
30
28
|
binding: 'binding',
|
|
31
|
-
webSocketUrl: 'url'
|
|
32
|
-
}
|
|
29
|
+
webSocketUrl: 'url',
|
|
30
|
+
},
|
|
33
31
|
});
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
37
34
|
describe('#registerAndConnect', () => {
|
|
38
35
|
it('registers connection', async () => {
|
|
39
36
|
llmService.register = sinon.stub().resolves({
|
|
40
37
|
body: {
|
|
41
38
|
binding: 'binding',
|
|
42
|
-
webSocketUrl: 'url'
|
|
43
|
-
}
|
|
39
|
+
webSocketUrl: 'url',
|
|
40
|
+
},
|
|
44
41
|
});
|
|
45
42
|
assert.equal(llmService.isConnected(), false);
|
|
46
43
|
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
47
44
|
assert.equal(llmService.isConnected(), true);
|
|
48
45
|
});
|
|
49
46
|
|
|
50
|
-
it(
|
|
47
|
+
it("doesn't registers connection for invalid input", async () => {
|
|
51
48
|
llmService.register = sinon.stub().resolves({
|
|
52
49
|
body: {
|
|
53
50
|
binding: 'binding',
|
|
54
|
-
webSocketUrl: 'url'
|
|
55
|
-
}
|
|
51
|
+
webSocketUrl: 'url',
|
|
52
|
+
},
|
|
56
53
|
});
|
|
57
54
|
await llmService.registerAndConnect();
|
|
58
55
|
assert.equal(llmService.isConnected(), false);
|
|
@@ -63,11 +60,13 @@ describe('plugin-llm', () => {
|
|
|
63
60
|
it('registers connection', async () => {
|
|
64
61
|
await llmService.register(datachannelUrl);
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
sinon.assert.calledOnceWithExactly(
|
|
64
|
+
llmService.request,
|
|
65
|
+
sinon.match({
|
|
66
|
+
method: 'POST',
|
|
67
|
+
url: `${datachannelUrl}`,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
71
70
|
|
|
72
71
|
assert.equal(llmService.getBinding(), 'binding');
|
|
73
72
|
});
|
|
@@ -78,8 +77,8 @@ describe('plugin-llm', () => {
|
|
|
78
77
|
llmService.register = sinon.stub().resolves({
|
|
79
78
|
body: {
|
|
80
79
|
binding: 'binding',
|
|
81
|
-
webSocketUrl: 'url'
|
|
82
|
-
}
|
|
80
|
+
webSocketUrl: 'url',
|
|
81
|
+
},
|
|
83
82
|
});
|
|
84
83
|
await llmService.registerAndConnect(locusUrl, datachannelUrl);
|
|
85
84
|
assert.equal(llmService.getLocusUrl(), locusUrl);
|
|
@@ -90,6 +89,9 @@ describe('plugin-llm', () => {
|
|
|
90
89
|
it('disconnects mercury', async () => {
|
|
91
90
|
await llmService.disconnect();
|
|
92
91
|
sinon.assert.calledOnce(llmService.disconnect);
|
|
92
|
+
assert.equal(llmService.isConnected(), false);
|
|
93
|
+
assert.equal(llmService.getLocusUrl(), undefined);
|
|
94
|
+
assert.equal(llmService.getBinding(), undefined);
|
|
93
95
|
});
|
|
94
96
|
});
|
|
95
97
|
});
|