fix getting giga token
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user