UPDATE 2 10-sept
This commit is contained in:
@@ -103,11 +103,13 @@ public class MessageEntryFilter {
|
||||
|
||||
String resultCategory = switch (geminiResponse != null ? geminiResponse.trim().toUpperCase() : "") {
|
||||
case CATEGORY_CONVERSATION -> {
|
||||
logger.info("Classified as {}. Input: '{}'", CATEGORY_CONVERSATION, queryInputText);
|
||||
logger.info("Classified as {}. Input: '{}'", CATEGORY_CONVERSATION);
|
||||
logger.debug("Classified as {}. Input: '{}'", CATEGORY_CONVERSATION, queryInputText);
|
||||
yield CATEGORY_CONVERSATION;
|
||||
}
|
||||
case CATEGORY_NOTIFICATION -> {
|
||||
logger.info("Classified as {}. Input: '{}'", CATEGORY_NOTIFICATION, queryInputText);
|
||||
logger.info("Classified as {}. Input: '{}'", CATEGORY_NOTIFICATION);
|
||||
logger.debug("Classified as {}. Input: '{}'", CATEGORY_NOTIFICATION, queryInputText);
|
||||
yield CATEGORY_NOTIFICATION;
|
||||
}
|
||||
default -> {
|
||||
|
||||
@@ -64,6 +64,7 @@ public class NotificationContextResolver {
|
||||
|
||||
public String resolveContext(String queryInputText, String notificationsJson, String conversationJson,
|
||||
String metadata, String userId, String sessionId, String userPhoneNumber) {
|
||||
logger.debug("resolveContext -> queryInputText: {}, notificationsJson: {}, conversationJson: {}, metadata: {}", queryInputText, notificationsJson, conversationJson, metadata);
|
||||
if (queryInputText == null || queryInputText.isBlank()) {
|
||||
logger.warn("Query input text for context resolution is null or blank. Returning {}.", CATEGORY_DIALOGFLOW);
|
||||
return CATEGORY_DIALOGFLOW;
|
||||
@@ -82,7 +83,7 @@ public class NotificationContextResolver {
|
||||
metadata,
|
||||
queryInputText);
|
||||
|
||||
logger.info("Sending context resolution request to Gemini for input (first 100 chars): '{}'...",
|
||||
logger.debug("Sending context resolution request to Gemini for input (first 100 chars): '{}'...",
|
||||
queryInputText.substring(0, Math.min(queryInputText.length(), 100)));
|
||||
|
||||
try {
|
||||
|
||||
@@ -293,7 +293,7 @@ public class ConversationManagerService {
|
||||
String notificationText = notificationContextMapper.toText(notification);
|
||||
|
||||
Map<String, Object> filteredParams = notification.parametros().entrySet().stream()
|
||||
.filter(entry -> entry.getKey().startsWith("po_"))
|
||||
.filter(entry -> entry.getKey().startsWith("notification_po_"))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
String resolvedContext = notificationContextResolver.resolveContext(userMessageText,
|
||||
@@ -360,13 +360,15 @@ public class ConversationManagerService {
|
||||
|
||||
private Mono<Void> persistNotificationTurn(String userId, String sessionId, ConversationEntryDTO entry,
|
||||
String userPhoneNumber) {
|
||||
logger.debug("Starting Write-Back persistence for notification session {}. Type: {}. Writing to Redis first.", sessionId,
|
||||
logger.debug("Starting Write-Back persistence for notification session {}. Type: {}. Writing to Redis first.",
|
||||
sessionId,
|
||||
entry.type().name());
|
||||
return memoryStoreNotificationService.saveEntry(userId, sessionId, entry, userPhoneNumber)
|
||||
.doOnSuccess(v -> logger.info(
|
||||
"Entry saved to Redis for notification session {}. Type: {}. Kicking off async Firestore write-back.",
|
||||
sessionId, entry.type().name()))
|
||||
.doOnError(e -> logger.error("Error during primary Redis write for notification session {}. Type: {}: {}", sessionId,
|
||||
.doOnError(e -> logger.error(
|
||||
"Error during primary Redis write for notification session {}. Type: {}: {}", sessionId,
|
||||
entry.type().name(), e.getMessage(), e));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,18 +49,18 @@ public class MemoryStoreConversationService {
|
||||
String sessionKey = SESSION_KEY_PREFIX + sessionId;
|
||||
String phoneToSessionKey = PHONE_TO_SESSION_KEY_PREFIX + userPhoneNumber;
|
||||
|
||||
logger.info("Attempting to save entry to Redis for session {}. Entity: {}", sessionId, newEntry.entity().name());
|
||||
logger.info("Attempting to save entry to Memorystore for session {}. Entity: {}", sessionId, newEntry.entity().name());
|
||||
|
||||
return redisTemplate.opsForValue().get(sessionKey)
|
||||
.doOnSuccess(session -> {
|
||||
if (session != null) {
|
||||
logger.info("Found existing session in Redis: {}", session);
|
||||
logger.info("Found existing session in Memorystore: {}", session);
|
||||
} else {
|
||||
logger.info("No session found in Redis for key: {}", sessionKey);
|
||||
logger.info("No session found in Memorystore for key: {}", sessionKey);
|
||||
}
|
||||
})
|
||||
.switchIfEmpty(Mono.defer(() -> {
|
||||
logger.info("Creating new session {} in Redis with TTL.", sessionId);
|
||||
logger.info("Creating new session {} in Memorystore with TTL.", sessionId);
|
||||
ConversationSessionDTO newSession = ConversationSessionDTO.create(sessionId, userId, userPhoneNumber);
|
||||
return redisTemplate.opsForValue().set(sessionKey, newSession, SESSION_TTL)
|
||||
.then(stringRedisTemplate.opsForValue().set(phoneToSessionKey, sessionId, SESSION_TTL))
|
||||
@@ -71,7 +71,7 @@ public class MemoryStoreConversationService {
|
||||
ConversationSessionDTO sessionWithPantallaContexto = (pantallaContexto != null) ? sessionWithUpdatedTelefono.withPantallaContexto(pantallaContexto) : sessionWithUpdatedTelefono;
|
||||
ConversationSessionDTO updatedSession = sessionWithPantallaContexto.withAddedEntry(newEntry);
|
||||
|
||||
logger.info("Updated session to be saved in Redis: {}", updatedSession);
|
||||
logger.debug("Updated session to be saved in Memorystore: {}", updatedSession);
|
||||
logger.info("Attempting to set updated session {} with new entry entity {} in Redis.", sessionId, newEntry.entity().name());
|
||||
|
||||
return redisTemplate.opsForValue().set(sessionKey, updatedSession)
|
||||
@@ -81,14 +81,14 @@ public class MemoryStoreConversationService {
|
||||
.doOnSuccess(success -> {
|
||||
logger.info("Successfully saved updated session and phone mapping to Redis for session {}. Entity Type: {}", sessionId, newEntry.entity().name());
|
||||
})
|
||||
.doOnError(e -> logger.error("Error appending entry to Redis for session {}: {}", sessionId, e.getMessage(), e));
|
||||
.doOnError(e -> logger.error("Error appending entry to Memorystore for session {}: {}", sessionId, e.getMessage(), e));
|
||||
}
|
||||
public Mono<ConversationSessionDTO> getSessionByTelefono(String telefono) {
|
||||
if (telefono == null || telefono.isBlank()) {
|
||||
return Mono.empty();
|
||||
}
|
||||
String phoneToSessionKey = PHONE_TO_SESSION_KEY_PREFIX + telefono;
|
||||
logger.debug("Attempting to retrieve session ID for phone number {} from Redis.", telefono);
|
||||
logger.debug("Attempting to retrieve session ID for phone number {} from Memorystore.", telefono);
|
||||
return stringRedisTemplate.opsForValue().get(phoneToSessionKey)
|
||||
.flatMap(sessionId -> {
|
||||
logger.debug("Found session ID {} for phone number {}. Retrieving session data.", sessionId, telefono);
|
||||
@@ -106,7 +106,7 @@ public class MemoryStoreConversationService {
|
||||
|
||||
public Mono<Void> updateSession(ConversationSessionDTO session) {
|
||||
String sessionKey = SESSION_KEY_PREFIX + session.sessionId();
|
||||
logger.info("Attempting to update session {} in Redis.", session.sessionId());
|
||||
logger.info("Attempting to update session {} in Memorystore.", session.sessionId());
|
||||
return redisTemplate.opsForValue().set(sessionKey, session).then();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user