Revert "Correccion error 500"

This reverts commit 24cebae2e3
This commit is contained in:
PAVEL PALMA
2026-01-07 22:31:56 -06:00
parent 21c7e3df39
commit a828de3990
7 changed files with 57 additions and 71 deletions

View File

@@ -4,7 +4,6 @@
*/
package com.example.mapper.conversation;
import com.google.cloud.Timestamp;
import com.example.dto.dialogflow.conversation.ConversationMessageDTO;
import com.example.dto.dialogflow.conversation.MessageType;
@@ -32,16 +31,9 @@ public class ConversationMessageMapper {
}
public ConversationMessageDTO fromMap(Map<String, Object> map) {
Object timeObject = map.get("tiempo");
Instant timestamp = null;
if (timeObject instanceof Timestamp) {
timestamp = ((Timestamp) timeObject).toDate().toInstant();
} else if (timeObject instanceof Instant) {
timestamp = (Instant) timeObject;
}
return new ConversationMessageDTO(
MessageType.valueOf((String) map.get("entidad")),
timestamp,
(Instant) map.get("tiempo"),
(String) map.get("mensaje"),
(Map<String, Object>) map.get("parametros"),
(String) map.get("canal")

View File

@@ -239,25 +239,22 @@ 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 30-minute threshold. Proceeding to Dialogflow.",
logger.info("Recent Session Found: Session {} is within the 10-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 30-minute threshold. Fetching history and continuing with same session.",
"Old Session Found: Session {} is older than the threshold. Fetching history and continuing with same session.",
session.sessionId());
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);
});
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);
});
}
}

View File

@@ -17,65 +17,62 @@
# =========================================================
# Orchestrator general Configuration
# =========================================================
spring.cloud.gcp.project-id=app-jovenes
spring.cloud.gcp.project-id=${GCP_PROJECT_ID}
# =========================================================
# Google Firestore Configuration
# =========================================================
spring.cloud.gcp.firestore.project-id=app-jovenes
spring.cloud.gcp.firestore.database-id=app-jovenes-cache-database
spring.cloud.gcp.firestore.host=firestore.googleapis.com
spring.cloud.gcp.firestore.port=443
spring.cloud.gcp.firestore.project-id=${GCP_PROJECT_ID}
spring.cloud.gcp.firestore.database-id=${GCP_FIRESTORE_DATABASE_ID}
spring.cloud.gcp.firestore.host=${GCP_FIRESTORE_HOST}
spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
# =========================================================
# Google Memorystore(Redis) Configuration
# =========================================================
spring.data.redis.host=10.241.0.11
spring.data.redis.port=6379
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT}
#spring.data.redis.password=${REDIS_PWD}
#spring.data.redis.username=default
# SSL Configuration (if using SSL)
# spring.data.redis.ssl=true
# spring.data.redis.ssl.key-store=classpath:keystore.p12
# spring.data.redis.ssl.key-store-password=your-keystore-password
# spring.data.redis.ssl.key-store-password=${REDIS_KEY_PWD}
# =========================================================
# Google Conversational Agents Configuration
# beto-singlerag-contexto
# =========================================================
dialogflow.cx.project-id=app-jovenes
dialogflow.cx.location=us-central1
dialogflow.cx.agent-id=d55333d2-9543-4f9c-bd7a-d0ee3b3573ac
dialogflow.default-language-code=es
dialogflow.cx.project-id=${DIALOGFLOW_CX_PROJECT_ID}
dialogflow.cx.location=${DIALOGFLOW_CX_LOCATION}
dialogflow.cx.agent-id=${DIALOGFLOW_CX_AGENT_ID}
dialogflow.default-language-code=${DIALOGFLOW_DEFAULT_LANGUAGE_CODE}
# =========================================================
# Google Generative AI (Gemini) Configuration
# =========================================================
google.cloud.project=app-jovenes
google.cloud.location=us-central1
gemini.model.name=gemini-2.5-flash
google.cloud.project=${GCP_PROJECT_ID}
google.cloud.location=${GCP_LOCATION}
gemini.model.name=${GEMINI_MODEL_NAME}
# =========================================================
# (Gemini) MessageFilter Configuration
# =========================================================
messagefilter.geminimodel=gemini-2.5-flash
messagefilter.temperature=0.1f
messagefilter.maxOutputTokens=800
messagefilter.topP= 0.1f
messagefilter.geminimodel=${MESSAGE_FILTER_GEMINI_MODEL}
messagefilter.temperature=${MESSAGE_FILTER_TEMPERATURE}
messagefilter.maxOutputTokens=${MESSAGE_FILTER_MAX_OUTPUT_TOKENS}
messagefilter.topP=${MESSAGE_FILTER_TOP_P}
messagefilter.prompt=prompts/message_filter_prompt.txt
# =========================================================
# (DLP) Configuration
# =========================================================
google.cloud.dlp.dlpTemplateCompleteFlow=BNET_INSPECT
google.cloud.dlp.dlpTemplateCompleteFlow=${DLP_TEMPLATE_COMPLETE_FLOW}
# =========================================================
# Quick-replies Preset-data
# =========================================================
firestore.data.importer.enabled=false
firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
# =========================================================
# LOGGING Configuration
# =========================================================
logging.level.root=INFO
logging.level.com.example=INFO
logging.level.root=${LOGGING_LEVEL_ROOT:INFO}
logging.level.com.example=${LOGGING_LEVEL_COM_EXAMPLE:INFO}
# =========================================================
# ConversationContext Configuration
# =========================================================
conversation.context.message.limit=60
conversation.context.days.limit=30
# logs for dev inspection
logging.file.name=logs/orchestrator.log
conversation.context.message.limit=${CONVERSATION_CONTEXT_MESSAGE_LIMIT}
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}

View File

@@ -30,13 +30,13 @@ spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
# =========================================================
spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT}
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
#spring.data.redis.password=${REDIS_PWD}
#spring.data.redis.username=default
# SSL Configuration (if using SSL)
# spring.data.redis.ssl=true
# spring.data.redis.ssl.key-store=classpath:keystore.p12
# spring.data.redis.ssl.key-store-password=your-keystore-password
# spring.data.redis.ssl.key-store-password=${REDIS_KEY_PWD}
# =========================================================
# Google Conversational Agents Configuration
# =========================================================
@@ -66,7 +66,7 @@ google.cloud.dlp.dlpTemplatePersistFlow=${DLP_TEMPLATE_PERSIST_FLOW}
# =========================================================
# Quick-replies Preset-data
# =========================================================
firestore.data.importer.enabled=true
firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
# =========================================================
# LOGGING Configuration
# =========================================================
@@ -76,4 +76,4 @@ logging.level.com.example=${LOGGING_LEVEL_COM_EXAMPLE:INFO}
# ConversationContext Configuration
# =========================================================
conversation.context.message.limit=${CONVERSATION_CONTEXT_MESSAGE_LIMIT}
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}

View File

@@ -30,13 +30,13 @@ spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
# =========================================================
spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT}
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
#spring.data.redis.password=${REDIS_PWD}
#spring.data.redis.username=default
# SSL Configuration (if using SSL)
# spring.data.redis.ssl=true
# spring.data.redis.ssl.key-store=classpath:keystore.p12
# spring.data.redis.ssl.key-store-password=your-keystore-password
# spring.data.redis.ssl.key-store-password=${REDIS_KEY_PWD}
# =========================================================
# Google Conversational Agents Configuration
# =========================================================
@@ -66,7 +66,7 @@ google.cloud.dlp.dlpTemplatePersistFlow=${DLP_TEMPLATE_PERSIST_FLOW}
# =========================================================
# Quick-replies Preset-data
# =========================================================
firestore.data.importer.enabled=true
firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
# =========================================================
# LOGGING Configuration
# =========================================================
@@ -76,4 +76,4 @@ logging.level.com.example=${LOGGING_LEVEL_COM_EXAMPLE:INFO}
# ConversationContext Configuration
# =========================================================
conversation.context.message.limit=${CONVERSATION_CONTEXT_MESSAGE_LIMIT}
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}

View File

@@ -1 +1 @@
spring.profiles.active=dev
spring.profiles.active=${SPRING_PROFILE}