@hed-hog/core 0.0.223 → 0.0.233
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/ai/ai.controller.d.ts +90 -0
- package/dist/ai/ai.controller.d.ts.map +1 -0
- package/dist/ai/ai.controller.js +124 -0
- package/dist/ai/ai.controller.js.map +1 -0
- package/dist/ai/ai.module.d.ts +3 -0
- package/dist/ai/ai.module.d.ts.map +1 -0
- package/dist/ai/ai.module.js +31 -0
- package/dist/ai/ai.module.js.map +1 -0
- package/dist/ai/ai.service.d.ts +76 -0
- package/dist/ai/ai.service.d.ts.map +1 -0
- package/dist/ai/ai.service.js +467 -0
- package/dist/ai/ai.service.js.map +1 -0
- package/dist/ai/dto/chat-agent.dto.d.ts +5 -0
- package/dist/ai/dto/chat-agent.dto.d.ts.map +1 -0
- package/dist/ai/dto/chat-agent.dto.js +29 -0
- package/dist/ai/dto/chat-agent.dto.js.map +1 -0
- package/dist/ai/dto/chat.dto.d.ts +8 -0
- package/dist/ai/dto/chat.dto.d.ts.map +1 -0
- package/dist/ai/dto/chat.dto.js +45 -0
- package/dist/ai/dto/chat.dto.js.map +1 -0
- package/dist/ai/dto/create-agent.dto.d.ts +7 -0
- package/dist/ai/dto/create-agent.dto.d.ts.map +1 -0
- package/dist/ai/dto/create-agent.dto.js +38 -0
- package/dist/ai/dto/create-agent.dto.js.map +1 -0
- package/dist/ai/dto/update-agent.dto.d.ts +7 -0
- package/dist/ai/dto/update-agent.dto.d.ts.map +1 -0
- package/dist/ai/dto/update-agent.dto.js +38 -0
- package/dist/ai/dto/update-agent.dto.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +1 -1
- package/dist/auth/auth.service.d.ts +1 -1
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +3 -0
- package/dist/core.module.js.map +1 -1
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
- package/dist/file/file.service.d.ts +2 -0
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +17 -2
- package/dist/file/file.service.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/menu/menu.controller.d.ts +3 -3
- package/dist/menu/menu.service.d.ts +3 -3
- package/dist/user/user.controller.d.ts +2 -2
- package/dist/user/user.service.d.ts +3 -3
- package/hedhog/data/menu.yaml +16 -2
- package/hedhog/data/route.yaml +64 -0
- package/hedhog/data/setting_group.yaml +33 -1
- package/hedhog/frontend/app/ai_agent/page.tsx.ejs +465 -0
- package/hedhog/table/ai_agent.yaml +24 -0
- package/package.json +3 -3
- package/src/ai/ai.controller.ts +68 -0
- package/src/ai/ai.module.ts +18 -0
- package/src/ai/ai.service.ts +646 -0
- package/src/ai/dto/chat-agent.dto.ts +13 -0
- package/src/ai/dto/chat.dto.ts +26 -0
- package/src/ai/dto/create-agent.dto.ts +20 -0
- package/src/ai/dto/update-agent.dto.ts +20 -0
- package/src/core.module.ts +3 -0
- package/src/file/file.service.ts +34 -8
- package/src/index.ts +3 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AiService = void 0;
|
|
19
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
20
|
+
const common_1 = require("@nestjs/common");
|
|
21
|
+
const client_1 = require("@prisma/client");
|
|
22
|
+
const axios_1 = __importDefault(require("axios"));
|
|
23
|
+
const file_service_1 = require("../file/file.service");
|
|
24
|
+
const setting_service_1 = require("../setting/setting.service");
|
|
25
|
+
let AiService = class AiService {
|
|
26
|
+
constructor(prismaService, settingService, fileService) {
|
|
27
|
+
this.prismaService = prismaService;
|
|
28
|
+
this.settingService = settingService;
|
|
29
|
+
this.fileService = fileService;
|
|
30
|
+
}
|
|
31
|
+
async chat(data, file) {
|
|
32
|
+
const provider = data.provider || 'openai';
|
|
33
|
+
const attachment = await this.resolveAttachment(file, data.file_id);
|
|
34
|
+
if (provider === 'openai') {
|
|
35
|
+
const model = data.model || 'gpt-4o-mini';
|
|
36
|
+
const content = await this.chatWithOpenAi({
|
|
37
|
+
message: data.message,
|
|
38
|
+
model,
|
|
39
|
+
systemPrompt: data.systemPrompt,
|
|
40
|
+
attachment,
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
provider,
|
|
44
|
+
model,
|
|
45
|
+
content,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const model = data.model || 'gemini-1.5-flash';
|
|
49
|
+
const content = await this.chatWithGemini({
|
|
50
|
+
message: data.message,
|
|
51
|
+
model,
|
|
52
|
+
systemPrompt: data.systemPrompt,
|
|
53
|
+
attachment,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
provider,
|
|
57
|
+
model,
|
|
58
|
+
content,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async createAgent(data) {
|
|
62
|
+
var _a;
|
|
63
|
+
const slug = data.slug.trim();
|
|
64
|
+
const provider = data.provider || 'openai';
|
|
65
|
+
const model = data.model || this.getDefaultModel(provider);
|
|
66
|
+
const instructions = ((_a = data.instructions) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
67
|
+
const existing = await this.findAgentBySlug(slug);
|
|
68
|
+
if (existing) {
|
|
69
|
+
return existing;
|
|
70
|
+
}
|
|
71
|
+
let externalAgentId = null;
|
|
72
|
+
if (provider === 'openai') {
|
|
73
|
+
externalAgentId = await this.createOpenAiAssistant({
|
|
74
|
+
slug,
|
|
75
|
+
model,
|
|
76
|
+
instructions,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
await this.prismaService.$executeRaw `
|
|
80
|
+
INSERT INTO ai_agent (slug, provider, model, instructions, external_agent_id)
|
|
81
|
+
VALUES (${slug}, ${provider}, ${model}, ${instructions}, ${externalAgentId})
|
|
82
|
+
`;
|
|
83
|
+
return this.findAgentBySlug(slug);
|
|
84
|
+
}
|
|
85
|
+
async listAgents(paginationParams) {
|
|
86
|
+
var _a;
|
|
87
|
+
const page = Math.max(Number((paginationParams === null || paginationParams === void 0 ? void 0 : paginationParams.page) || 1), 1);
|
|
88
|
+
const pageSize = Math.min(Math.max(Number((paginationParams === null || paginationParams === void 0 ? void 0 : paginationParams.pageSize) || 10), 1), 100);
|
|
89
|
+
const offset = (page - 1) * pageSize;
|
|
90
|
+
const search = String((paginationParams === null || paginationParams === void 0 ? void 0 : paginationParams.search) || '').trim();
|
|
91
|
+
const whereClause = search
|
|
92
|
+
? client_1.Prisma.sql `WHERE LOWER(slug) LIKE LOWER(${`%${search}%`})`
|
|
93
|
+
: client_1.Prisma.empty;
|
|
94
|
+
const data = await this.prismaService.$queryRaw(client_1.Prisma.sql `
|
|
95
|
+
SELECT id, slug, provider, model, instructions, external_agent_id, created_at, updated_at
|
|
96
|
+
FROM ai_agent
|
|
97
|
+
${whereClause}
|
|
98
|
+
ORDER BY id DESC
|
|
99
|
+
LIMIT ${pageSize}
|
|
100
|
+
OFFSET ${offset}
|
|
101
|
+
`);
|
|
102
|
+
const totalResult = await this.prismaService.$queryRaw(client_1.Prisma.sql `
|
|
103
|
+
SELECT COUNT(*) AS total
|
|
104
|
+
FROM ai_agent
|
|
105
|
+
${whereClause}
|
|
106
|
+
`);
|
|
107
|
+
const total = Number(((_a = totalResult === null || totalResult === void 0 ? void 0 : totalResult[0]) === null || _a === void 0 ? void 0 : _a.total) || 0);
|
|
108
|
+
return {
|
|
109
|
+
data,
|
|
110
|
+
total,
|
|
111
|
+
page,
|
|
112
|
+
pageSize,
|
|
113
|
+
totalPages: Math.ceil(total / pageSize),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async getAgentById(agentId) {
|
|
117
|
+
const agent = await this.findAgentById(agentId);
|
|
118
|
+
if (!agent) {
|
|
119
|
+
throw new common_1.NotFoundException(`AI agent with id "${agentId}" was not found.`);
|
|
120
|
+
}
|
|
121
|
+
return agent;
|
|
122
|
+
}
|
|
123
|
+
async updateAgent(agentId, data) {
|
|
124
|
+
var _a, _b, _c, _d, _e, _f;
|
|
125
|
+
const currentAgent = await this.findAgentById(agentId);
|
|
126
|
+
if (!currentAgent) {
|
|
127
|
+
throw new common_1.NotFoundException(`AI agent with id "${agentId}" was not found.`);
|
|
128
|
+
}
|
|
129
|
+
const slug = (_b = (_a = data.slug) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : currentAgent.slug;
|
|
130
|
+
const provider = (_c = data.provider) !== null && _c !== void 0 ? _c : currentAgent.provider;
|
|
131
|
+
const model = (_e = (_d = data.model) !== null && _d !== void 0 ? _d : currentAgent.model) !== null && _e !== void 0 ? _e : this.getDefaultModel(provider);
|
|
132
|
+
const instructions = (_f = data.instructions) !== null && _f !== void 0 ? _f : currentAgent.instructions;
|
|
133
|
+
if (slug !== currentAgent.slug) {
|
|
134
|
+
const existingSlug = await this.findAgentBySlug(slug);
|
|
135
|
+
if (existingSlug && existingSlug.id !== agentId) {
|
|
136
|
+
throw new common_1.BadRequestException(`AI agent with slug "${slug}" already exists.`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let externalAgentId = currentAgent.external_agent_id;
|
|
140
|
+
if (provider !== 'openai') {
|
|
141
|
+
externalAgentId = null;
|
|
142
|
+
}
|
|
143
|
+
else if (!externalAgentId) {
|
|
144
|
+
externalAgentId = await this.createOpenAiAssistant({
|
|
145
|
+
slug,
|
|
146
|
+
model,
|
|
147
|
+
instructions,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
await this.prismaService.$executeRaw `
|
|
151
|
+
UPDATE ai_agent
|
|
152
|
+
SET slug = ${slug},
|
|
153
|
+
provider = ${provider},
|
|
154
|
+
model = ${model},
|
|
155
|
+
instructions = ${instructions},
|
|
156
|
+
external_agent_id = ${externalAgentId},
|
|
157
|
+
updated_at = NOW()
|
|
158
|
+
WHERE id = ${agentId}
|
|
159
|
+
`;
|
|
160
|
+
return this.getAgentById(agentId);
|
|
161
|
+
}
|
|
162
|
+
async deleteAgents({ ids }) {
|
|
163
|
+
const existing = await this.prismaService.$queryRaw(client_1.Prisma.sql `
|
|
164
|
+
SELECT id
|
|
165
|
+
FROM ai_agent
|
|
166
|
+
WHERE id IN (${client_1.Prisma.join(ids)})
|
|
167
|
+
`);
|
|
168
|
+
if (existing.length !== ids.length) {
|
|
169
|
+
const existingIds = existing.map((item) => item.id);
|
|
170
|
+
const missingIds = ids.filter((id) => !existingIds.includes(id));
|
|
171
|
+
throw new common_1.NotFoundException(`AI agents with ids "${missingIds.join(', ')}" were not found.`);
|
|
172
|
+
}
|
|
173
|
+
const deletedCount = await this.prismaService.$executeRaw `
|
|
174
|
+
DELETE FROM ai_agent
|
|
175
|
+
WHERE id IN (${client_1.Prisma.join(ids)})
|
|
176
|
+
`;
|
|
177
|
+
return {
|
|
178
|
+
count: Number(deletedCount || 0),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async chatWithAgent(slug, data, file) {
|
|
182
|
+
const agent = await this.findAgentBySlug(slug);
|
|
183
|
+
const attachment = await this.resolveAttachment(file, data.file_id);
|
|
184
|
+
if (!agent) {
|
|
185
|
+
throw new common_1.NotFoundException(`AI agent with slug "${slug}" was not found.`);
|
|
186
|
+
}
|
|
187
|
+
if (agent.provider === 'openai') {
|
|
188
|
+
if (agent.external_agent_id && !attachment) {
|
|
189
|
+
const content = await this.chatWithOpenAiAssistant(agent.external_agent_id, data.message);
|
|
190
|
+
return {
|
|
191
|
+
slug: agent.slug,
|
|
192
|
+
provider: agent.provider,
|
|
193
|
+
model: agent.model,
|
|
194
|
+
content,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const content = await this.chatWithOpenAi({
|
|
198
|
+
message: data.message,
|
|
199
|
+
model: agent.model || this.getDefaultModel('openai'),
|
|
200
|
+
systemPrompt: agent.instructions || undefined,
|
|
201
|
+
attachment,
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
slug: agent.slug,
|
|
205
|
+
provider: agent.provider,
|
|
206
|
+
model: agent.model,
|
|
207
|
+
content,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const content = await this.chatWithGemini({
|
|
211
|
+
message: data.message,
|
|
212
|
+
model: agent.model || this.getDefaultModel('gemini'),
|
|
213
|
+
systemPrompt: agent.instructions || undefined,
|
|
214
|
+
attachment,
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
slug: agent.slug,
|
|
218
|
+
provider: agent.provider,
|
|
219
|
+
model: agent.model,
|
|
220
|
+
content,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async getAgentBySlug(slug) {
|
|
224
|
+
const agent = await this.findAgentBySlug(slug);
|
|
225
|
+
if (!agent) {
|
|
226
|
+
throw new common_1.NotFoundException(`AI agent with slug "${slug}" was not found.`);
|
|
227
|
+
}
|
|
228
|
+
return agent;
|
|
229
|
+
}
|
|
230
|
+
async findAgentBySlug(slug) {
|
|
231
|
+
const result = await this.prismaService.$queryRaw `
|
|
232
|
+
SELECT id, slug, provider, model, instructions, external_agent_id, created_at, updated_at
|
|
233
|
+
FROM ai_agent
|
|
234
|
+
WHERE slug = ${slug}
|
|
235
|
+
LIMIT 1
|
|
236
|
+
`;
|
|
237
|
+
return (result === null || result === void 0 ? void 0 : result[0]) || null;
|
|
238
|
+
}
|
|
239
|
+
async findAgentById(id) {
|
|
240
|
+
const result = await this.prismaService.$queryRaw `
|
|
241
|
+
SELECT id, slug, provider, model, instructions, external_agent_id, created_at, updated_at
|
|
242
|
+
FROM ai_agent
|
|
243
|
+
WHERE id = ${id}
|
|
244
|
+
LIMIT 1
|
|
245
|
+
`;
|
|
246
|
+
return (result === null || result === void 0 ? void 0 : result[0]) || null;
|
|
247
|
+
}
|
|
248
|
+
getDefaultModel(provider) {
|
|
249
|
+
if (provider === 'openai') {
|
|
250
|
+
return 'gpt-4o-mini';
|
|
251
|
+
}
|
|
252
|
+
return 'gemini-1.5-flash';
|
|
253
|
+
}
|
|
254
|
+
async getApiKeys() {
|
|
255
|
+
const settings = await this.settingService.getSettingValues([
|
|
256
|
+
'ai-openai-api-key',
|
|
257
|
+
'ai-gemini-api-key',
|
|
258
|
+
]);
|
|
259
|
+
return {
|
|
260
|
+
openai: settings['ai-openai-api-key'],
|
|
261
|
+
gemini: settings['ai-gemini-api-key'],
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
async chatWithOpenAi({ message, model, systemPrompt, attachment, }) {
|
|
265
|
+
var _a, _b, _c, _d;
|
|
266
|
+
const { openai } = await this.getApiKeys();
|
|
267
|
+
if (!openai) {
|
|
268
|
+
throw new common_1.BadRequestException('OpenAI API key is not configured (setting "ai-openai-api-key").');
|
|
269
|
+
}
|
|
270
|
+
const messages = [];
|
|
271
|
+
if (systemPrompt) {
|
|
272
|
+
messages.push({ role: 'system', content: systemPrompt });
|
|
273
|
+
}
|
|
274
|
+
const userContent = this.buildOpenAiUserContent(message, attachment);
|
|
275
|
+
messages.push({ role: 'user', content: userContent });
|
|
276
|
+
const response = await axios_1.default.post('https://api.openai.com/v1/chat/completions', {
|
|
277
|
+
model,
|
|
278
|
+
messages,
|
|
279
|
+
}, {
|
|
280
|
+
headers: {
|
|
281
|
+
Authorization: `Bearer ${openai}`,
|
|
282
|
+
'Content-Type': 'application/json',
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
return ((_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.choices) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.content) || '';
|
|
286
|
+
}
|
|
287
|
+
async createOpenAiAssistant({ slug, model, instructions, }) {
|
|
288
|
+
var _a;
|
|
289
|
+
const { openai } = await this.getApiKeys();
|
|
290
|
+
if (!openai) {
|
|
291
|
+
throw new common_1.BadRequestException('OpenAI API key is not configured (setting "ai-openai-api-key").');
|
|
292
|
+
}
|
|
293
|
+
const response = await axios_1.default.post('https://api.openai.com/v1/assistants', {
|
|
294
|
+
name: slug,
|
|
295
|
+
model,
|
|
296
|
+
instructions: instructions || `You are the assistant identified by slug ${slug}.`,
|
|
297
|
+
}, {
|
|
298
|
+
headers: {
|
|
299
|
+
Authorization: `Bearer ${openai}`,
|
|
300
|
+
'Content-Type': 'application/json',
|
|
301
|
+
'OpenAI-Beta': 'assistants=v2',
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
const assistantId = (_a = response.data) === null || _a === void 0 ? void 0 : _a.id;
|
|
305
|
+
if (!assistantId) {
|
|
306
|
+
throw new common_1.BadRequestException('OpenAI assistant creation failed.');
|
|
307
|
+
}
|
|
308
|
+
return assistantId;
|
|
309
|
+
}
|
|
310
|
+
async chatWithOpenAiAssistant(assistantId, message) {
|
|
311
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
312
|
+
const { openai } = await this.getApiKeys();
|
|
313
|
+
if (!openai) {
|
|
314
|
+
throw new common_1.BadRequestException('OpenAI API key is not configured (setting "ai-openai-api-key").');
|
|
315
|
+
}
|
|
316
|
+
const threadResponse = await axios_1.default.post('https://api.openai.com/v1/threads', {
|
|
317
|
+
messages: [{ role: 'user', content: message }],
|
|
318
|
+
}, {
|
|
319
|
+
headers: {
|
|
320
|
+
Authorization: `Bearer ${openai}`,
|
|
321
|
+
'Content-Type': 'application/json',
|
|
322
|
+
'OpenAI-Beta': 'assistants=v2',
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
const threadId = (_a = threadResponse.data) === null || _a === void 0 ? void 0 : _a.id;
|
|
326
|
+
if (!threadId) {
|
|
327
|
+
throw new common_1.BadRequestException('OpenAI thread creation failed.');
|
|
328
|
+
}
|
|
329
|
+
const runResponse = await axios_1.default.post(`https://api.openai.com/v1/threads/${threadId}/runs`, {
|
|
330
|
+
assistant_id: assistantId,
|
|
331
|
+
}, {
|
|
332
|
+
headers: {
|
|
333
|
+
Authorization: `Bearer ${openai}`,
|
|
334
|
+
'Content-Type': 'application/json',
|
|
335
|
+
'OpenAI-Beta': 'assistants=v2',
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
const runId = (_b = runResponse.data) === null || _b === void 0 ? void 0 : _b.id;
|
|
339
|
+
if (!runId) {
|
|
340
|
+
throw new common_1.BadRequestException('OpenAI assistant run failed to start.');
|
|
341
|
+
}
|
|
342
|
+
for (let i = 0; i < 30; i++) {
|
|
343
|
+
const runStatusResponse = await axios_1.default.get(`https://api.openai.com/v1/threads/${threadId}/runs/${runId}`, {
|
|
344
|
+
headers: {
|
|
345
|
+
Authorization: `Bearer ${openai}`,
|
|
346
|
+
'OpenAI-Beta': 'assistants=v2',
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
const status = (_c = runStatusResponse.data) === null || _c === void 0 ? void 0 : _c.status;
|
|
350
|
+
if (status === 'completed') {
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
if (['cancelled', 'failed', 'expired'].includes(status)) {
|
|
354
|
+
throw new common_1.BadRequestException(`OpenAI assistant run did not complete successfully (status: ${status}).`);
|
|
355
|
+
}
|
|
356
|
+
await this.sleep(1000);
|
|
357
|
+
}
|
|
358
|
+
const messagesResponse = await axios_1.default.get(`https://api.openai.com/v1/threads/${threadId}/messages`, {
|
|
359
|
+
headers: {
|
|
360
|
+
Authorization: `Bearer ${openai}`,
|
|
361
|
+
'OpenAI-Beta': 'assistants=v2',
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
const assistantMessage = (_e = (_d = messagesResponse.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.find((item) => item.role === 'assistant');
|
|
365
|
+
const output = (_h = (_g = (_f = assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage.content) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.text) === null || _h === void 0 ? void 0 : _h.value;
|
|
366
|
+
return output || '';
|
|
367
|
+
}
|
|
368
|
+
async chatWithGemini({ message, model, systemPrompt, attachment, }) {
|
|
369
|
+
var _a, _b, _c, _d;
|
|
370
|
+
const { gemini } = await this.getApiKeys();
|
|
371
|
+
if (!gemini) {
|
|
372
|
+
throw new common_1.BadRequestException('Gemini API key is not configured (setting "ai-gemini-api-key").');
|
|
373
|
+
}
|
|
374
|
+
const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${gemini}`;
|
|
375
|
+
const userParts = [{ text: message }];
|
|
376
|
+
if (attachment) {
|
|
377
|
+
if (this.isTextMime(attachment.mimeType)) {
|
|
378
|
+
userParts.push({
|
|
379
|
+
text: `\n\n[Attached file: ${attachment.filename}]\n${this.toUtf8Text(attachment.buffer)}`,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
userParts.push({
|
|
384
|
+
inline_data: {
|
|
385
|
+
mime_type: attachment.mimeType,
|
|
386
|
+
data: attachment.buffer.toString('base64'),
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const payload = {
|
|
392
|
+
contents: [{ parts: userParts }],
|
|
393
|
+
};
|
|
394
|
+
if (systemPrompt) {
|
|
395
|
+
payload.systemInstruction = {
|
|
396
|
+
parts: [{ text: systemPrompt }],
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
const response = await axios_1.default.post(url, payload, {
|
|
400
|
+
headers: {
|
|
401
|
+
'Content-Type': 'application/json',
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
const parts = ((_d = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.candidates) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.parts) || [];
|
|
405
|
+
return parts.map((part) => part.text || '').join('');
|
|
406
|
+
}
|
|
407
|
+
async sleep(ms) {
|
|
408
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
409
|
+
}
|
|
410
|
+
async resolveAttachment(uploadFile, fileId) {
|
|
411
|
+
var _a;
|
|
412
|
+
if (uploadFile) {
|
|
413
|
+
return {
|
|
414
|
+
filename: uploadFile.originalname,
|
|
415
|
+
mimeType: uploadFile.mimetype,
|
|
416
|
+
buffer: uploadFile.buffer,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
if (fileId) {
|
|
420
|
+
const { file, buffer } = await this.fileService.getBuffer(fileId);
|
|
421
|
+
return {
|
|
422
|
+
filename: file.filename,
|
|
423
|
+
mimeType: ((_a = file.file_mimetype) === null || _a === void 0 ? void 0 : _a.name) || 'application/octet-stream',
|
|
424
|
+
buffer,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
buildOpenAiUserContent(message, attachment) {
|
|
430
|
+
if (!attachment) {
|
|
431
|
+
return message;
|
|
432
|
+
}
|
|
433
|
+
if (this.isImageMime(attachment.mimeType)) {
|
|
434
|
+
const dataUri = `data:${attachment.mimeType};base64,${attachment.buffer.toString('base64')}`;
|
|
435
|
+
return [
|
|
436
|
+
{ type: 'text', text: message },
|
|
437
|
+
{ type: 'image_url', image_url: { url: dataUri } },
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
const text = this.isTextMime(attachment.mimeType)
|
|
441
|
+
? this.toUtf8Text(attachment.buffer)
|
|
442
|
+
: `[Binary attachment: ${attachment.filename} | ${attachment.mimeType} | ${attachment.buffer.length} bytes]`;
|
|
443
|
+
return `${message}\n\n[Attached file: ${attachment.filename}]\n${text}`;
|
|
444
|
+
}
|
|
445
|
+
isImageMime(mimeType) {
|
|
446
|
+
return mimeType.startsWith('image/');
|
|
447
|
+
}
|
|
448
|
+
isTextMime(mimeType) {
|
|
449
|
+
return (mimeType.startsWith('text/') ||
|
|
450
|
+
mimeType === 'application/json' ||
|
|
451
|
+
mimeType === 'application/xml');
|
|
452
|
+
}
|
|
453
|
+
toUtf8Text(buffer) {
|
|
454
|
+
return buffer.toString('utf8');
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
exports.AiService = AiService;
|
|
458
|
+
exports.AiService = AiService = __decorate([
|
|
459
|
+
(0, common_1.Injectable)(),
|
|
460
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => api_prisma_1.PrismaService))),
|
|
461
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => setting_service_1.SettingService))),
|
|
462
|
+
__param(2, (0, common_1.Inject)((0, common_1.forwardRef)(() => file_service_1.FileService))),
|
|
463
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService,
|
|
464
|
+
setting_service_1.SettingService,
|
|
465
|
+
file_service_1.FileService])
|
|
466
|
+
], AiService);
|
|
467
|
+
//# sourceMappingURL=ai.service.js.map
|
|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O,CACL,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;YAC5B,QAAQ,KAAK,kBAAkB;YAC/B,QAAQ,KAAK,iBAAiB,CAC/B,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,MAAc;QAC/B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AA9lBY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,gCAAc,CAAC,CAAC,CAAA;IAExC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCAHN,0BAAa;QAEZ,gCAAc;QAEjB,0BAAW;GAPhC,SAAS,CA8lBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agent.dto.d.ts","sourceRoot":"","sources":["../../../src/ai/dto/chat-agent.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY;IAGvB,OAAO,EAAE,MAAM,CAAC;IAKhB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChatAgentDTO = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class ChatAgentDTO {
|
|
16
|
+
}
|
|
17
|
+
exports.ChatAgentDTO = ChatAgentDTO;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, class_validator_1.IsString)(),
|
|
20
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], ChatAgentDTO.prototype, "message", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
26
|
+
(0, class_validator_1.IsInt)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], ChatAgentDTO.prototype, "file_id", void 0);
|
|
29
|
+
//# sourceMappingURL=chat-agent.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-agent.dto.js","sourceRoot":"","sources":["../../../src/ai/dto/chat-agent.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA0E;AAE1E,MAAa,YAAY;CASxB;AATD,oCASC;AANC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6CACG;AAKhB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;6CACS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.dto.d.ts","sourceRoot":"","sources":["../../../src/ai/dto/chat.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,OAAO;IAGlB,OAAO,EAAE,MAAM,CAAC;IAKhB,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAI/B,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChatDTO = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class ChatDTO {
|
|
16
|
+
}
|
|
17
|
+
exports.ChatDTO = ChatDTO;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, class_validator_1.IsString)(),
|
|
20
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], ChatDTO.prototype, "message", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
(0, class_validator_1.IsIn)(['openai', 'gemini']),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], ChatDTO.prototype, "provider", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, class_validator_1.IsOptional)(),
|
|
31
|
+
(0, class_validator_1.IsString)(),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], ChatDTO.prototype, "model", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsOptional)(),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], ChatDTO.prototype, "systemPrompt", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, class_validator_1.IsOptional)(),
|
|
41
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
42
|
+
(0, class_validator_1.IsInt)(),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], ChatDTO.prototype, "file_id", void 0);
|
|
45
|
+
//# sourceMappingURL=chat.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.dto.js","sourceRoot":"","sources":["../../../src/ai/dto/chat.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAAgF;AAEhF,MAAa,OAAO;CAsBnB;AAtBD,0BAsBC;AAnBC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wCACG;AAKhB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,sBAAI,EAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;;yCACI;AAI/B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sCACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;6CACW;AAKtB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;wCACS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-agent.dto.d.ts","sourceRoot":"","sources":["../../../src/ai/dto/create-agent.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,cAAc;IAGzB,IAAI,EAAE,MAAM,CAAC;IAKb,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAI/B,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateAgentDTO = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateAgentDTO {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateAgentDTO = CreateAgentDTO;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CreateAgentDTO.prototype, "slug", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsIn)(['openai', 'gemini']),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], CreateAgentDTO.prototype, "provider", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsOptional)(),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], CreateAgentDTO.prototype, "model", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
(0, class_validator_1.IsString)(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], CreateAgentDTO.prototype, "instructions", void 0);
|
|
38
|
+
//# sourceMappingURL=create-agent.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-agent.dto.js","sourceRoot":"","sources":["../../../src/ai/dto/create-agent.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyE;AAEzE,MAAa,cAAc;CAiB1B;AAjBD,wCAiBC;AAdC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;4CACA;AAKb;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,sBAAI,EAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;;gDACI;AAI/B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;6CACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACW"}
|