From 27763bf1559341330ca4bf5f621c58918c04cc7a Mon Sep 17 00:00:00 2001 From: ronalds Date: Mon, 8 Dec 2025 16:26:59 -0300 Subject: [PATCH] =?UTF-8?q?=20Versiones=20Actualizadas=20Backend:=201.2.12?= =?UTF-8?q?=20=E2=86=92=201.2.13=20Frontend:=201.3.8=20=E2=86=92=201.3.9?= =?UTF-8?q?=20=F0=9F=92=A1=20Beneficios=20Mejor=20UX:=20El=20mec=C3=A1nico?= =?UTF-8?q?=20no=20ve=20un=20chat=20vac=C3=ADo,=20sino=20orientaci=C3=B3n?= =?UTF-8?q?=20inmediata=20Contextualizado:=20El=20asistente=20menciona=20l?= =?UTF-8?q?o=20que=20ya=20conoce=20de=20la=20inspecci=C3=B3n=20Gu=C3=ADa?= =?UTF-8?q?=20clara:=20Indica=20qu=C3=A9=20puede=20hacer=20el=20asistente?= =?UTF-8?q?=20seg=C3=BAn=20las=20instrucciones=20configuradas=20Eficiente:?= =?UTF-8?q?=20Solo=20se=20genera=20una=20vez=20por=20sesi=C3=B3n=20de=20ch?= =?UTF-8?q?at?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/main.py | 37 +++++++- frontend/package.json | 2 +- frontend/public/service-worker.js | 2 +- frontend/src/App.jsx | 136 +++++++++++++++++++++++++++++- frontend/src/Sidebar.jsx | 2 +- 5 files changed, 171 insertions(+), 8 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 160df65..1f1f30a 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -278,7 +278,7 @@ def extract_pdf_text_smart(pdf_content: bytes, max_chars: int = None) -> dict: } -BACKEND_VERSION = "1.2.12" +BACKEND_VERSION = "1.2.13" app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION) # S3/MinIO configuration @@ -3453,6 +3453,11 @@ async def chat_with_ai_assistant( print(f"📝 Context answers: {len(context_answers_list)} respuestas previas") print(f"💭 Chat history: {len(chat_history_list)} mensajes previos") + # Detectar si es el mensaje inicial de bienvenida + is_initial_greeting = (user_message == "__INITIAL_GREETING__") + if is_initial_greeting: + print("🎉 MENSAJE INICIAL DE BIENVENIDA") + # Procesar archivos adjuntos attached_files_data = [] if files: @@ -3564,6 +3569,36 @@ INFORMACIÓN DEL VEHÍCULO: if observations: answers_context += f" Observaciones: {observations}\n" + # Si es mensaje inicial, generar saludo contextualizado + if is_initial_greeting: + greeting_parts = ["¡Hola! Soy tu Asistente Ayutec."] + + # Mencionar instrucciones específicas si existen + if assistant_instructions: + greeting_parts.append(f"\n\n{assistant_instructions}") + elif assistant_prompt: + greeting_parts.append(f"\n\nEstoy aquí para ayudarte con: {assistant_prompt}") + + # Mencionar contexto disponible + context_info = [] + if context_answers_list: + context_info.append(f"{len(context_answers_list)} respuestas anteriores") + if context_photos_list: + context_info.append(f"{len(context_photos_list)} fotografías") + + if context_info: + greeting_parts.append(f"\n\nHe analizado {' y '.join(context_info)} de esta inspección del vehículo {vehicle_info_dict.get('brand', '')} {vehicle_info_dict.get('model', '')} (Placa: {vehicle_info_dict.get('plate', '')}).") + + # Pregunta específica o solicitud de información + if assistant_prompt: + greeting_parts.append("\n\n¿Qué información necesitas o deseas que analice?") + else: + greeting_parts.append("\n\n¿En qué puedo ayudarte con esta inspección?") + + # Reemplazar el mensaje especial con el saludo generado + user_message = "".join(greeting_parts) + print(f"✅ Mensaje de bienvenida generado: {user_message[:100]}...") + # Definir la longitud de respuesta max_tokens_map = { 'short': 200, diff --git a/frontend/package.json b/frontend/package.json index 907c90e..a307bd6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "checklist-frontend", "private": true, - "version": "1.3.8", + "version": "1.3.9", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/public/service-worker.js b/frontend/public/service-worker.js index 464b954..a470c2e 100644 --- a/frontend/public/service-worker.js +++ b/frontend/public/service-worker.js @@ -1,6 +1,6 @@ // Service Worker para PWA con detección de actualizaciones // IMPORTANTE: Actualizar esta versión cada vez que se despliegue una nueva versión -const CACHE_NAME = 'ayutec-v1.3.8'; +const CACHE_NAME = 'ayutec-v1.3.9'; const urlsToCache = [ '/', '/index.html' diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 7ae0bb0..e6fc0f7 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -4384,6 +4384,7 @@ function InspectionModal({ checklist, existingInspection, user, onClose, onCompl const [showAIChat, setShowAIChat] = useState(false) const [aiChatMessages, setAiChatMessages] = useState([]) const [aiChatLoading, setAiChatLoading] = useState(false) + const [initialMessageSent, setInitialMessageSent] = useState(false) // Signature canvas const mechanicSigRef = useRef(null) @@ -5309,9 +5310,10 @@ function InspectionModal({ checklist, existingInspection, user, onClose, onCompl