fix getting giga token

This commit is contained in:
Дмитриев Максим Сергеевич
2025-06-14 18:26:13 +03:00
parent 45cafbee91
commit f37f34d803
4 changed files with 20 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
const router = require('express').Router();
const { getSupabaseClient } = require('./supabaseClient');
const { getGigaAuth } = require('./get-constants');
const { SupportAgent } = require('./support-ai-agent/support-agent');
// Хранилище агентов для разных пользователей
@@ -8,11 +9,13 @@ const userAgents = new Map();
/**
* Получить или создать агента для пользователя
*/
function getUserAgent(userId) {
async function getUserAgent(userId) {
if (!userAgents.has(userId)) {
const GIGA_AUTH = await getGigaAuth();
const config = {
threadId: userId,
temperature: 0.7
temperature: 0.7,
GIGA_AUTH
};
userAgents.set(userId, new SupportAgent(config));
}
@@ -74,7 +77,7 @@ router.post('/support', async (req, res) => {
}
// Получаем агента для пользователя
const agent = getUserAgent(user_id);
const agent = await getUserAgent(user_id);
// Получаем ответ от AI-агента, передавая apartment_id
const aiResponse = await agent.processMessage(message, apartment_id);