Widget:ChatBox: Unterschied zwischen den Versionen

Aus MediaWiki
Wechseln zu:Navigation, Suche
Create ChatBox widget for multi-turn RAG chat
 
Fix source list rendering: match API fields (score/url/content)
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 313: Zeile 313:
     html += '<div class="chat-sources-list" id="' + listId + '">';
     html += '<div class="chat-sources-list" id="' + listId + '">';
     sources.forEach(function(s) {
     sources.forEach(function(s) {
       var pct = Math.round((s.similarity_score || 0) * 100);
       var pct = Math.round((s.score || 0) * 100);
       var wikiUrl = '/wiki/' + encodeURIComponent((s.page_title || '').replace(/ /g, '_'));
       var url = s.url || '';
      var title = '';
      if (url) {
        var seg = url.split('/').pop();
        try { seg = decodeURIComponent(seg); } catch (e) {}
        title = seg.replace(/_/g, ' ');
      }
       html += '<div class="chat-source-item">'
       html += '<div class="chat-source-item">'
         + '<h5><a href="' + wikiUrl + '">' + escapeHtml(s.page_title || '') + '</a></h5>'
         + '<h5><a href="' + escapeHtml(url) + '">' + escapeHtml(title) + '</a></h5>'
         + '<p class="chat-source-snippet">' + escapeHtml(truncate(s.content_text || '', 150)) + '</p>'
         + '<p class="chat-source-snippet">' + escapeHtml(truncate(s.content || '', 150)) + '</p>'
         + '<div class="chat-source-meta">Relevanz: ' + pct + '% &middot; ' + escapeHtml(s.source || '') + '</div>'
         + '<div class="chat-source-meta">Relevanz: ' + pct + '% · ' + escapeHtml(s.source || '') + '</div>'
         + '</div>';
         + '</div>';
     });
     });
Zeile 339: Zeile 345:
     if (remaining > 0) {
     if (remaining > 0) {
       statusEl.textContent = remaining + ' R\u00fcckfrage' + (remaining !== 1 ? 'n' : '') + ' verbleibend';
       statusEl.textContent = remaining + ' R\u00fcckfrage' + (remaining !== 1 ? 'n' : '') + ' verbleibend';
     } else if (remaining === 0 && conversationId) {
     } else if (remaining === 0) { if (conversationId) {
       statusEl.textContent = 'Keine R\u00fcckfragen mehr m\u00f6glich';
       statusEl.textContent = 'Keine R\u00fcckfragen mehr m\u00f6glich';
       input.disabled = true;
       input.disabled = true;
       sendBtn.disabled = true;
       sendBtn.disabled = true;
       input.placeholder = 'Starte eine neue Unterhaltung';
       input.placeholder = 'Starte eine neue Unterhaltung';
     }
     } }
     newBtn.className = conversationId ? 'visible' : '';
     newBtn.className = conversationId ? 'visible' : '';
   }
   }

Aktuelle Version vom 16. Juni 2026, 11:30 Uhr