@wrcb/cb-common 1.0.839 → 1.0.841
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.
|
@@ -46,9 +46,13 @@ export interface ChatResult {
|
|
|
46
46
|
export declare class AIClient {
|
|
47
47
|
private readonly natsClient;
|
|
48
48
|
private readonly service;
|
|
49
|
-
private readonly
|
|
50
|
-
private readonly
|
|
51
|
-
|
|
49
|
+
private readonly openaiApiKey;
|
|
50
|
+
private readonly cerebrasApiKey?;
|
|
51
|
+
private _openai?;
|
|
52
|
+
private _cerebras?;
|
|
53
|
+
constructor(natsClient: Stan, service: string, openaiApiKey: string, cerebrasApiKey?: string | undefined);
|
|
54
|
+
private get openai();
|
|
55
|
+
private get cerebras();
|
|
52
56
|
private emit;
|
|
53
57
|
chat(params: ChatParams): Promise<ChatResult>;
|
|
54
58
|
tts(params: TTSParams): Promise<Buffer>;
|
|
@@ -56,11 +56,19 @@ class AIClient {
|
|
|
56
56
|
constructor(natsClient, service, openaiApiKey, cerebrasApiKey) {
|
|
57
57
|
this.natsClient = natsClient;
|
|
58
58
|
this.service = service;
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
this.openaiApiKey = openaiApiKey;
|
|
60
|
+
this.cerebrasApiKey = cerebrasApiKey;
|
|
61
|
+
}
|
|
62
|
+
get openai() {
|
|
63
|
+
if (!this._openai)
|
|
64
|
+
this._openai = new openai_1.default({ apiKey: this.openaiApiKey });
|
|
65
|
+
return this._openai;
|
|
66
|
+
}
|
|
67
|
+
get cerebras() {
|
|
68
|
+
var _a;
|
|
69
|
+
if (!this._cerebras)
|
|
70
|
+
this._cerebras = new openai_1.default({ apiKey: (_a = this.cerebrasApiKey) !== null && _a !== void 0 ? _a : '', baseURL: 'https://api.cerebras.ai/v1' });
|
|
71
|
+
return this._cerebras;
|
|
64
72
|
}
|
|
65
73
|
emit(data) {
|
|
66
74
|
return __awaiter(this, void 0, void 0, function* () {
|