Correccion error 500
This commit is contained in:
@@ -239,22 +239,25 @@ public class ConversationManagerService {
|
||||
DetectIntentRequestDTO request, ConversationSessionDTO session) {
|
||||
Instant now = Instant.now();
|
||||
if (Duration.between(session.lastModified(), now).toMinutes() < SESSION_RESET_THRESHOLD_MINUTES) {
|
||||
logger.info("Recent Session Found: Session {} is within the 10-minute threshold. Proceeding to Dialogflow.",
|
||||
logger.info("Recent Session Found: Session {} is within the 30-minute threshold. Proceeding to Dialogflow.",
|
||||
session.sessionId());
|
||||
return processDialogflowRequest(session, request, context.userId(), context.userMessageText(),
|
||||
context.primaryPhoneNumber(), false);
|
||||
} else {
|
||||
logger.info(
|
||||
"Old Session Found: Session {} is older than the threshold. Fetching history and continuing with same session.",
|
||||
"Old Session Found: Session {} is older than the 30-minute threshold. Fetching history and continuing with same session.",
|
||||
session.sessionId());
|
||||
return memoryStoreConversationService.getMessages(session.sessionId()).collectList()
|
||||
.map(conversationContextMapper::toTextFromMessages)
|
||||
.defaultIfEmpty("")
|
||||
.flatMap(conversationHistory -> {
|
||||
DetectIntentRequestDTO newRequest = request.withParameter(CONV_HISTORY_PARAM, conversationHistory);
|
||||
return processDialogflowRequest(session, newRequest, context.userId(), context.userMessageText(),
|
||||
context.primaryPhoneNumber(), false);
|
||||
});
|
||||
return memoryStoreConversationService.getMessages(session.sessionId())
|
||||
.collectList()
|
||||
// Adding use the TextWithLimits to truncate according to business rule 30 days/60 messages
|
||||
.map(messages -> conversationContextMapper.toTextWithLimits(session, messages))
|
||||
.defaultIfEmpty("")
|
||||
.flatMap(conversationHistory -> {
|
||||
// Inject historial (max 60 msgs / 30 días / 50KB)
|
||||
DetectIntentRequestDTO newRequest = request.withParameter(CONV_HISTORY_PARAM, conversationHistory);
|
||||
return processDialogflowRequest(session, newRequest, context.userId(), context.userMessageText(),
|
||||
context.primaryPhoneNumber(), false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user