@wabot-dev/framework 0.1.0-beta.40 → 0.1.0-beta.42
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/src/addon/chat-bot/anthropic/AnthropicChatAdapter.js +9 -2
- package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +9 -2
- package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +7 -2
- package/dist/src/addon/repository/pg/PgCrudRepository.js +1 -1
- package/dist/src/feature/rest-controller/runRestControllers.js +15 -1
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { Env } from '../../../core/env/Env.js';
|
|
3
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
1
4
|
import { Logger } from '../../../core/logger/Logger.js';
|
|
2
5
|
import { Anthropic } from '@anthropic-ai/sdk';
|
|
3
6
|
|
|
4
|
-
class AnthropicChatAdapter {
|
|
7
|
+
let AnthropicChatAdapter = class AnthropicChatAdapter {
|
|
5
8
|
env;
|
|
6
9
|
anthropic;
|
|
7
10
|
logger = new Logger('wabot:anthropic-chat-adapter');
|
|
@@ -123,6 +126,10 @@ class AnthropicChatAdapter {
|
|
|
123
126
|
}
|
|
124
127
|
return { chatItem, usage };
|
|
125
128
|
}
|
|
126
|
-
}
|
|
129
|
+
};
|
|
130
|
+
AnthropicChatAdapter = __decorate([
|
|
131
|
+
singleton(),
|
|
132
|
+
__metadata("design:paramtypes", [Env])
|
|
133
|
+
], AnthropicChatAdapter);
|
|
127
134
|
|
|
128
135
|
export { AnthropicChatAdapter };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { Env } from '../../../core/env/Env.js';
|
|
3
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
1
4
|
import { Logger } from '../../../core/logger/Logger.js';
|
|
2
5
|
import { GoogleGenAI } from '@google/genai';
|
|
3
6
|
|
|
4
|
-
class GoogleChatAdapter {
|
|
7
|
+
let GoogleChatAdapter = class GoogleChatAdapter {
|
|
5
8
|
env;
|
|
6
9
|
genai;
|
|
7
10
|
logger = new Logger('wabot:google-chat-adapter');
|
|
@@ -115,6 +118,10 @@ class GoogleChatAdapter {
|
|
|
115
118
|
throw new Error('No parts in Gemini response');
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
}
|
|
121
|
+
};
|
|
122
|
+
GoogleChatAdapter = __decorate([
|
|
123
|
+
singleton(),
|
|
124
|
+
__metadata("design:paramtypes", [Env])
|
|
125
|
+
], GoogleChatAdapter);
|
|
119
126
|
|
|
120
127
|
export { GoogleChatAdapter };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
1
2
|
import { Logger } from '../../../core/logger/Logger.js';
|
|
2
3
|
import { OpenAI } from 'openai';
|
|
4
|
+
import { singleton } from '../../../core/injection/index.js';
|
|
3
5
|
|
|
4
|
-
class OpenaiChatAdapter {
|
|
6
|
+
let OpenaiChatAdapter = class OpenaiChatAdapter {
|
|
5
7
|
openai = new OpenAI();
|
|
6
8
|
logger = new Logger('wabot:openai-chat-adapter');
|
|
7
9
|
async nextItem(req) {
|
|
@@ -106,6 +108,9 @@ class OpenaiChatAdapter {
|
|
|
106
108
|
}
|
|
107
109
|
return { chatItem, usage };
|
|
108
110
|
}
|
|
109
|
-
}
|
|
111
|
+
};
|
|
112
|
+
OpenaiChatAdapter = __decorate([
|
|
113
|
+
singleton()
|
|
114
|
+
], OpenaiChatAdapter);
|
|
110
115
|
|
|
111
116
|
export { OpenaiChatAdapter };
|
|
@@ -32,7 +32,7 @@ class PgCrudRepository extends PgRepositoryBase {
|
|
|
32
32
|
const item = await this.find(id);
|
|
33
33
|
if (!item) {
|
|
34
34
|
throw new CustomError({
|
|
35
|
-
message: `Not found ${this.config.constructor.name} with id = '${id}'
|
|
35
|
+
message: `Not found ${this.config.constructor.name} with id = '${id}'`,
|
|
36
36
|
httpCode: 404,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -70,7 +70,7 @@ function runRestControllers(controllers) {
|
|
|
70
70
|
}, {});
|
|
71
71
|
res
|
|
72
72
|
.status(httpCode ?? 500)
|
|
73
|
-
.json({ error: { message: err.message, stack: err.stack, ...info } });
|
|
73
|
+
.json(removeCircular({ error: { message: err.message, stack: err.stack, ...info } }));
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
res.status(500).json({ error: { message: 'Unknown error' } });
|
|
@@ -84,5 +84,19 @@ function runRestControllers(controllers) {
|
|
|
84
84
|
});
|
|
85
85
|
expressProvider.listen();
|
|
86
86
|
}
|
|
87
|
+
function removeCircular(obj, seen = new WeakSet()) {
|
|
88
|
+
if (obj && typeof obj === 'object') {
|
|
89
|
+
if (seen.has(obj)) {
|
|
90
|
+
return undefined; // remove circular ref
|
|
91
|
+
}
|
|
92
|
+
seen.add(obj);
|
|
93
|
+
const clone = Array.isArray(obj) ? [] : {};
|
|
94
|
+
for (const key in obj) {
|
|
95
|
+
clone[key] = removeCircular(obj[key], seen);
|
|
96
|
+
}
|
|
97
|
+
return clone;
|
|
98
|
+
}
|
|
99
|
+
return obj;
|
|
100
|
+
}
|
|
87
101
|
|
|
88
102
|
export { runRestControllers };
|