embeddings-1 #2

Merged
mstoeck3 merged 11 commits from embeddings-1 into main 2025-08-02 09:59:35 +00:00
3 changed files with 98788 additions and 98776 deletions
Showing only changes of commit c96aa70413 - Show all commits

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -497,15 +497,27 @@ document.addEventListener('DOMContentLoaded', () => {
}
function formatWorkflowSuggestion(text) {
// Type safety: ensure text is a string
if (!text || typeof text !== 'string') {
console.warn('[FORMAT] Invalid text input:', typeof text, text);
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">Inhalt nicht verfügbar</p>`;
}
// Sanitize and trim the text
const cleanText = text.trim();
if (cleanText.length === 0) {
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">Keine Informationen verfügbar</p>`;
}
// Improved handling for different list formats
const numberedListPattern = /(\d+\.\s)/g;
if (numberedListPattern.test(text)) {
const items = text.split(/\d+\.\s/).filter(item => item.trim().length > 0);
if (numberedListPattern.test(cleanText)) {
const items = cleanText.split(/\d+\.\s/).filter(item => item.trim().length > 0);
if (items.length > 1) {
const listItems = items.map(item =>
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${item.trim()}</li>`
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(item.trim())}</li>`
).join('');
return `<ol style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ol>`;
@ -514,12 +526,12 @@ document.addEventListener('DOMContentLoaded', () => {
// Handle bullet points
const bulletPattern = /^[\s]*[-\*•]\s/gm;
if (bulletPattern.test(text)) {
const items = text.split(/^[\s]*[-\*•]\s/gm).filter(item => item.trim().length > 0);
if (bulletPattern.test(cleanText)) {
const items = cleanText.split(/^[\s]*[-\*•]\s/gm).filter(item => item.trim().length > 0);
if (items.length > 1) {
const listItems = items.map(item =>
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${item.trim()}</li>`
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(item.trim())}</li>`
).join('');
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
@ -527,11 +539,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
// Handle line breaks as lists
if (text.includes('\n')) {
const lines = text.split('\n').filter(line => line.trim().length > 0);
if (cleanText.includes('\n')) {
const lines = cleanText.split('\n').filter(line => line.trim().length > 0);
if (lines.length > 1) {
const listItems = lines.map(line =>
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${line.trim()}</li>`
`<li style="margin-bottom: 0.5rem; line-height: 1.6;">${sanitizeHTML(line.trim())}</li>`
).join('');
return `<ul style="margin: 0; padding-left: 1.5rem; color: var(--color-text);">${listItems}</ul>`;
@ -539,7 +551,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
// Default paragraph formatting
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">${text}</p>`;
return `<p style="margin: 0; line-height: 1.6; color: var(--color-text);">${sanitizeHTML(cleanText)}</p>`;
}
function renderBackgroundKnowledge(backgroundKnowledge) {