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