feat(whatsapp): QWEN primary AI backend, Hermes fallback, conversation history, vehicle persistence, demo prompts

- Add QWEN (qwen3.6) as primary AI backend with short system prompt
- Hermes remains as fallback with 45s timeout
- Increase QWEN timeout to 35s, max_tokens to 4000
- Add conversation history loading from whatsapp_messages (last 4 msgs)
- Persist detected vehicle in whatsapp_sessions table
- Add 'limpiar chat' / 'nuevo chat' / 'reset' commands to clear history
- Fix CSS conflict: rename whatsapp chat-panel classes to wa-chat-panel
- Fix JS ID conflicts with chat.js widget (waChatPanel, waChatMessages, etc.)
- Improve no-stock response: conversational with alternatives
- Split search_query by | for multi-part lookups
- Add DEMO_PROMPTS.md and DEMO_PROMPTS_V2.md
This commit is contained in:
2026-05-06 20:27:14 +00:00
parent 371d72887e
commit ff45905b49
33 changed files with 3040 additions and 445 deletions

View File

@@ -4,6 +4,9 @@
<script>/*pos_theme_early*/(function(){var t=localStorage.getItem("pos_theme")||"industrial";document.documentElement.setAttribute("data-theme",t);})()</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>WhatsApp — Nexus Autoparts POS</title>
<link rel="stylesheet" href="/pos/static/css/chat.css" />
<link rel="stylesheet" href="/pos/static/css/tokens.css" />
@@ -89,10 +92,11 @@
<div class="empty-state__hint">Los mensajes de WhatsApp aparecen aqui en tiempo real</div>
</div>
<div class="chat-panel" id="chatPanel" style="display:none">
<div class="chat-panel__header">
<span class="chat-panel__phone" id="chatHeaderPhone"></span>
<div class="chat-panel__actions">
<div class="wa-chat-panel" id="waChatPanel" style="display:none">
<div class="wa-chat-panel__header">
<button class="btn btn--sm" id="backToListBtn" style="display:none;margin-right:8px;">&larr; Volver</button>
<span class="wa-chat-panel__phone" id="chatHeaderPhone"></span>
<div class="wa-chat-panel__actions">
<button class="btn btn--sm" id="sendQuoteBtn" title="Enviar cotizacion por WhatsApp">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/>
@@ -102,11 +106,11 @@
</div>
</div>
<div class="chat-panel__messages" id="chatMessages"></div>
<div class="wa-chat-panel__messages" id="waChatMessages"></div>
<div class="chat-input-bar">
<textarea id="chatInput" placeholder="Escribe un mensaje..." rows="1"></textarea>
<button class="btn btn--primary" id="sendBtn">
<textarea id="waChatInput" placeholder="Escribe un mensaje..." rows="1"></textarea>
<button class="btn btn--primary" id="waSendBtn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>
</svg>
@@ -127,7 +131,7 @@ function posLogout(){localStorage.removeItem('pos_token');window.location.href='
<!-- Sidebar -->
<script src="/pos/static/js/i18n.js" defer></script>
<script src="/pos/static/js/whatsapp.js" defer></script>
<script src="/pos/static/js/whatsapp2.js" defer></script>
<script src="/pos/static/js/pos-utils.js" defer></script>
<script src="/pos/static/js/sidebar.js" defer></script>