Spaces:
Running
Running
add support for new lines in assistant's response and mark down in asssistant's response - Follow Up Deployment
Browse files71 unmodified lines727374757677435 unmodified lines5135145155165175185197 unmodified lines527528529530531532533204 unmodified lines73873974074174274374471 unmodified lines.transition-all {transition: all 0.3s ease;}</style></head><body class="bg-gray-50 dark:bg-dark-900 text-gray-800 dark:text-gray-200 min-h-screen">435 unmodified lines<i class="fas fa-robot"></i></div><div class="max-w-[80%] bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm relative group"><div class="prose dark:prose-invert">${msg.content}</div><div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1"><button class="message-action bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 p-1 rounded text-gray-700 dark:text-gray-300" data-action="regenerate" title="Regenerate"><i class="fas fa-sync-alt text-xs"></i>7 unmodified lines} else {messageElement.innerHTML = `<div class="max-w-[80%] bg-primary-500 text-white rounded-lg p-4 shadow-sm relative group"><div class="prose prose-white">${msg.content}</div><div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity"><button class="message-action bg-primary-600 hover:bg-primary-700 p-1 rounded text-white" data-action="edit" title="Edit"><i class="fas fa-edit text-xs"></i>204 unmodified linesconst parsed = JSON.parse(data);const content = parsed.choices?.[0]?.delta?.content || '';result += content;contentElement.innerHTML = result;chatArea.scrollTop = chatArea.scrollHeight;} catch (e) {console.error('Error parsing stream data:', e);71 unmodified lines7273747576777879808182838485868788435 unmodified lines5245255265275285295307 unmodified lines538539540541542543544204 unmodified lines74975075175275375475575675775875976071 unmodified lines.transition-all {transition: all 0.3s ease;}/* Code block styling */.prose code {background-color: rgba(0,0,0,0.1);padding: 0.2em 0.4em;border-radius: 0.25em;font-family: monospace;}.dark .prose code {background-color: rgba(255,255,255,0.1);}</style></head><body class="bg-gray-50 dark:bg-dark-900 text-gray-800 dark:text-gray-200 min-h-screen">435 unmodified lines<i class="fas fa-robot"></i></div><div class="max-w-[80%] bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm relative group"><div class="prose dark:prose-invert whitespace-pre-wrap">${msg.content.replace(/\n/g, '<br>')}</div><div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1"><button class="message-action bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 p-1 rounded text-gray-700 dark:text-gray-300" data-action="regenerate" title="Regenerate"><i class="fas fa-sync-alt text-xs"></i>7 unmodified lines} else {messageElement.innerHTML = `<div class="max-w-[80%] bg-primary-500 text-white rounded-lg p-4 shadow-sm relative group"><div class="prose prose-white whitespace-pre-wrap">${msg.content.replace(/\n/g, '<br>')}</div><div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity"><button class="message-action bg-primary-600 hover:bg-primary-700 p-1 rounded text-white" data-action="edit" title="Edit"><i class="fas fa-edit text-xs"></i>204 unmodified linesconst parsed = JSON.parse(data);const content = parsed.choices?.[0]?.delta?.content || '';result += content;// Replace newlines with <br> and preserve markdown formattingcontentElement.innerHTML = result.replace(/\n/g, '<br>').replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>').replace(/\*(.*?)\*/g, '<em>$1</em>').replace(/`(.*?)`/g, '<code>$1</code>');chatArea.scrollTop = chatArea.scrollHeight;} catch (e) {console.error('Error parsing stream data:', e);
index.html+19-3