Correccion error 500
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -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
|
||||||
# FROM quay.ocp.banorte.com/base/openjdk-21:maven_3.8 AS builder
|
WORKDIR /app
|
||||||
# WORKDIR /app
|
COPY pom.xml .
|
||||||
# COPY pom.xml .
|
COPY src ./src
|
||||||
# COPY src ./src
|
RUN mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||||
# RUN mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true
|
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime
|
||||||
# FROM eclipse-temurin:21.0.3_9-jre-jammy
|
COPY --from=builder /app/target/app-jovenes-service-orchestrator-0.0.1-SNAPSHOT.jar app.jar
|
||||||
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"]
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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;
|
||||||
@@ -31,9 +32,16 @@ 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")),
|
||||||
(Instant) map.get("tiempo"),
|
timestamp,
|
||||||
(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")
|
||||||
|
|||||||
@@ -239,18 +239,21 @@ 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 10-minute threshold. Proceeding to Dialogflow.",
|
logger.info("Recent Session Found: Session {} is within the 30-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 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());
|
session.sessionId());
|
||||||
return memoryStoreConversationService.getMessages(session.sessionId()).collectList()
|
return memoryStoreConversationService.getMessages(session.sessionId())
|
||||||
.map(conversationContextMapper::toTextFromMessages)
|
.collectList()
|
||||||
|
// 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);
|
||||||
|
|||||||
@@ -17,62 +17,65 @@
|
|||||||
# =========================================================
|
# =========================================================
|
||||||
# Orchestrator general Configuration
|
# Orchestrator general Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
spring.cloud.gcp.project-id=${GCP_PROJECT_ID}
|
spring.cloud.gcp.project-id=app-jovenes
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Google Firestore Configuration
|
# Google Firestore Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
spring.cloud.gcp.firestore.project-id=${GCP_PROJECT_ID}
|
spring.cloud.gcp.firestore.project-id=app-jovenes
|
||||||
spring.cloud.gcp.firestore.database-id=${GCP_FIRESTORE_DATABASE_ID}
|
spring.cloud.gcp.firestore.database-id=app-jovenes-cache-database
|
||||||
spring.cloud.gcp.firestore.host=${GCP_FIRESTORE_HOST}
|
spring.cloud.gcp.firestore.host=firestore.googleapis.com
|
||||||
spring.cloud.gcp.firestore.port=${GCP_FIRESTORE_PORT}
|
spring.cloud.gcp.firestore.port=443
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Google Memorystore(Redis) Configuration
|
# Google Memorystore(Redis) Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
spring.data.redis.host=${REDIS_HOST}
|
spring.data.redis.host=10.241.0.11
|
||||||
spring.data.redis.port=${REDIS_PORT}
|
spring.data.redis.port=6379
|
||||||
#spring.data.redis.password=${REDIS_PWD}
|
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
|
||||||
#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=${REDIS_KEY_PWD}
|
# spring.data.redis.ssl.key-store-password=your-keystore-password
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Google Conversational Agents Configuration
|
# Google Conversational Agents Configuration
|
||||||
|
# beto-singlerag-contexto
|
||||||
# =========================================================
|
# =========================================================
|
||||||
dialogflow.cx.project-id=${DIALOGFLOW_CX_PROJECT_ID}
|
dialogflow.cx.project-id=app-jovenes
|
||||||
dialogflow.cx.location=${DIALOGFLOW_CX_LOCATION}
|
dialogflow.cx.location=us-central1
|
||||||
dialogflow.cx.agent-id=${DIALOGFLOW_CX_AGENT_ID}
|
dialogflow.cx.agent-id=d55333d2-9543-4f9c-bd7a-d0ee3b3573ac
|
||||||
dialogflow.default-language-code=${DIALOGFLOW_DEFAULT_LANGUAGE_CODE}
|
dialogflow.default-language-code=es
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Google Generative AI (Gemini) Configuration
|
# Google Generative AI (Gemini) Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
google.cloud.project=${GCP_PROJECT_ID}
|
google.cloud.project=app-jovenes
|
||||||
google.cloud.location=${GCP_LOCATION}
|
google.cloud.location=us-central1
|
||||||
gemini.model.name=${GEMINI_MODEL_NAME}
|
gemini.model.name=gemini-2.5-flash
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# (Gemini) MessageFilter Configuration
|
# (Gemini) MessageFilter Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
messagefilter.geminimodel=${MESSAGE_FILTER_GEMINI_MODEL}
|
messagefilter.geminimodel=gemini-2.5-flash
|
||||||
messagefilter.temperature=${MESSAGE_FILTER_TEMPERATURE}
|
messagefilter.temperature=0.1f
|
||||||
messagefilter.maxOutputTokens=${MESSAGE_FILTER_MAX_OUTPUT_TOKENS}
|
messagefilter.maxOutputTokens=800
|
||||||
messagefilter.topP=${MESSAGE_FILTER_TOP_P}
|
messagefilter.topP= 0.1f
|
||||||
messagefilter.prompt=prompts/message_filter_prompt.txt
|
messagefilter.prompt=prompts/message_filter_prompt.txt
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# (DLP) Configuration
|
# (DLP) Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
google.cloud.dlp.dlpTemplateCompleteFlow=${DLP_TEMPLATE_COMPLETE_FLOW}
|
google.cloud.dlp.dlpTemplateCompleteFlow=BNET_INSPECT
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Quick-replies Preset-data
|
# Quick-replies Preset-data
|
||||||
# =========================================================
|
# =========================================================
|
||||||
firestore.data.importer.enabled=${GCP_FIRESTORE_IMPORTER_ENABLE}
|
firestore.data.importer.enabled=false
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# LOGGING Configuration
|
# LOGGING Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
logging.level.root=${LOGGING_LEVEL_ROOT:INFO}
|
logging.level.root=INFO
|
||||||
logging.level.com.example=${LOGGING_LEVEL_COM_EXAMPLE:INFO}
|
logging.level.com.example=INFO
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# ConversationContext Configuration
|
# ConversationContext Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
conversation.context.message.limit=${CONVERSATION_CONTEXT_MESSAGE_LIMIT}
|
conversation.context.message.limit=60
|
||||||
conversation.context.days.limit=${CONVERSATION_CONTEXT_DAYS_LIMIT}
|
conversation.context.days.limit=30
|
||||||
|
# logs for dev inspection
|
||||||
|
logging.file.name=logs/orchestrator.log
|
||||||
|
|||||||
@@ -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=${REDIS_PWD}
|
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
|
||||||
#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=${REDIS_KEY_PWD}
|
# spring.data.redis.ssl.key-store-password=your-keystore-password
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# 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=${GCP_FIRESTORE_IMPORTER_ENABLE}
|
firestore.data.importer.enabled=true
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# LOGGING Configuration
|
# LOGGING Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|||||||
@@ -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=${REDIS_PWD}
|
#spring.data.redis.password=23cb4c76-9d96-4c74-b8c0-778fb364877a
|
||||||
#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=${REDIS_KEY_PWD}
|
# spring.data.redis.ssl.key-store-password=your-keystore-password
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# 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=${GCP_FIRESTORE_IMPORTER_ENABLE}
|
firestore.data.importer.enabled=true
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# LOGGING Configuration
|
# LOGGING Configuration
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
spring.profiles.active=${SPRING_PROFILE}
|
spring.profiles.active=dev
|
||||||
Reference in New Issue
Block a user