@dataclouder/conversation-card-nestjs 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
73
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
74
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
75
+ };
76
+ Object.defineProperty(exports, "__esModule", { value: true });
77
+ exports.IAModelsService = void 0;
78
+ var common_1 = require("@nestjs/common");
79
+ var groq_sdk_1 = require("groq-sdk");
80
+ var conversation_interface_1 = require("./clases/conversation.interface");
81
+ var IAModelsService = function () {
82
+ var _classDecorators = [(0, common_1.Injectable)()];
83
+ var _classDescriptor;
84
+ var _classExtraInitializers = [];
85
+ var _classThis;
86
+ var IAModelsService = _classThis = /** @class */ (function () {
87
+ function IAModelsService_1(conversationModel) {
88
+ this.conversationModel = conversationModel;
89
+ this.groqClient = new groq_sdk_1.default({
90
+ apiKey: process.env['GROQ_API_KEY'],
91
+ });
92
+ }
93
+ IAModelsService_1.prototype.chat = function (messages) {
94
+ var _a, _b;
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var completion, error_1;
97
+ return __generator(this, function (_c) {
98
+ switch (_c.label) {
99
+ case 0:
100
+ _c.trys.push([0, 2, , 3]);
101
+ return [4 /*yield*/, this.groqClient.chat.completions.create({
102
+ messages: messages,
103
+ model: 'mixtral-8x7b-32768',
104
+ temperature: 0.7,
105
+ max_tokens: 1024,
106
+ })];
107
+ case 1:
108
+ completion = _c.sent();
109
+ return [2 /*return*/, {
110
+ content: ((_b = (_a = completion.choices[0]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.content) || '',
111
+ role: conversation_interface_1.ChatRole.Assistant,
112
+ metadata: null,
113
+ }];
114
+ case 2:
115
+ error_1 = _c.sent();
116
+ throw new Error("Failed to generate completion: ".concat(error_1.message));
117
+ case 3: return [2 /*return*/];
118
+ }
119
+ });
120
+ });
121
+ };
122
+ IAModelsService_1.prototype.generateCompletion = function (prompt) {
123
+ var _a, _b;
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ var completion, error_2;
126
+ return __generator(this, function (_c) {
127
+ switch (_c.label) {
128
+ case 0:
129
+ _c.trys.push([0, 2, , 3]);
130
+ return [4 /*yield*/, this.groqClient.chat.completions.create({
131
+ messages: [{ role: 'user', content: prompt }],
132
+ model: 'mixtral-8x7b-32768',
133
+ temperature: 0.7,
134
+ max_tokens: 1024,
135
+ })];
136
+ case 1:
137
+ completion = _c.sent();
138
+ return [2 /*return*/, ((_b = (_a = completion.choices[0]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.content) || ''];
139
+ case 2:
140
+ error_2 = _c.sent();
141
+ throw new Error("Failed to generate completion: ".concat(error_2.message));
142
+ case 3: return [2 /*return*/];
143
+ }
144
+ });
145
+ });
146
+ };
147
+ IAModelsService_1.prototype.getCompletion = function (prompt) {
148
+ var _a, _b;
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var completion, error_3;
151
+ return __generator(this, function (_c) {
152
+ switch (_c.label) {
153
+ case 0:
154
+ _c.trys.push([0, 2, , 3]);
155
+ return [4 /*yield*/, this.groqClient.chat.completions.create({
156
+ messages: [{ role: 'user', content: prompt }],
157
+ model: 'mixtral-8x7b-32768',
158
+ temperature: 0.7,
159
+ max_tokens: 1024,
160
+ })];
161
+ case 1:
162
+ completion = _c.sent();
163
+ return [2 /*return*/, ((_b = (_a = completion.choices[0]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.content) || ''];
164
+ case 2:
165
+ error_3 = _c.sent();
166
+ throw new Error("Failed to generate completion: ".concat(error_3.message));
167
+ case 3: return [2 /*return*/];
168
+ }
169
+ });
170
+ });
171
+ };
172
+ return IAModelsService_1;
173
+ }());
174
+ __setFunctionName(_classThis, "IAModelsService");
175
+ (function () {
176
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
177
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
178
+ IAModelsService = _classThis = _classDescriptor.value;
179
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
180
+ __runInitializers(_classThis, _classExtraInitializers);
181
+ })();
182
+ return IAModelsService = _classThis;
183
+ }();
184
+ exports.IAModelsService = IAModelsService;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConversationType = exports.TextEngines = exports.ChatMessage = exports.ChatMessageDict = exports.WordTimestamps = exports.ChatMultiMessage = exports.ChatRole = void 0;
4
+ var ChatRole;
5
+ (function (ChatRole) {
6
+ ChatRole["System"] = "system";
7
+ ChatRole["User"] = "user";
8
+ ChatRole["Assistant"] = "assistant";
9
+ ChatRole["AssistantHelper"] = "assistantHelper";
10
+ })(ChatRole || (exports.ChatRole = ChatRole = {}));
11
+ var ChatMultiMessage = /** @class */ (function () {
12
+ function ChatMultiMessage() {
13
+ }
14
+ return ChatMultiMessage;
15
+ }());
16
+ exports.ChatMultiMessage = ChatMultiMessage;
17
+ var WordTimestamps = /** @class */ (function () {
18
+ function WordTimestamps() {
19
+ }
20
+ return WordTimestamps;
21
+ }());
22
+ exports.WordTimestamps = WordTimestamps;
23
+ var ChatMessageDict = /** @class */ (function () {
24
+ function ChatMessageDict() {
25
+ }
26
+ return ChatMessageDict;
27
+ }());
28
+ exports.ChatMessageDict = ChatMessageDict;
29
+ var ChatMessage = /** @class */ (function () {
30
+ function ChatMessage() {
31
+ }
32
+ return ChatMessage;
33
+ }());
34
+ exports.ChatMessage = ChatMessage;
35
+ var TextEngines;
36
+ (function (TextEngines) {
37
+ TextEngines["Plantext"] = "plantext";
38
+ TextEngines["SimpleText"] = "simpleText";
39
+ TextEngines["MarkdownMultiMessages"] = "markdownMultiMessages";
40
+ TextEngines["MarkdownSSML"] = "markdownSSML";
41
+ })(TextEngines || (exports.TextEngines = TextEngines = {}));
42
+ var ConversationType;
43
+ (function (ConversationType) {
44
+ ConversationType["General"] = "general";
45
+ ConversationType["Reflection"] = "reflection";
46
+ ConversationType["LearningExample"] = "learningExample";
47
+ ConversationType["Challenge"] = "challenge";
48
+ ConversationType["RolePlay"] = "rolePlay";
49
+ ConversationType["RolePlayNoNarrator"] = "rolePlayNoNarrator";
50
+ ConversationType["RolePlayInnerThoughts"] = "rolePlayInnerThoughts";
51
+ })(ConversationType || (exports.ConversationType = ConversationType = {}));
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
73
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
74
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
75
+ };
76
+ Object.defineProperty(exports, "__esModule", { value: true });
77
+ exports.ConversationAiController = void 0;
78
+ var common_1 = require("@nestjs/common");
79
+ var swagger_1 = require("@nestjs/swagger");
80
+ var conversation_interface_1 = require("./clases/conversation.interface");
81
+ var conversation_entity_1 = require("./entities/conversation.entity");
82
+ var ConversationAiController = function () {
83
+ var _classDecorators = [(0, swagger_1.ApiTags)('conversation-ai-cards'), (0, common_1.Controller)('api/conversation-ai-cards')];
84
+ var _classDescriptor;
85
+ var _classExtraInitializers = [];
86
+ var _classThis;
87
+ var _instanceExtraInitializers = [];
88
+ var _getConversations_decorators;
89
+ var _saveConversation_decorators;
90
+ var _getConversationById_decorators;
91
+ var _updateConversation_decorators;
92
+ var _deleteConversationById_decorators;
93
+ var _continueConversation_decorators;
94
+ var _getTTS_decorators;
95
+ var _test_decorators;
96
+ var ConversationAiController = _classThis = /** @class */ (function () {
97
+ function ConversationAiController_1(conversationAiService, aiModel, ttsService) {
98
+ this.conversationAiService = (__runInitializers(this, _instanceExtraInitializers), conversationAiService);
99
+ this.aiModel = aiModel;
100
+ this.ttsService = ttsService;
101
+ }
102
+ ConversationAiController_1.prototype.getConversations = function () {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ console.log('getConversations');
106
+ return [2 /*return*/, this.conversationAiService.getConversations()];
107
+ });
108
+ });
109
+ };
110
+ ConversationAiController_1.prototype.saveConversation = function (conversation) {
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ return __generator(this, function (_a) {
113
+ return [2 /*return*/, this.conversationAiService.saveConversation(conversation)];
114
+ });
115
+ });
116
+ };
117
+ ConversationAiController_1.prototype.getConversationById = function (id) {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ return __generator(this, function (_a) {
120
+ return [2 /*return*/, this.conversationAiService.getConversationById(id)];
121
+ });
122
+ });
123
+ };
124
+ ConversationAiController_1.prototype.updateConversation = function (id, updateData) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ return __generator(this, function (_a) {
127
+ return [2 /*return*/, this.conversationAiService.updateConversation(id, updateData)];
128
+ });
129
+ });
130
+ };
131
+ ConversationAiController_1.prototype.deleteConversationById = function (id) {
132
+ return __awaiter(this, void 0, void 0, function () {
133
+ return __generator(this, function (_a) {
134
+ return [2 /*return*/, this.conversationAiService.deleteConversationById(id)];
135
+ });
136
+ });
137
+ };
138
+ ConversationAiController_1.prototype.continueConversation = function (conversation) {
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ var messages, response;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0:
144
+ messages = conversation.messages;
145
+ console.log('messages', messages);
146
+ return [4 /*yield*/, this.aiModel.chat(messages)];
147
+ case 1:
148
+ response = _a.sent();
149
+ console.log('response', response);
150
+ return [2 /*return*/, response];
151
+ }
152
+ });
153
+ });
154
+ };
155
+ ConversationAiController_1.prototype.getTTS = function (tts, res) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var _a, audioContent, voiceName;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
160
+ case 0:
161
+ console.log('tts', tts);
162
+ return [4 /*yield*/, this.ttsService.getSpeech({
163
+ voiceName: tts.voice,
164
+ text: tts.text,
165
+ options: {},
166
+ lang: null,
167
+ isSsml: tts.ssml,
168
+ })];
169
+ case 1:
170
+ _a = _b.sent(), audioContent = _a.audioContent, voiceName = _a.voiceName;
171
+ res.header('Content-Type', 'audio/mpeg');
172
+ res.header('Content-Disposition', "attachment; filename=\"".concat(voiceName, ".mp3\""));
173
+ res.header('Content-Length', audioContent.length);
174
+ res.header('transcription', 'This is a transcription');
175
+ return [2 /*return*/, audioContent];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ ConversationAiController_1.prototype.test = function () {
181
+ return __awaiter(this, void 0, void 0, function () {
182
+ return __generator(this, function (_a) {
183
+ // charaCard.save();
184
+ return [2 /*return*/, 'Hello World' + conversation_interface_1.TextEngines.MarkdownMultiMessages];
185
+ });
186
+ });
187
+ };
188
+ return ConversationAiController_1;
189
+ }());
190
+ __setFunctionName(_classThis, "ConversationAiController");
191
+ (function () {
192
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
193
+ _getConversations_decorators = [(0, common_1.Get)('/conversation'), (0, swagger_1.ApiOperation)({ summary: 'Get all conversations' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return all conversations.' })];
194
+ _saveConversation_decorators = [(0, common_1.Post)('/conversation'), (0, swagger_1.ApiOperation)({ summary: 'Save new conversations' }), (0, swagger_1.ApiResponse)({ status: 201, description: 'The conversation has been successfully created.', type: conversation_entity_1.Conversation })];
195
+ _getConversationById_decorators = [(0, common_1.Get)('/conversation/:id'), (0, swagger_1.ApiOperation)({ summary: 'Get a conversation by ID' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' })];
196
+ _updateConversation_decorators = [(0, common_1.Put)('/conversation/:id'), (0, swagger_1.ApiOperation)({ summary: 'Update a conversation by ID' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'The conversation has been successfully updated.', type: conversation_entity_1.Conversation })];
197
+ _deleteConversationById_decorators = [(0, common_1.Delete)('/conversation/:id'), (0, swagger_1.ApiOperation)({ summary: 'Delete a conversation by ID' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the deleted conversation.' })];
198
+ _continueConversation_decorators = [(0, common_1.Post)('/chat'), (0, swagger_1.ApiOperation)({ summary: 'Continue the conversation' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' })];
199
+ _getTTS_decorators = [(0, common_1.Post)('/tts'), (0, swagger_1.ApiOperation)({ summary: 'Generate TTS audio' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the TTS audio.' })];
200
+ _test_decorators = [(0, common_1.Get)('/test'), (0, swagger_1.ApiOperation)({ summary: 'Test the conversation AI' }), (0, swagger_1.ApiResponse)({ status: 200, description: 'Return the test result.' })];
201
+ __esDecorate(_classThis, null, _getConversations_decorators, { kind: "method", name: "getConversations", static: false, private: false, access: { has: function (obj) { return "getConversations" in obj; }, get: function (obj) { return obj.getConversations; } }, metadata: _metadata }, null, _instanceExtraInitializers);
202
+ __esDecorate(_classThis, null, _saveConversation_decorators, { kind: "method", name: "saveConversation", static: false, private: false, access: { has: function (obj) { return "saveConversation" in obj; }, get: function (obj) { return obj.saveConversation; } }, metadata: _metadata }, null, _instanceExtraInitializers);
203
+ __esDecorate(_classThis, null, _getConversationById_decorators, { kind: "method", name: "getConversationById", static: false, private: false, access: { has: function (obj) { return "getConversationById" in obj; }, get: function (obj) { return obj.getConversationById; } }, metadata: _metadata }, null, _instanceExtraInitializers);
204
+ __esDecorate(_classThis, null, _updateConversation_decorators, { kind: "method", name: "updateConversation", static: false, private: false, access: { has: function (obj) { return "updateConversation" in obj; }, get: function (obj) { return obj.updateConversation; } }, metadata: _metadata }, null, _instanceExtraInitializers);
205
+ __esDecorate(_classThis, null, _deleteConversationById_decorators, { kind: "method", name: "deleteConversationById", static: false, private: false, access: { has: function (obj) { return "deleteConversationById" in obj; }, get: function (obj) { return obj.deleteConversationById; } }, metadata: _metadata }, null, _instanceExtraInitializers);
206
+ __esDecorate(_classThis, null, _continueConversation_decorators, { kind: "method", name: "continueConversation", static: false, private: false, access: { has: function (obj) { return "continueConversation" in obj; }, get: function (obj) { return obj.continueConversation; } }, metadata: _metadata }, null, _instanceExtraInitializers);
207
+ __esDecorate(_classThis, null, _getTTS_decorators, { kind: "method", name: "getTTS", static: false, private: false, access: { has: function (obj) { return "getTTS" in obj; }, get: function (obj) { return obj.getTTS; } }, metadata: _metadata }, null, _instanceExtraInitializers);
208
+ __esDecorate(_classThis, null, _test_decorators, { kind: "method", name: "test", static: false, private: false, access: { has: function (obj) { return "test" in obj; }, get: function (obj) { return obj.test; } }, metadata: _metadata }, null, _instanceExtraInitializers);
209
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
210
+ ConversationAiController = _classThis = _classDescriptor.value;
211
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
212
+ __runInitializers(_classThis, _classExtraInitializers);
213
+ })();
214
+ return ConversationAiController = _classThis;
215
+ }();
216
+ exports.ConversationAiController = ConversationAiController;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ConversationAiModule = void 0;
42
+ var common_1 = require("@nestjs/common");
43
+ var mongoose_1 = require("@nestjs/mongoose");
44
+ var conversation_ai_controller_1 = require("./conversation-ai.controller");
45
+ var conversation_entity_1 = require("./entities/conversation.entity");
46
+ var tts_service_1 = require("./tts/tts-service");
47
+ var ai_models_service_1 = require("./ai-models.service");
48
+ var conversation_ai_service_1 = require("./services/conversation-ai.service");
49
+ var ConversationAiModule = function () {
50
+ var _classDecorators = [(0, common_1.Module)({
51
+ imports: [mongoose_1.MongooseModule.forFeature([{ name: conversation_entity_1.Conversation.name, schema: conversation_entity_1.ConversationSchema }])],
52
+ controllers: [conversation_ai_controller_1.ConversationAiController],
53
+ providers: [conversation_ai_service_1.ConversationAiService, tts_service_1.TTSService, ai_models_service_1.IAModelsService],
54
+ exports: [conversation_ai_service_1.ConversationAiService, tts_service_1.TTSService, ai_models_service_1.IAModelsService],
55
+ })];
56
+ var _classDescriptor;
57
+ var _classExtraInitializers = [];
58
+ var _classThis;
59
+ var ConversationAiModule = _classThis = /** @class */ (function () {
60
+ function ConversationAiModule_1() {
61
+ }
62
+ return ConversationAiModule_1;
63
+ }());
64
+ __setFunctionName(_classThis, "ConversationAiModule");
65
+ (function () {
66
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
67
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
68
+ ConversationAiModule = _classThis = _classDescriptor.value;
69
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ __runInitializers(_classThis, _classExtraInitializers);
71
+ })();
72
+ return ConversationAiModule = _classThis;
73
+ }();
74
+ exports.ConversationAiModule = ConversationAiModule;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ConversationCardsModule = void 0;
42
+ var common_1 = require("@nestjs/common");
43
+ var mongoose_1 = require("@nestjs/mongoose");
44
+ var conversation_ai_controller_1 = require("./conversation-ai.controller");
45
+ var conversation_entity_1 = require("./entities/conversation.entity");
46
+ var tts_service_1 = require("./tts/tts-service");
47
+ var ai_models_service_1 = require("./ai-models.service");
48
+ var conversation_ai_service_1 = require("./services/conversation-ai.service");
49
+ var ConversationCardsModule = function () {
50
+ var _classDecorators = [(0, common_1.Module)({
51
+ imports: [mongoose_1.MongooseModule.forFeature([{ name: conversation_entity_1.Conversation.name, schema: conversation_entity_1.ConversationSchema }])],
52
+ controllers: [conversation_ai_controller_1.ConversationAiController],
53
+ providers: [conversation_ai_service_1.ConversationAiService, tts_service_1.TTSService, ai_models_service_1.IAModelsService],
54
+ exports: [conversation_ai_service_1.ConversationAiService, ai_models_service_1.IAModelsService, tts_service_1.TTSService],
55
+ })];
56
+ var _classDescriptor;
57
+ var _classExtraInitializers = [];
58
+ var _classThis;
59
+ var ConversationCardsModule = _classThis = /** @class */ (function () {
60
+ function ConversationCardsModule_1() {
61
+ }
62
+ return ConversationCardsModule_1;
63
+ }());
64
+ __setFunctionName(_classThis, "ConversationCardsModule");
65
+ (function () {
66
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
67
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
68
+ ConversationCardsModule = _classThis = _classDescriptor.value;
69
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ __runInitializers(_classThis, _classExtraInitializers);
71
+ })();
72
+ return ConversationCardsModule = _classThis;
73
+ }();
74
+ exports.ConversationCardsModule = ConversationCardsModule;