ваше сообщение коммита
This commit is contained in:
@@ -543,45 +543,8 @@ class UniversalGuestService {
|
||||
};
|
||||
}
|
||||
|
||||
// Проверяем согласия для добавления системного сообщения к ответу ИИ
|
||||
const consentService = require('./consentService');
|
||||
const [provider, providerId] = identifier?.split(':') || [];
|
||||
let walletAddress = null;
|
||||
|
||||
if (provider === 'web' && providerId?.startsWith('guest_')) {
|
||||
walletAddress = providerId; // Для веб-гостей используем guest_ID
|
||||
}
|
||||
|
||||
const consentCheck = await consentService.checkConsents({
|
||||
userId: null,
|
||||
walletAddress
|
||||
});
|
||||
|
||||
// Формируем финальный ответ ИИ с системным сообщением, если нужно
|
||||
// 4. Сохраняем AI ответ
|
||||
let finalAiResponse = aiResponse.response;
|
||||
let consentInfo = null;
|
||||
|
||||
if (consentCheck.needsConsent) {
|
||||
const consentSystemMessage = await consentService.getConsentSystemMessage({
|
||||
userId: null,
|
||||
walletAddress,
|
||||
channel: channel === 'web' ? 'web' : channel
|
||||
});
|
||||
|
||||
if (consentSystemMessage && consentSystemMessage.consentRequired) {
|
||||
// Добавляем системное сообщение к ответу ИИ
|
||||
finalAiResponse = `${aiResponse.response}\n\n---\n\n${consentSystemMessage.content}`;
|
||||
|
||||
consentInfo = {
|
||||
consentRequired: true,
|
||||
missingConsents: consentSystemMessage.missingConsents,
|
||||
consentDocuments: consentSystemMessage.consentDocuments,
|
||||
autoConsentOnReply: consentSystemMessage.autoConsentOnReply
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Сохраняем AI ответ с добавленным системным сообщением
|
||||
await this.saveAiResponse({
|
||||
identifier,
|
||||
content: finalAiResponse,
|
||||
@@ -600,14 +563,6 @@ class UniversalGuestService {
|
||||
}
|
||||
};
|
||||
|
||||
// Добавляем информацию о согласиях, если они нужны
|
||||
if (consentInfo) {
|
||||
result.consentRequired = consentInfo.consentRequired;
|
||||
result.missingConsents = consentInfo.missingConsents;
|
||||
result.consentDocuments = consentInfo.consentDocuments;
|
||||
result.autoConsentOnReply = consentInfo.autoConsentOnReply;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
|
||||
@@ -380,30 +380,10 @@ async function processMessage(messageData) {
|
||||
});
|
||||
|
||||
if (aiResponse && aiResponse.success && aiResponse.response) {
|
||||
// Проверяем согласия и добавляем системное сообщение к ответу ИИ
|
||||
const walletIdentity = await identityService.findIdentity(userId, 'wallet');
|
||||
const consentSystemMessage = await consentService.getConsentSystemMessage({
|
||||
userId,
|
||||
walletAddress: walletIdentity?.provider_id || null,
|
||||
channel: channel === 'web' ? 'web' : channel
|
||||
});
|
||||
|
||||
// Формируем финальный ответ ИИ с системным сообщением, если нужно
|
||||
// Формируем финальный ответ ИИ
|
||||
finalAiResponse = aiResponse.response;
|
||||
if (consentSystemMessage && consentSystemMessage.consentRequired) {
|
||||
// Добавляем системное сообщение к ответу ИИ
|
||||
finalAiResponse = `${aiResponse.response}\n\n---\n\n${consentSystemMessage.content}`;
|
||||
|
||||
// Сохраняем информацию о согласиях в метаданные ответа
|
||||
aiResponse.consentInfo = {
|
||||
consentRequired: true,
|
||||
missingConsents: consentSystemMessage.missingConsents,
|
||||
consentDocuments: consentSystemMessage.consentDocuments,
|
||||
autoConsentOnReply: consentSystemMessage.autoConsentOnReply
|
||||
};
|
||||
}
|
||||
|
||||
// Сохраняем ответ AI с добавленным системным сообщением
|
||||
// Сохраняем ответ AI
|
||||
const { rows: aiMessageRows } = await db.getQuery()(
|
||||
`INSERT INTO messages (
|
||||
conversation_id,
|
||||
@@ -478,14 +458,6 @@ async function processMessage(messageData) {
|
||||
assistantDisabled: aiResponseDisabled
|
||||
};
|
||||
|
||||
// Если есть информация о согласиях, добавляем её в результат
|
||||
if (aiResponse && aiResponse.success && aiResponse.consentInfo) {
|
||||
result.consentRequired = aiResponse.consentInfo.consentRequired;
|
||||
result.missingConsents = aiResponse.consentInfo.missingConsents;
|
||||
result.consentDocuments = aiResponse.consentInfo.consentDocuments;
|
||||
result.autoConsentOnReply = aiResponse.consentInfo.autoConsentOnReply;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user