fix system prompt
This commit is contained in:
@@ -8,15 +8,12 @@ const userAgents = new Map();
|
||||
/**
|
||||
* Получить или создать агента для пользователя
|
||||
*/
|
||||
function getUserAgent(userId, systemPrompt) {
|
||||
function getUserAgent(userId) {
|
||||
if (!userAgents.has(userId)) {
|
||||
const config = {
|
||||
threadId: userId,
|
||||
temperature: 0.7
|
||||
};
|
||||
if (systemPrompt) {
|
||||
config.systemPrompt = systemPrompt;
|
||||
}
|
||||
userAgents.set(userId, new SupportAgent(config));
|
||||
}
|
||||
return userAgents.get(userId);
|
||||
@@ -25,7 +22,7 @@ function getUserAgent(userId, systemPrompt) {
|
||||
// POST /api/support
|
||||
router.post('/support', async (req, res) => {
|
||||
const supabase = getSupabaseClient();
|
||||
const { user_id, message, system_prompt } = req.body;
|
||||
const { user_id, message } = req.body;
|
||||
|
||||
if (!user_id || !message) {
|
||||
return res.status(400).json({ error: 'user_id и message обязательны' });
|
||||
@@ -42,12 +39,7 @@ router.post('/support', async (req, res) => {
|
||||
}
|
||||
|
||||
// Получаем агента для пользователя
|
||||
const agent = getUserAgent(user_id, system_prompt);
|
||||
|
||||
// Обновляем системный промпт если передан
|
||||
if (system_prompt) {
|
||||
agent.updateSystemPrompt(system_prompt);
|
||||
}
|
||||
const agent = getUserAgent(user_id);
|
||||
|
||||
// Получаем ответ от AI-агента
|
||||
const aiResponse = await agent.processMessage(message);
|
||||
@@ -89,35 +81,7 @@ router.post('/support', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/support/configure - Настройка системного промпта
|
||||
router.post('/support/configure', async (req, res) => {
|
||||
const { user_id, system_prompt } = req.body;
|
||||
|
||||
if (!user_id) {
|
||||
return res.status(400).json({ error: 'user_id обязателен' });
|
||||
}
|
||||
|
||||
try {
|
||||
const agent = getUserAgent(user_id, system_prompt);
|
||||
|
||||
if (system_prompt) {
|
||||
agent.updateSystemPrompt(system_prompt);
|
||||
}
|
||||
|
||||
res.json({
|
||||
message: 'Конфигурация агента обновлена',
|
||||
current_system_prompt: agent.getSystemPrompt(),
|
||||
success: true
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Ошибка в /support/configure:', error);
|
||||
res.status(500).json({
|
||||
error: 'Внутренняя ошибка сервера',
|
||||
success: false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/support/history/:userId - Очистка истории диалога
|
||||
router.delete('/support/history/:userId', async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user