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

@@ -1,15 +1,15 @@
# Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose.
# Your use of it is subject to your agreement with Google.
# Java 21.0.6 # Java 21.0.6
# 'jammy' refers to Ubuntu 22.04 LTS, which is a stable and widely used base. # 'jammy' refers to Ubuntu 22.04 LTS, which is a stable and widely used base.
FROM maven:3.9.6-eclipse-temurin-21 AS builder # FROM maven:3.9.6-eclipse-temurin-21 AS builder
WORKDIR /app # FROM quay.ocp.banorte.com/base/openjdk-21:maven_3.8 AS builder
COPY pom.xml . # WORKDIR /app
COPY src ./src # COPY pom.xml .
RUN mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true # COPY src ./src
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime # RUN mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true
COPY --from=builder /app/target/app-jovenes-service-orchestrator-0.0.1-SNAPSHOT.jar app.jar # FROM eclipse-temurin:21.0.3_9-jre-jammy
FROM quay.ocp.banorte.com/golden/openjdk-21:latest
# COPY --from=builder /app/target/app-jovenes-service-orchestrator-0.0.1-SNAPSHOT.jar app.jar
COPY target/app-jovenes-service-orchestrator-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"] ENTRYPOINT ["java", "-jar", "app.jar"]

View File

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

View File

@@ -239,21 +239,18 @@ public class ConversationManagerService {
DetectIntentRequestDTO request, ConversationSessionDTO session) { DetectIntentRequestDTO request, ConversationSessionDTO session) {
Instant now = Instant.now(); Instant now = Instant.now();
if (Duration.between(session.lastModified(), now).toMinutes() < SESSION_RESET_THRESHOLD_MINUTES) { 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()); session.sessionId());
return processDialogflowRequest(session, request, context.userId(), context.userMessageText(), return processDialogflowRequest(session, request, context.userId(), context.userMessageText(),
context.primaryPhoneNumber(), false); context.primaryPhoneNumber(), false);
} else { } else {
logger.info( 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()); session.sessionId());
return memoryStoreConversationService.getMessages(session.sessionId()) return memoryStoreConversationService.getMessages(session.sessionId()).collectList()
.collectList() .map(conversationContextMapper::toTextFromMessages)
// Adding use the TextWithLimits to truncate according to business rule 30 days/60 messages
.map(messages -> conversationContextMapper.toTextWithLimits(session, messages))
.defaultIfEmpty("") .defaultIfEmpty("")
.flatMap(conversationHistory -> { .flatMap(conversationHistory -> {
// Inject historial (max 60 msgs / 30 días / 50KB)
DetectIntentRequestDTO newRequest = request.withParameter(CONV_HISTORY_PARAM, conversationHistory); DetectIntentRequestDTO newRequest = request.withParameter(CONV_HISTORY_PARAM, conversationHistory);
return processDialogflowRequest(session, newRequest, context.userId(), context.userMessageText(), return processDialogflowRequest(session, newRequest, context.userId(), context.userMessageText(),
context.primaryPhoneNumber(), false); context.primaryPhoneNumber(), false);

View File

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

View File

@@ -30,13 +30,13 @@ spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
# ========================================================= # =========================================================
spring.data.redis.host=${REDIS_HOST} spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT} 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 #spring.data.redis.username=default
# SSL Configuration (if using SSL) # SSL Configuration (if using SSL)
# spring.data.redis.ssl=true # spring.data.redis.ssl=true
# spring.data.redis.ssl.key-store=classpath:keystore.p12 # 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 # Google Conversational Agents Configuration
# ========================================================= # =========================================================
@@ -66,7 +66,7 @@ google.cloud.dlp.dlpTemplatePersistFlow=${DLP_TEMPLATE_PERSIST_FLOW}
# ========================================================= # =========================================================
# Quick-replies Preset-data # Quick-replies Preset-data
# ========================================================= # =========================================================
firestore.data.importer.enabled=true firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
# ========================================================= # =========================================================
# LOGGING Configuration # LOGGING Configuration
# ========================================================= # =========================================================

View File

@@ -30,13 +30,13 @@ spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
# ========================================================= # =========================================================
spring.data.redis.host=${REDIS_HOST} spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT} 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 #spring.data.redis.username=default
# SSL Configuration (if using SSL) # SSL Configuration (if using SSL)
# spring.data.redis.ssl=true # spring.data.redis.ssl=true
# spring.data.redis.ssl.key-store=classpath:keystore.p12 # 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 # Google Conversational Agents Configuration
# ========================================================= # =========================================================
@@ -66,7 +66,7 @@ google.cloud.dlp.dlpTemplatePersistFlow=${DLP_TEMPLATE_PERSIST_FLOW}
# ========================================================= # =========================================================
# Quick-replies Preset-data # Quick-replies Preset-data
# ========================================================= # =========================================================
firestore.data.importer.enabled=true firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
# ========================================================= # =========================================================
# LOGGING Configuration # LOGGING Configuration
# ========================================================= # =========================================================

View File

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