@onecx/integration-interface 7.13.1 → 7.14.0
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/package.json +2 -2
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -1
- package/src/lib/gatherers/ai-completion/v1/ai-completion.gatherer.d.ts +28 -0
- package/src/lib/gatherers/ai-completion/v1/ai-completion.gatherer.js +34 -0
- package/src/lib/gatherers/ai-completion/v1/ai-completion.gatherer.js.map +1 -0
- package/src/lib/gatherers/ai-completion/v1/ai-completion.model.d.ts +12 -0
- package/src/lib/gatherers/ai-completion/v1/ai-completion.model.js +3 -0
- package/src/lib/gatherers/ai-completion/v1/ai-completion.model.js.map +1 -0
- package/src/lib/services/ai-completion.service.d.ts +14 -0
- package/src/lib/services/ai-completion.service.js +31 -0
- package/src/lib/services/ai-completion.service.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onecx/integration-interface",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"tslib": "^2.6.3",
|
|
11
11
|
"rxjs": "^7.8.1",
|
|
12
|
-
"@onecx/accelerator": "7.
|
|
12
|
+
"@onecx/accelerator": "7.14.0"
|
|
13
13
|
},
|
|
14
14
|
"type": "commonjs",
|
|
15
15
|
"main": "./src/index.js",
|
package/src/index.d.ts
CHANGED
|
@@ -51,3 +51,6 @@ export * from './lib/topics/notification/v1/notification.topic';
|
|
|
51
51
|
export * from './lib/services/notification.service';
|
|
52
52
|
export * from './lib/gatherers/ai-context/v1/ai-context.model';
|
|
53
53
|
export * from './lib/gatherers/ai-context/v1/ai-context.gatherer';
|
|
54
|
+
export * from './lib/gatherers/ai-completion/v1/ai-completion.model';
|
|
55
|
+
export * from './lib/gatherers/ai-completion/v1/ai-completion.gatherer';
|
|
56
|
+
export * from './lib/services/ai-completion.service';
|
package/src/index.js
CHANGED
|
@@ -54,4 +54,7 @@ tslib_1.__exportStar(require("./lib/topics/notification/v1/notification.topic"),
|
|
|
54
54
|
tslib_1.__exportStar(require("./lib/services/notification.service"), exports);
|
|
55
55
|
tslib_1.__exportStar(require("./lib/gatherers/ai-context/v1/ai-context.model"), exports);
|
|
56
56
|
tslib_1.__exportStar(require("./lib/gatherers/ai-context/v1/ai-context.gatherer"), exports);
|
|
57
|
+
tslib_1.__exportStar(require("./lib/gatherers/ai-completion/v1/ai-completion.model"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./lib/gatherers/ai-completion/v1/ai-completion.gatherer"), exports);
|
|
59
|
+
tslib_1.__exportStar(require("./lib/services/ai-completion.service"), exports);
|
|
57
60
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/integration-interface/src/index.ts"],"names":[],"mappings":";;;AAAA,wFAA6D;AAC7D,qFAA0D;AAC1D,0FAA+D;AAC/D,uFAA4D;AAE5D,0FAA+D;AAE/D,8FAAmE;AAEnE,4FAAiE;AACjE,oFAAyD;AACzD,6FAAkE;AAElE,0FAA+D;AAC/D,0FAA+D;AAE/D,4FAAiE;AAEjE,oGAAyE;AACzE,0GAA+E;AAC/E,4FAAiE;AACjE,wFAA6D;AAC7D,2FAAgE;AAEhE,iGAAsE;AAEtE,gFAAqD;AACrD,gFAAqD;AAErD,mGAAwE;AACxE,yGAA8E;AAC9E,uFAA4D;AAC5D,oGAAyE;AAEzE,wFAA6D;AAE7D,gGAAqE;AACrE,gGAAqE;AAErE,8EAAmD;AACnD,kFAAuD;AACvD,4EAAiD;AACjD,sFAA2D;AAC3D,yFAA8D;AAE9D,4FAAiE;AACjE,8FAAmE;AACnE,uGAA4E;AAC5E,kGAAuE;AACvE,4FAAiE;AACjE,kGAAuE;AAEvE,kGAAuE;AACvE,kGAAuE;AAEvE,sFAA2D;AAE3D,8FAAmE;AAEnE,+FAAoE;AACpE,+FAAoE;AACpE,kFAAuD;AAEvD,2EAAgD;AAChD,2EAAgD;AAChD,sEAA2C;AAE3C,0FAA+D;AAC/D,0FAA+D;AAC/D,8EAAmD;AACnD,yFAA8D;AAC9D,4FAAiE"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/integration-interface/src/index.ts"],"names":[],"mappings":";;;AAAA,wFAA6D;AAC7D,qFAA0D;AAC1D,0FAA+D;AAC/D,uFAA4D;AAE5D,0FAA+D;AAE/D,8FAAmE;AAEnE,4FAAiE;AACjE,oFAAyD;AACzD,6FAAkE;AAElE,0FAA+D;AAC/D,0FAA+D;AAE/D,4FAAiE;AAEjE,oGAAyE;AACzE,0GAA+E;AAC/E,4FAAiE;AACjE,wFAA6D;AAC7D,2FAAgE;AAEhE,iGAAsE;AAEtE,gFAAqD;AACrD,gFAAqD;AAErD,mGAAwE;AACxE,yGAA8E;AAC9E,uFAA4D;AAC5D,oGAAyE;AAEzE,wFAA6D;AAE7D,gGAAqE;AACrE,gGAAqE;AAErE,8EAAmD;AACnD,kFAAuD;AACvD,4EAAiD;AACjD,sFAA2D;AAC3D,yFAA8D;AAE9D,4FAAiE;AACjE,8FAAmE;AACnE,uGAA4E;AAC5E,kGAAuE;AACvE,4FAAiE;AACjE,kGAAuE;AAEvE,kGAAuE;AACvE,kGAAuE;AAEvE,sFAA2D;AAE3D,8FAAmE;AAEnE,+FAAoE;AACpE,+FAAoE;AACpE,kFAAuD;AAEvD,2EAAgD;AAChD,2EAAgD;AAChD,sEAA2C;AAE3C,0FAA+D;AAC/D,0FAA+D;AAC/D,8EAAmD;AACnD,yFAA8D;AAC9D,4FAAiE;AACjE,+FAAoE;AACpE,kGAAuE;AACvE,+EAAoD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Gatherer } from "@onecx/accelerator";
|
|
2
|
+
import type { AiCompletionRequest, AiCompletionResponse } from "./ai-completion.model";
|
|
3
|
+
/**
|
|
4
|
+
* This class acts as a thin communication layer for AI completions between consumers inside
|
|
5
|
+
* onecx-portal-ui-libs and the AI Provider Remote Component. It publishes AI completion requests,
|
|
6
|
+
* collects responses from the registered provider instance and returns them to the caller.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
*
|
|
11
|
+
* // create the gatherer in the provider (remote component) so it can answer completion requests
|
|
12
|
+
* // in ngOnDestroy, call the gatherer.destroy() method to clean up resources
|
|
13
|
+
*
|
|
14
|
+
* const aiCompletionGatherer = new AiCompletionGatherer(async (request) => {
|
|
15
|
+
* // request the AI provider BFF with request.agent / request.message / ...
|
|
16
|
+
* // and return the response: { message: string }
|
|
17
|
+
* // return null if you do not want to contribute to this request
|
|
18
|
+
* return { message: "..." }
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // on the consumer side, publish the request and get the responses back:
|
|
22
|
+
* const responses = await aiCompletionGatherer.gather(request)
|
|
23
|
+
* // responses is an array of (AiCompletionResponse | null)
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class AiCompletionGatherer extends Gatherer<AiCompletionRequest, AiCompletionResponse | null> {
|
|
27
|
+
constructor(callback: (request: AiCompletionRequest) => Promise<AiCompletionResponse | null>);
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiCompletionGatherer = void 0;
|
|
4
|
+
const accelerator_1 = require("@onecx/accelerator");
|
|
5
|
+
/**
|
|
6
|
+
* This class acts as a thin communication layer for AI completions between consumers inside
|
|
7
|
+
* onecx-portal-ui-libs and the AI Provider Remote Component. It publishes AI completion requests,
|
|
8
|
+
* collects responses from the registered provider instance and returns them to the caller.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
*
|
|
13
|
+
* // create the gatherer in the provider (remote component) so it can answer completion requests
|
|
14
|
+
* // in ngOnDestroy, call the gatherer.destroy() method to clean up resources
|
|
15
|
+
*
|
|
16
|
+
* const aiCompletionGatherer = new AiCompletionGatherer(async (request) => {
|
|
17
|
+
* // request the AI provider BFF with request.agent / request.message / ...
|
|
18
|
+
* // and return the response: { message: string }
|
|
19
|
+
* // return null if you do not want to contribute to this request
|
|
20
|
+
* return { message: "..." }
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // on the consumer side, publish the request and get the responses back:
|
|
24
|
+
* const responses = await aiCompletionGatherer.gather(request)
|
|
25
|
+
* // responses is an array of (AiCompletionResponse | null)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class AiCompletionGatherer extends accelerator_1.Gatherer {
|
|
29
|
+
constructor(callback) {
|
|
30
|
+
super("aiCompletion", 1, callback);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AiCompletionGatherer = AiCompletionGatherer;
|
|
34
|
+
//# sourceMappingURL=ai-completion.gatherer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-completion.gatherer.js","sourceRoot":"","sources":["../../../../../../../../libs/integration-interface/src/lib/gatherers/ai-completion/v1/ai-completion.gatherer.ts"],"names":[],"mappings":";;;AAAA,oDAA6C;AAI7C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,oBAAqB,SAAQ,sBAA0D;IAChG,YAAY,QAAgF;QACxF,KAAK,CAAC,cAAc,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;IACtC,CAAC;CACJ;AAJD,oDAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-completion.model.js","sourceRoot":"","sources":["../../../../../../../../libs/integration-interface/src/lib/gatherers/ai-completion/v1/ai-completion.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AiCompletionRequest, AiCompletionResponse } from '../gatherers/ai-completion/v1/ai-completion.model';
|
|
2
|
+
export declare function consumerAiCompletionProvider(_request: AiCompletionRequest): Promise<AiCompletionResponse | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Thin service wrapper around AiCompletionGatherer that lets consumers inside request AI completions.
|
|
5
|
+
*
|
|
6
|
+
* It forwards the given request unchanged through the gatherer and returns the first
|
|
7
|
+
* non-null response collected from the registered AI provider instance (for example the
|
|
8
|
+
* ocx-ai-connector-component). If no provider contributes a response, an error is thrown.
|
|
9
|
+
*/
|
|
10
|
+
export declare class OneCXAiCompletionService {
|
|
11
|
+
private readonly aiCompletionGatherer;
|
|
12
|
+
getCompletion(request: AiCompletionRequest): Promise<AiCompletionResponse>;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OneCXAiCompletionService = void 0;
|
|
4
|
+
exports.consumerAiCompletionProvider = consumerAiCompletionProvider;
|
|
5
|
+
const ai_completion_gatherer_1 = require("../gatherers/ai-completion/v1/ai-completion.gatherer");
|
|
6
|
+
async function consumerAiCompletionProvider(_request) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thin service wrapper around AiCompletionGatherer that lets consumers inside request AI completions.
|
|
11
|
+
*
|
|
12
|
+
* It forwards the given request unchanged through the gatherer and returns the first
|
|
13
|
+
* non-null response collected from the registered AI provider instance (for example the
|
|
14
|
+
* ocx-ai-connector-component). If no provider contributes a response, an error is thrown.
|
|
15
|
+
*/
|
|
16
|
+
class OneCXAiCompletionService {
|
|
17
|
+
aiCompletionGatherer = new ai_completion_gatherer_1.AiCompletionGatherer(consumerAiCompletionProvider);
|
|
18
|
+
async getCompletion(request) {
|
|
19
|
+
const responses = await this.aiCompletionGatherer.gather(request);
|
|
20
|
+
const response = responses.find((r) => r !== null);
|
|
21
|
+
if (!response) {
|
|
22
|
+
throw new Error('No AI provider responded to the completion request');
|
|
23
|
+
}
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this.aiCompletionGatherer.destroy();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.OneCXAiCompletionService = OneCXAiCompletionService;
|
|
31
|
+
//# sourceMappingURL=ai-completion.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-completion.service.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/services/ai-completion.service.ts"],"names":[],"mappings":";;;AAGA,oEAIC;AAPD,iGAA2F;AAGpF,KAAK,UAAU,4BAA4B,CAChD,QAA6B;IAE7B,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAa,wBAAwB;IAClB,oBAAoB,GAAG,IAAI,6CAAoB,CAAC,4BAA4B,CAAC,CAAA;IAE9F,KAAK,CAAC,aAAa,CAAC,OAA4B;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACjE,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAA;IACrC,CAAC;CACF;AAfD,4DAeC"}
|