UPDATE 06-nov
This commit is contained in:
@@ -119,7 +119,6 @@ public class MessageEntryFilter {
|
|||||||
yield CATEGORY_UNKNOWN;
|
yield CATEGORY_UNKNOWN;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
resultCategory = CATEGORY_CONVERSATION;
|
|
||||||
return resultCategory;
|
return resultCategory;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An error occurred during Gemini content generation for message classification.", e);
|
logger.error("An error occurred during Gemini content generation for message classification.", e);
|
||||||
|
|||||||
@@ -161,41 +161,8 @@ public class ConversationManagerService {
|
|||||||
String userMessageText = request.queryInput().text().text();
|
String userMessageText = request.queryInput().text().text();
|
||||||
final ConversationContext context = new ConversationContext(resolvedUserId, null, userMessageText, primaryPhoneNumber);
|
final ConversationContext context = new ConversationContext(resolvedUserId, null, userMessageText, primaryPhoneNumber);
|
||||||
|
|
||||||
return handleMessageClassification(context, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<DetectIntentResponseDTO> handleMessageClassification(ConversationContext context,
|
|
||||||
DetectIntentRequestDTO request) {
|
|
||||||
final String userPhoneNumber = context.primaryPhoneNumber();
|
|
||||||
final String userMessageText = context.userMessageText();
|
|
||||||
|
|
||||||
return memoryStoreConversationService.getSessionByTelefono(userPhoneNumber)
|
|
||||||
.flatMap(session -> memoryStoreConversationService.getMessages(session.sessionId()).collectList()
|
|
||||||
.map(conversationContextMapper::toTextFromMessages)
|
|
||||||
.defaultIfEmpty("")
|
|
||||||
.flatMap(conversationHistory -> {
|
|
||||||
return memoryStoreNotificationService.getNotificationIdForPhone(userPhoneNumber)
|
|
||||||
.flatMap(notificationId -> memoryStoreNotificationService
|
|
||||||
.getCachedNotificationSession(notificationId))
|
|
||||||
.map(notificationSession -> notificationSession.notificaciones().stream()
|
|
||||||
.filter(notification -> "active".equalsIgnoreCase(notification.status()))
|
|
||||||
.max(java.util.Comparator.comparing(NotificationDTO::timestampCreacion))
|
|
||||||
.orElse(null))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.flatMap((NotificationDTO notification) -> {
|
|
||||||
String notificationText = notificationContextMapper.toText(notification);
|
|
||||||
String classification = messageEntryFilter.classifyMessage(userMessageText,
|
|
||||||
notificationText, conversationHistory);
|
|
||||||
if (MessageEntryFilter.CATEGORY_NOTIFICATION.equals(classification)) {
|
|
||||||
return startNotificationConversation(context, request, notification);
|
|
||||||
} else {
|
|
||||||
return continueConversationFlow(context, request);
|
return continueConversationFlow(context, request);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.switchIfEmpty(continueConversationFlow(context, request));
|
|
||||||
}))
|
|
||||||
.switchIfEmpty(continueConversationFlow(context, request));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<DetectIntentResponseDTO> continueConversationFlow(ConversationContext context,
|
private Mono<DetectIntentResponseDTO> continueConversationFlow(ConversationContext context,
|
||||||
DetectIntentRequestDTO request) {
|
DetectIntentRequestDTO request) {
|
||||||
@@ -357,7 +324,6 @@ public class ConversationManagerService {
|
|||||||
String resolvedContext = notificationContextResolver.resolveContext(userMessageText,
|
String resolvedContext = notificationContextResolver.resolveContext(userMessageText,
|
||||||
notificationText, conversationHistory, filteredParams.toString(), userId, sessionId,
|
notificationText, conversationHistory, filteredParams.toString(), userId, sessionId,
|
||||||
userPhoneNumber);
|
userPhoneNumber);
|
||||||
|
|
||||||
if (!resolvedContext.trim().toUpperCase().contains(NotificationContextResolver.CATEGORY_DIALOGFLOW)) {
|
if (!resolvedContext.trim().toUpperCase().contains(NotificationContextResolver.CATEGORY_DIALOGFLOW)) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
llmResponseTunerService.setValue(uuid, resolvedContext).subscribe();
|
llmResponseTunerService.setValue(uuid, resolvedContext).subscribe();
|
||||||
|
|||||||
Reference in New Issue
Block a user