Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
| chiedi_a_claude [2025/08/11 06:39] – neoadmin | chiedi_a_claude [2025/08/25 17:09] (versione attuale) – neoadmin | ||
|---|---|---|---|
| Linea 3: | Linea 3: | ||
| <meta charset=" | <meta charset=" | ||
| <meta name=" | <meta name=" | ||
| - | < | + | < |
| + | <script src=" | ||
| < | < | ||
| - | | + | |
| - | | + | |
| - | max-width: 1200px; | + | |
| - | margin: 0 auto; | + | |
| - | padding: 20px; | + | |
| - | background-color: #f8f9fa; | + | |
| } | } | ||
| - | | + | @keyframes |
| - | .claude-container { | + | |
| - | background: white; | + | |
| - | border-radius: | + | |
| - | padding: 25px; | + | |
| - | box-shadow: 0 4px 12px rgba(0, | + | |
| - | margin-bottom: | + | |
| - | } | + | |
| - | + | ||
| - | .header { | + | |
| - | text-align: center; | + | |
| - | margin-bottom: | + | |
| - | } | + | |
| - | + | ||
| - | .header h1 { | + | |
| - | color: #2c3e50; | + | |
| - | margin: 0; | + | |
| - | font-size: 2.5em; | + | |
| - | } | + | |
| - | + | ||
| - | .header p { | + | |
| - | color: #7f8c8d; | + | |
| - | margin: 10px 0 0 0; | + | |
| - | font-size: 1.1em; | + | |
| - | } | + | |
| - | + | ||
| - | .input-section { | + | |
| - | margin-bottom: | + | |
| - | } | + | |
| - | + | ||
| - | .question-input { | + | |
| - | width: 100%; | + | |
| - | padding: 15px; | + | |
| - | font-size: 16px; | + | |
| - | border: 2px solid #e1e8ed; | + | |
| - | border-radius: | + | |
| - | box-sizing: border-box; | + | |
| - | transition: border-color 0.3s ease; | + | |
| - | } | + | |
| - | + | ||
| - | .question-input: | + | |
| - | outline: none; | + | |
| - | border-color: | + | |
| - | box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.1); | + | |
| - | } | + | |
| - | + | ||
| - | .button-group { | + | |
| - | display: flex; | + | |
| - | gap: 10px; | + | |
| - | margin-top: 15px; | + | |
| - | flex-wrap: wrap; | + | |
| - | } | + | |
| - | + | ||
| - | .btn { | + | |
| - | padding: 12px 24px; | + | |
| - | border: none; | + | |
| - | border-radius: | + | |
| - | font-size: 14px; | + | |
| - | font-weight: | + | |
| - | cursor: pointer; | + | |
| - | transition: all 0.3s ease; | + | |
| - | display: flex; | + | |
| - | align-items: | + | |
| - | gap: 8px; | + | |
| - | } | + | |
| - | + | ||
| - | .btn-primary { | + | |
| - | background: #007acc; | + | |
| - | color: white; | + | |
| - | } | + | |
| - | + | ||
| - | .btn-primary: | + | |
| - | background: #005fa3; | + | |
| - | transform: translateY(-1px); | + | |
| - | } | + | |
| - | + | ||
| - | .btn-secondary { | + | |
| - | background: #6c757d; | + | |
| - | color: white; | + | |
| - | } | + | |
| - | + | ||
| - | .btn-secondary: | + | |
| - | background: #545b62; | + | |
| - | } | + | |
| - | + | ||
| - | .btn: | + | |
| - | background: #ccc; | + | |
| - | cursor: not-allowed; | + | |
| - | transform: none; | + | |
| - | } | + | |
| - | + | ||
| - | .status { | + | |
| - | margin: 20px 0; | + | |
| - | padding: 15px; | + | |
| - | border-radius: | + | |
| - | display: none; | + | |
| - | } | + | |
| - | + | ||
| - | .status.loading { | + | |
| - | background: #e3f2fd; | + | |
| - | color: #1565c0; | + | |
| - | border-left: | + | |
| - | } | + | |
| - | + | ||
| - | .status.error { | + | |
| - | background: #ffebee; | + | |
| - | color: #c62828; | + | |
| - | border-left: | + | |
| - | } | + | |
| - | + | ||
| - | .status.info { | + | |
| - | background: #e8f5e8; | + | |
| - | color: #2d5a2d; | + | |
| - | border-left: | + | |
| - | } | + | |
| - | + | ||
| - | .answer-section { | + | |
| - | margin-top: 25px; | + | |
| - | } | + | |
| - | + | ||
| - | .answer-box { | + | |
| - | background: #f8f9fa; | + | |
| - | border: 1px solid #e9ecef; | + | |
| - | border-radius: | + | |
| - | padding: 20px; | + | |
| - | min-height: 100px; | + | |
| - | line-height: | + | |
| - | display: none; | + | |
| - | } | + | |
| - | + | ||
| - | .answer-box.show { | + | |
| - | display: block; | + | |
| - | animation: fadeIn 0.5s ease; | + | |
| - | } | + | |
| - | + | ||
| - | | + | |
| from { opacity: 0; transform: translateY(10px); | from { opacity: 0; transform: translateY(10px); | ||
| to { opacity: 1; transform: translateY(0); | to { opacity: 1; transform: translateY(0); | ||
| } | } | ||
| - | | + | .typing-indicator |
| - | | + | |
| - | | + | |
| - | padding-top: 25px; | + | |
| - | border-top: 2px solid #e9ecef; | + | |
| } | } | ||
| - | | + | |
| - | .config-grid | + | |
| - | | + | |
| - | grid-template-columns: | + | |
| - | gap: 20px; | + | |
| - | } | + | |
| - | + | ||
| - | .config-item | + | |
| - | display: flex; | + | |
| - | flex-direction: | + | |
| - | gap: 8px; | + | |
| - | } | + | |
| - | + | ||
| - | .config-item label { | + | |
| - | font-weight: | + | |
| - | color: #495057; | + | |
| - | } | + | |
| - | + | ||
| - | .config-item input, .config-item select { | + | |
| - | padding: 10px; | + | |
| - | border: 1px solid #ced4da; | + | |
| - | border-radius: | + | |
| - | font-size: 14px; | + | |
| - | } | + | |
| - | + | ||
| - | .examples { | + | |
| - | background: #e8f5e8; | + | |
| - | border-radius: | + | |
| - | padding: 20px; | + | |
| - | margin-top: 20px; | + | |
| - | } | + | |
| - | + | ||
| - | .examples h3 { | + | |
| - | margin: 0 0 15px 0; | + | |
| - | color: #2d5a2d; | + | |
| - | } | + | |
| - | + | ||
| - | | + | |
| - | display: flex; | + | |
| - | flex-wrap: wrap; | + | |
| - | gap: 10px; | + | |
| - | | + | |
| - | + | ||
| - | .example-btn { | + | |
| - | | + | |
| - | border: 1px solid #28a745; | + | |
| - | color: #28a745; | + | |
| - | padding: 8px 12px; | + | |
| - | border-radius: | + | |
| - | font-size: 12px; | + | |
| - | cursor: pointer; | + | |
| - | transition: all 0.3s ease; | + | |
| - | } | + | |
| - | + | ||
| - | .example-btn: | + | |
| - | background: #28a745; | + | |
| - | color: white; | + | |
| - | } | + | |
| - | + | ||
| - | .footer { | + | |
| - | text-align: center; | + | |
| - | margin-top: 40px; | + | |
| - | padding: 20px; | + | |
| - | color: #6c757d; | + | |
| - | font-size: 14px; | + | |
| - | } | + | |
| - | + | ||
| - | .info-box { | + | |
| - | margin-bottom: | + | |
| - | padding: 15px; | + | |
| - | background: #fff3cd; | + | |
| - | border-radius: | + | |
| - | border-left: | + | |
| - | } | + | |
| - | + | ||
| - | @media (max-width: 768px) { | + | |
| - | body { | + | |
| - | padding: 10px; | + | |
| - | } | + | |
| - | + | ||
| - | .claude-container { | + | |
| - | padding: 15px; | + | |
| - | } | + | |
| - | + | ||
| - | .header h1 { | + | |
| - | font-size: 2em; | + | |
| - | } | + | |
| - | + | ||
| - | .button-group { | + | |
| - | flex-direction: | + | |
| - | } | + | |
| - | + | ||
| - | .btn { | + | |
| - | justify-content: | + | |
| - | | + | |
| } | } | ||
| </ | </ | ||
| </ | </ | ||
| - | <body> | + | <body class=" |
| - | < | + | <!-- Header --> |
| - | <div class=" | + | <div class=" |
| - | < | + | <div class=" |
| - | < | + | <div class=" |
| - | </ | + | <svg class=" |
| - | + | <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/> | |
| - | | + | </svg> |
| - | <textarea | + | |
| - | id=" | + | |
| - | | + | |
| - | placeholder=" | + | |
| - | rows="3" | + | |
| - | ></ | + | |
| - | | + | |
| - | <div class=" | + | |
| - | <button | + | |
| - | < | + | |
| - | </ | + | |
| - | <button class="btn btn-secondary" | + | |
| - | <span> | + | |
| - | </ | + | |
| - | <button class="btn btn-secondary" | + | |
| - | < | + | |
| - | </button> | + | |
| </ | </ | ||
| - | | + | |
| - | + | <h1 class=" | |
| - | | + | <p class=" |
| - | + | <svg class="h-4 w-4 mr-1" | |
| - | | + | <path stroke-linecap=" |
| - | <div id="answerBox" | + | </ |
| - | <strong> | + | Fonte: " |
| + | | ||
| </ | </ | ||
| </ | </ | ||
| - | | + | </ |
| - | <div class=" | + | |
| - | <h3>💡 Esempi di domande per DocuNeo:</ | + | <!-- Messages Container --> |
| - | <div class=" | + | <div id=" |
| - | <span class=" | + | <!-- Messages will be inserted here --> |
| - | <span class=" | + | </div> |
| - | <span class=" | + | |
| - | <span class=" | + | <!-- Quick Questions (shown initially) --> |
| - | <span class=" | + | <div id=" |
| + | <div class=" | ||
| + | < | ||
| + | <svg class=" | ||
| + | <path stroke-linecap=" | ||
| + | </ | ||
| + | Domande rapide: | ||
| + | | ||
| + | <div class=" | ||
| + | <button | ||
| + | <button | ||
| + | <button onclick=" | ||
| + | < | ||
| + | <button onclick=" | ||
| + | < | ||
| + | <button onclick=" | ||
| + | < | ||
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||
| - | | + | |
| - | <div class=" | + | <!-- Input Area --> |
| - | < | + | <div class=" |
| - | | + | <div class=" |
| - | <div class=" | + | <textarea |
| - | <h4 style="margin: 0 0 10px 0; color: #856404;">🔧 Come iniziare</h4> | + | id="message-input" |
| - | <p style="margin: 0; font-size: 13px; color: #856404;"> | + | placeholder=" |
| - | | + | class=" |
| - | | + | rows=" |
| - | 3. Fai una domanda sui protocolli neonatali | + | onkeydown=" |
| - | </p> | + | |
| + | <button | ||
| + | id="send-button" | ||
| + | onclick=" | ||
| + | class=" | ||
| + | | ||
| + | | ||
| + | | ||
| + | </svg> | ||
| + | </button> | ||
| </ | </ | ||
| - | | + | <div class=" |
| - | | + | <svg class=" |
| - | <div class=" | + | <path stroke-linecap="round" |
| - | <label for=" | + | </svg> |
| - | <input type=" | + | |
| - | </div> | + | |
| - | < | + | |
| - | <label for=" | + | |
| - | <select id=" | + | |
| - | <option value=" | + | |
| - | <option value=" | + | |
| - | <option value="claude-3-haiku-20240307">Claude 3 Haiku</ | + | |
| - | </ | + | |
| - | </ | + | |
| - | <div class="config-item"> | + | |
| - | <label for="maxTokens">Max Token Risposta:</ | + | |
| - | <input type="number" | + | |
| - | </div> | + | |
| - | | + | |
| - | <label for=" | + | |
| - | <input type=" | + | |
| - | | + | |
| </ | </ | ||
| </ | </ | ||
| - | | + | |
| - | <div class=" | + | <style> |
| - | | + | .quick-btn { |
| - | <p style=" | + | |
| - | 🏥 Sistema di gestione documenti per Terapia Intensiva Neonatale | + | |
| - | | + | </style> |
| - | </div> | + | |
| < | < | ||
| - | // Variabili globali | + | // Knowledge Base dal documento |
| - | | + | |
| - | let isProcessing = false; | + | |
| - | + | | |
| - | // Inizializzazione | + | |
| - | | + | }, |
| - | | + | ' |
| - | + | keywords: [' | |
| - | // Controlla se abbiamo contenuti in cache | + | response: ' |
| - | | + | |
| - | | + | |
| - | } else { | + | keywords: [' |
| - | | + | response: 'La prognosi dipende da diversi fattori. Con il fegato nativo, la sopravvivenza a 10 anni è del 30-50%. Tuttavia, considerando anche i trapianti, la sopravvivenza globale supera il 90%. I fattori prognostici favorevoli includono: età al Kasai <60 giorni, clearance dell\' |
| + | | ||
| + | ' | ||
| + | keywords: [' | ||
| + | response: 'Il documento descrive due classificazioni principali: | ||
| + | | ||
| + | ' | ||
| + | keywords: [' | ||
| + | response: 'I segni clinici tipici dell\' | ||
| + | }, | ||
| + | ' | ||
| + | | ||
| + | response: 'La diagnosi si basa su un approccio multimodale: | ||
| + | }, | ||
| + | | ||
| + | keywords: [' | ||
| + | response: 'La procedura di Kasai (portoenterostomia) è il trattamento standard: | ||
| + | }, | ||
| + | ' | ||
| + | | ||
| + | response: 'Il trapianto di fegato è indicato in caso di:\\n- **Fallimento primario** della procedura di Kasai\\n- **Deterioramento della funzione epatica** nonostante successo iniziale del Kasai\\n- **PELD Score >15-20** (pediatric end-stage liver disease)\\n- **Complicanze della cirrosi:** ascite refrattaria, | ||
| + | }, | ||
| + | | ||
| + | keywords: [' | ||
| + | response: 'La sindrome BASM è presente nel 10-20% dei casi di atresia biliare e include: | ||
| } | } | ||
| - | setTimeout(hideStatus, | ||
| }; | }; | ||
| - | | + | |
| - | | + | |
| - | function | + | |
| - | const config | + | function |
| - | apiKey: document.getElementById(' | + | const input = userInput.toLowerCase(); |
| - | | + | |
| - | | + | let bestMatch = null; |
| - | contextLimit: | + | |
| - | | + | |
| - | Object.keys(config).forEach(key => { | + | Object.entries(knowledgeBase).forEach(([key, data]) |
| - | | + | |
| - | | + | data.keywords.forEach(keyword => { |
| + | | ||
| + | score += keyword.length; | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | if (score > bestScore) { | ||
| + | bestScore = score; | ||
| + | bestMatch = data.response; | ||
| } | } | ||
| }); | }); | ||
| - | } | + | |
| - | + | | |
| - | function loadConfig() { | + | if (input.includes('età') || input.includes('bambini') || input.includes('neonati')) { |
| - | ['apiKey', 'claudeModel', ' | + | |
| - | const stored = localStorage.getItem('claude_' | + | |
| - | if (stored) { | + | |
| - | | + | |
| } | } | ||
| - | }); | + | |
| - | } | + | |
| - | + | | |
| - | // Funzioni interfaccia | + | } |
| - | function setQuestion(question) { | + | |
| - | document.getElementById('questionInput').value = question; | + | |
| - | document.getElementById('questionInput').focus(); | + | } |
| - | } | + | |
| - | + | ||
| - | function clearAll() { | + | |
| - | document.getElementById('questionInput').value = ''; | + | |
| - | hideAnswer(); | + | |
| - | hideStatus(); | + | |
| - | } | + | |
| - | + | ||
| - | function showStatus(message, | + | |
| - | const status = document.getElementById('status'); | + | |
| - | status.textContent = message; | + | |
| - | status.className = `status ${type}`; | + | |
| - | status.style.display = ' | + | |
| - | } | + | |
| - | + | ||
| - | function hideStatus() { | + | |
| - | document.getElementById(' | + | |
| - | } | + | |
| - | + | ||
| - | | + | |
| - | const answerBox = document.getElementById('answerBox' | + | |
| - | answerBox.innerHTML = content; | + | |
| - | answerBox.classList.add('show'); | + | |
| - | } | + | |
| - | + | ||
| - | function hideAnswer() { | + | |
| - | | + | |
| - | answerBox.classList.remove(' | + | |
| - | | + | |
| - | + | ||
| - | // Modalità offline - carica contenuti base DocuNeo | + | |
| - | function useOfflineMode() { | + | |
| - | if (isProcessing) return; | + | |
| | | ||
| - | | + | |
| - | wikiContent = getPreExtractedContent(); | + | |
| - | + | ||
| - | // Salva in cache | + | |
| - | localStorage.setItem(' | + | |
| - | localStorage.setItem(' | + | |
| - | + | ||
| - | showStatus(`✅ Contenuti DocuNeo caricati! (${Math.round(wikiContent.length / 1000)}k caratteri)`, | + | |
| - | setTimeout(hideStatus, | + | |
| } | } | ||
| - | | ||
| - | // Contenuto pre-estratto da DocuNeo | ||
| - | function getPreExtractedContent() { | ||
| - | return ` | ||
| - | === DocuNeo - Sistema di Gestione Documenti Neonatali === | ||
| - | DocuNeo è il sistema di gestione dei documenti di reparto per la Terapia Intensiva Neonatale. | + | function addMessage(type, content) { |
| - | Include linee guida, percorsi diagnostico-terapeutici | + | const timestamp = new Date(); |
| + | messages.push({ type, content, timestamp }); | ||
| + | renderMessages(); | ||
| + | scrollToBottom(); | ||
| + | } | ||
| - | ## AREE PRINCIPALI: | + | function renderMessages() { |
| + | const container = document.getElementById(' | ||
| + | container.innerHTML = ''; | ||
| - | ### DOLORE | + | messages.forEach((message, |
| - | - Indicazioni operative per il trattamento del dolore nel neonato | + | const messageDiv = document.createElement(' |
| - | - Approccio pratico al controllo del dolore da procedura | + | messageDiv.className = `flex ${message.type === ' |
| - | - Gestione farmacologica e non farmacologica del dolore neonatale | + | |
| + | messageDiv.innerHTML = ` | ||
| + | <div class=" | ||
| + | < | ||
| + | ${message.type === ' | ||
| + | '< | ||
| + | '< | ||
| + | } | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | ${message.timestamp.toLocaleTimeString(' | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | `; | ||
| + | |||
| + | container.appendChild(messageDiv); | ||
| + | }); | ||
| + | } | ||
| - | ### EMATOLOGIA | + | function scrollToBottom() { |
| - | - Guida alla trasfusione dei concentrati piastrinici nel neonato | + | const container = document.getElementById(' |
| - | - Profilassi malattia emorragica nel neonato con vitamina K | + | |
| - | - Spremitura del funicolo per la prevenzione dell' | + | } |
| - | - Gestione dell' | + | |
| - | ### GASTROENTEROLOGIA | + | |
| - | - Modalità di esecuzione del test di Apt per sangue nelle feci | + | const input = document.getElementById('message-input'); |
| - | - Linee guida per la gestione della NEC (Enterocolite Necrotizzante) | + | const value = input.value.trim(); |
| - | - Valutazione ecografica della NEC e staging radiologico | + | |
| - | - Linee guida ESPGHAN e NASPGHAN per la gestione del Reflusso gastroesofageo | + | |
| - | - Gestione nutrizionale post-NEC | + | |
| - | + | ||
| - | ### INFEZIONI | + | |
| - | - Infezione perinatale da streptococco: | + | |
| - | - Linee guida per la terapia della sepsi e delle infezioni in epoca neonatale | + | |
| - | - Infezione congenita da Cytomegalovirus: | + | |
| - | - Infezioni ed esposizione in gravidanza a CMV, HSV, VZ, sifilide | + | |
| - | - Infezioni materne ed allattamento: | + | |
| - | - Profilassi della trasmissione perinatale dell' | + | |
| - | - Gestione infezioni correlate a dispositivi vascolari | + | |
| - | + | ||
| - | ### MALATTIE METABOLICHE E IPOGLICEMIA | + | |
| - | - Ipoglicemia neonatale: definizione, | + | |
| - | - Algoritmo per la gestione dell' | + | |
| - | - Linee Guida per la diagnosi ed il trattamento dei difetti del ciclo dell' | + | |
| - | - Inquadramento delle malattie metaboliche ad esordio neonatale | + | |
| - | - Screening metabolico allargato e follow-up | + | |
| - | + | ||
| - | ### NUTRIZIONE E ALLATTAMENTO | + | |
| - | - Linee guida per la nutrizione e l' | + | |
| - | - Schema operativo per la determinazione dei fabbisogni di liquidi e nutrienti | + | |
| - | - Alimentazione per il neonato con rischio atopia | + | |
| - | - Linee guida per la profilassi dell' | + | |
| - | - Procedure per il sostegno dell' | + | |
| - | - Gestione della Banca del Latte umano donato | + | |
| - | - Composizione dei latti in formula e indicazioni d' | + | |
| - | + | ||
| - | ### NEFRO-UROLOGIA | + | |
| - | - Indicazioni all' | + | |
| - | - Nefrocalcinosi e nefrolitasi nel pretermine: prevenzione e trattamento | + | |
| - | - Linee guida per la gestione dell' | + | |
| - | - Gestione della trombosi della vena renale | + | |
| - | + | ||
| - | ### PATOLOGIA NEUROLOGICA | + | |
| - | - PDT Trattamento dell' | + | |
| - | - Convulsioni neonatali: diagnosi differenziale e trattamento | + | |
| - | - Programma diagnostico-terapeutico per mielomeningocele | + | |
| - | - Protocollo per la dilatazione ventricolare postemorragica | + | |
| - | - Indicazioni all' | + | |
| - | - Follow-up neurosviluppo nel pretermine | + | |
| - | + | ||
| - | ### PATOLOGIA RESPIRATORIA | + | |
| - | - Standard Clinico per la gestione del neonato con sindrome da distress respiratorio (RDS) | + | |
| - | - Parametri di ossimetria pulsatile e target di saturazione | + | |
| - | - Indicazioni all' | + | |
| - | - Premedicazione per intubazione tracheale: protocollo sedazione | + | |
| - | - Ipertensione polmonare nel neonato: diagnosi e terapia | + | |
| - | - Utilizzo dell' | + | |
| - | - Ventilazione non invasiva: CPAP e BiPAP | + | |
| - | - Modalità di ventilazione a volume garantito | + | |
| - | - Gestione dello svezzamento ventilatorio | + | |
| - | + | ||
| - | ### PATOLOGIA CARDIOCIRCOLATORIA | + | |
| - | - Terapia di supporto cardiovascolare: | + | |
| - | - Gestione del dotto arterioso pervio (PDA) | + | |
| - | - Screening cardiopatie congenite con ecocardiografia | + | |
| - | - Gestione dell' | + | |
| - | + | ||
| - | ### RIANIMAZIONE E URGENZE | + | |
| - | - Linee guida per la rianimazione neonatale (ERC Guidelines) | + | |
| - | - Algoritmi di rianimazione in sala parto | + | |
| - | - Gestione delle emergenze respiratorie e cardiocircolatorie | + | |
| - | - Protocolli per il trasporto neonatale d' | + | |
| - | + | ||
| - | ### FOLLOW-UP E DIMISSIONI | + | |
| - | - Criteri di dimissione dal reparto di Terapia Intensiva | + | |
| - | - Programmi di follow-up per il neonato pretermine | + | |
| - | - Vaccinazioni nel pretermine: calendario e controindicazioni | + | |
| - | - Screening sensoriali: vista e udito | + | |
| - | + | ||
| - | Questo sistema fornisce protocolli evidence-based per la gestione clinica completa in Terapia Intensiva Neonatale, basati su linee guida internazionali e consensi di esperti. | + | |
| - | `.trim(); | + | |
| - | } | + | |
| - | + | ||
| - | // Verifica contenuti in cache | + | |
| - | | + | |
| - | const cached | + | |
| - | const timestamp | + | |
| | | ||
| - | if (cached && timestamp) { | + | if (!value) return; |
| - | const cacheAge = Date.now() - parseInt(timestamp); | + | |
| - | const maxAge = 24 * 60 * 60 * 1000; // 24 ore | + | |
| - | + | ||
| - | if (cacheAge < maxAge) { | + | |
| - | wikiContent = cached; | + | |
| - | | + | |
| - | } | + | |
| - | } | + | |
| - | return false; | + | |
| - | } | + | |
| - | + | ||
| - | // Funzione principale | + | |
| - | async function askClaude() { | + | |
| - | if (isProcessing) return; | + | |
| - | + | ||
| - | const question = document.getElementById(' | + | |
| - | const apiKey = document.getElementById(' | + | |
| | | ||
| - | if (!question) { | + | |
| - | | + | |
| - | return; | + | |
| } | } | ||
| | | ||
| - | | + | |
| - | alert('⚠️ Inserisci la tua API Key Anthropic nella configurazione!'); | + | |
| - | | + | |
| - | } | + | |
| | | ||
| - | | + | |
| - | alert(' | + | |
| - | return; | + | |
| - | } | + | |
| | | ||
| - | | + | |
| - | | + | |
| - | + | | |
| - | try { | + | const response = findBestResponse(value); |
| - | | + | |
| - | | + | }, 1000 + Math.random() * 1000); |
| - | const response = await callClaudeAPI(question, wikiContent); | + | |
| - | | + | |
| - | hideStatus(); | + | |
| - | showAnswer(response); | + | |
| - | | + | |
| - | } catch (error) { | + | |
| - | console.error(' | + | |
| - | showStatus(' | + | |
| - | setTimeout(hideStatus, 5000); | + | |
| - | } finally { | + | |
| - | isProcessing = false; | + | |
| - | } | + | |
| } | } | ||
| - | | ||
| - | // Chiamata API Claude | ||
| - | async function callClaudeAPI(question, | ||
| - | const apiKey = document.getElementById(' | ||
| - | const model = document.getElementById(' | ||
| - | const maxTokens = parseInt(document.getElementById(' | ||
| - | const contextLimit = parseInt(document.getElementById(' | ||
| - | | ||
| - | // Limita il contesto | ||
| - | const limitedContext = context.substring(0, | ||
| - | | ||
| - | const prompt = `Sei un assistente specializzato in neonatologia che risponde domande basandosi ESCLUSIVAMENTE sui contenuti del sito DocuNeo.org. Non usare conoscenze esterne. | ||
| - | CONTENUTI DEL SITO DOCUNEO: | + | function askQuestion(question) |
| - | ${limitedContext} | + | document.getElementById(' |
| + | sendMessage(); | ||
| + | | ||
| - | DOMANDA: ${question} | + | function handleKeyPress(event) |
| + | if (event.key === ' | ||
| + | event.preventDefault(); | ||
| + | sendMessage(); | ||
| + | } | ||
| + | | ||
| - | Rispondi basandoti SOLO sui contenuti sopra provenienti da DocuNeo.org. Se la risposta non è presente nei contenuti forniti, dì che l'informazione non è disponibile nel sito DocuNeo. | + | function showTypingIndicator() { |
| + | const container = document.getElementById(' | ||
| + | const typingDiv = document.createElement('div' | ||
| + | typingDiv.id = ' | ||
| + | typingDiv.className = 'flex justify-start'; | ||
| + | typingDiv.innerHTML = ` | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <svg class=" | ||
| + | <path stroke-linecap=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | `; | ||
| + | container.appendChild(typingDiv); | ||
| + | scrollToBottom(); | ||
| + | } | ||
| - | Quando possibile, cita le sezioni specifiche | + | function hideTypingIndicator() { |
| - | + | const indicator | |
| - | Formatta la risposta in HTML per una migliore leggibilità, | + | if (indicator) { |
| - | - <h3> per i titoli principali | + | |
| - | - <ul> e <li> per le liste | + | |
| - | - < | + | |
| - | - <em> per le citazioni delle fonti`; | + | |
| - | + | ||
| - | const response | + | |
| - | method: ' | + | |
| - | headers: { | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | }, | + | |
| - | body: JSON.stringify({ | + | |
| - | model: model, | + | |
| - | max_tokens: maxTokens, | + | |
| - | messages: [{ | + | |
| - | role: ' | + | |
| - | content: prompt | + | |
| - | }] | + | |
| - | }) | + | |
| - | }); | + | |
| - | | + | |
| - | if (!response.ok) { | + | |
| - | | + | |
| - | throw new Error(`API Error ${response.status}: | + | |
| } | } | ||
| - | | ||
| - | const data = await response.json(); | ||
| - | | ||
| - | if (!data.content || !data.content[0] || !data.content[0].text) { | ||
| - | throw new Error(' | ||
| - | } | ||
| - | | ||
| - | return data.content[0].text; | ||
| } | } | ||
| - | | + | |
| - | // Eventi tastiera | + | // Initialize with welcome message |
| - | | + | |
| - | | + | |
| - | askClaude(); | + | }; |
| - | } | + | |
| - | }); | + | |
| - | + | ||
| - | // Auto-save configurazione | + | |
| - | [' | + | |
| - | document.getElementById(id).addEventListener('change', | + | |
| - | }); | + | |
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||