in react typescript write deepseek or chatgpt like text stream
Browse files- README.md +8 -5
- index.html +255 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: MindMeld Streaminator 🤖
|
| 3 |
+
colorFrom: yellow
|
| 4 |
+
colorTo: yellow
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,256 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>MindMeld Streaminator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script>
|
| 11 |
+
tailwind.config = {
|
| 12 |
+
theme: {
|
| 13 |
+
extend: {
|
| 14 |
+
colors: {
|
| 15 |
+
primary: {
|
| 16 |
+
500: '#6366f1',
|
| 17 |
+
},
|
| 18 |
+
secondary: {
|
| 19 |
+
500: '#8b5cf6',
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
</script>
|
| 26 |
+
<style>
|
| 27 |
+
.typing-cursor {
|
| 28 |
+
display: inline-block;
|
| 29 |
+
width: 8px;
|
| 30 |
+
height: 24px;
|
| 31 |
+
background-color: currentColor;
|
| 32 |
+
animation: blink 1s infinite;
|
| 33 |
+
vertical-align: middle;
|
| 34 |
+
}
|
| 35 |
+
@keyframes blink {
|
| 36 |
+
0%, 100% { opacity: 1; }
|
| 37 |
+
50% { opacity: 0; }
|
| 38 |
+
}
|
| 39 |
+
.message-container {
|
| 40 |
+
max-height: 70vh;
|
| 41 |
+
overflow-y: auto;
|
| 42 |
+
scroll-behavior: smooth;
|
| 43 |
+
}
|
| 44 |
+
.gradient-bg {
|
| 45 |
+
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
| 46 |
+
}
|
| 47 |
+
</style>
|
| 48 |
+
</head>
|
| 49 |
+
<body class="bg-gray-50 dark:bg-gray-900 transition-colors duration-300">
|
| 50 |
+
<div class="min-h-screen flex flex-col">
|
| 51 |
+
<!-- Header -->
|
| 52 |
+
<header class="gradient-bg text-white p-4 shadow-lg">
|
| 53 |
+
<div class="container mx-auto flex items-center justify-between">
|
| 54 |
+
<div class="flex items-center space-x-2">
|
| 55 |
+
<i data-feather="cpu" class="w-6 h-6"></i>
|
| 56 |
+
<h1 class="text-xl font-bold">MindMeld Streaminator</h1>
|
| 57 |
+
</div>
|
| 58 |
+
<div class="flex items-center space-x-4">
|
| 59 |
+
<button id="themeToggle" class="p-2 rounded-full hover:bg-white/10 transition">
|
| 60 |
+
<i data-feather="moon" class="hidden dark:block w-5 h-5"></i>
|
| 61 |
+
<i data-feather="sun" class="block dark:hidden w-5 h-5"></i>
|
| 62 |
+
</button>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</header>
|
| 66 |
+
|
| 67 |
+
<!-- Main Content -->
|
| 68 |
+
<main class="flex-1 container mx-auto p-4 max-w-4xl">
|
| 69 |
+
<!-- Chat Display -->
|
| 70 |
+
<div id="messageContainer" class="message-container bg-white dark:bg-gray-800 rounded-lg shadow-lg p-4 mb-4">
|
| 71 |
+
<div class="message response flex mb-4">
|
| 72 |
+
<div class="flex-shrink-0 mr-3">
|
| 73 |
+
<div class="gradient-bg text-white rounded-full w-8 h-8 flex items-center justify-center">
|
| 74 |
+
<i data-feather="cpu" class="w-4 h-4"></i>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="flex-1">
|
| 78 |
+
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1">MindMeld Streaminator</div>
|
| 79 |
+
<div class="text-gray-800 dark:text-gray-200">
|
| 80 |
+
<div id="streamedText" class="whitespace-pre-wrap">
|
| 81 |
+
<span class="typing-cursor"></span>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
|
| 88 |
+
<!-- Input Area -->
|
| 89 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-4">
|
| 90 |
+
<div class="flex items-start space-x-2">
|
| 91 |
+
<div class="flex-1">
|
| 92 |
+
<textarea id="userInput" placeholder="Ask me anything..." class="w-full p-3 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-none" rows="3"></textarea>
|
| 93 |
+
</div>
|
| 94 |
+
<button id="sendButton" class="gradient-bg text-white p-3 rounded-lg hover:opacity-90 transition flex items-center justify-center">
|
| 95 |
+
<i data-feather="send" class="w-5 h-5"></i>
|
| 96 |
+
</button>
|
| 97 |
+
</div>
|
| 98 |
+
<div class="flex justify-between items-center mt-2 text-xs text-gray-500 dark:text-gray-400">
|
| 99 |
+
<div class="flex items-center space-x-2">
|
| 100 |
+
<button class="hover:text-primary-500 transition">
|
| 101 |
+
<i data-feather="mic" class="w-4 h-4"></i>
|
| 102 |
+
</button>
|
| 103 |
+
<button class="hover:text-primary-500 transition">
|
| 104 |
+
<i data-feather="image" class="w-4 h-4"></i>
|
| 105 |
+
</button>
|
| 106 |
+
</div>
|
| 107 |
+
<span>Press Shift+Enter for new line</span>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
</main>
|
| 111 |
+
|
| 112 |
+
<!-- Footer -->
|
| 113 |
+
<footer class="gradient-bg text-white p-4 text-center text-sm">
|
| 114 |
+
<p>© 2023 MindMeld Streaminator - AI Text Streaming Interface</p>
|
| 115 |
+
</footer>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<script>
|
| 119 |
+
feather.replace();
|
| 120 |
+
|
| 121 |
+
// Theme toggle
|
| 122 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 123 |
+
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
| 124 |
+
document.documentElement.classList.add('dark');
|
| 125 |
+
} else {
|
| 126 |
+
document.documentElement.classList.remove('dark');
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
themeToggle.addEventListener('click', () => {
|
| 130 |
+
document.documentElement.classList.toggle('dark');
|
| 131 |
+
localStorage.setItem('color-theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light');
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
// Simulate streaming text
|
| 135 |
+
const streamedText = document.getElementById('streamedText');
|
| 136 |
+
const sampleResponse = `Hello! I'm MindMeld Streaminator, your AI assistant.\n\nI can help you with:\n- Answering questions\n- Generating creative content\n- Analyzing data\n- And much more!\n\nWhat would you like to know today?`;
|
| 137 |
+
let currentIndex = 0;
|
| 138 |
+
const typingSpeed = 20; // milliseconds per character
|
| 139 |
+
|
| 140 |
+
function typeWriter() {
|
| 141 |
+
if (currentIndex < sampleResponse.length) {
|
| 142 |
+
const currentChar = sampleResponse.charAt(currentIndex);
|
| 143 |
+
if (currentChar === '\n') {
|
| 144 |
+
streamedText.innerHTML = streamedText.innerHTML.replace('<span class="typing-cursor"></span>', '<br><span class="typing-cursor"></span>');
|
| 145 |
+
} else {
|
| 146 |
+
streamedText.innerHTML = streamedText.innerHTML.replace('<span class="typing-cursor"></span>', currentChar + '<span class="typing-cursor"></span>');
|
| 147 |
+
}
|
| 148 |
+
currentIndex++;
|
| 149 |
+
setTimeout(typeWriter, typingSpeed);
|
| 150 |
+
|
| 151 |
+
// Auto-scroll to bottom
|
| 152 |
+
const container = document.getElementById('messageContainer');
|
| 153 |
+
container.scrollTop = container.scrollHeight;
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
// Start typing effect after page loads
|
| 158 |
+
setTimeout(typeWriter, 1000);
|
| 159 |
+
|
| 160 |
+
// Handle send button click
|
| 161 |
+
document.getElementById('sendButton').addEventListener('click', function() {
|
| 162 |
+
const userInput = document.getElementById('userInput').value.trim();
|
| 163 |
+
if (userInput) {
|
| 164 |
+
// Add user message to chat
|
| 165 |
+
const messageContainer = document.getElementById('messageContainer');
|
| 166 |
+
const userMessageDiv = document.createElement('div');
|
| 167 |
+
userMessageDiv.className = 'message user flex mb-4 justify-end';
|
| 168 |
+
userMessageDiv.innerHTML = `
|
| 169 |
+
<div class="flex-1 max-w-[90%]">
|
| 170 |
+
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1 text-right">You</div>
|
| 171 |
+
<div class="bg-primary-500 text-white rounded-lg p-3 inline-block">
|
| 172 |
+
${userInput}
|
| 173 |
+
</div>
|
| 174 |
+
</div>
|
| 175 |
+
<div class="flex-shrink-0 ml-3">
|
| 176 |
+
<div class="bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-gray-200 rounded-full w-8 h-8 flex items-center justify-center">
|
| 177 |
+
<i data-feather="user" class="w-4 h-4"></i>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
`;
|
| 181 |
+
messageContainer.appendChild(userMessageDiv);
|
| 182 |
+
|
| 183 |
+
// Clear input
|
| 184 |
+
document.getElementById('userInput').value = '';
|
| 185 |
+
|
| 186 |
+
// Scroll to bottom
|
| 187 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
| 188 |
+
|
| 189 |
+
// Simulate thinking
|
| 190 |
+
setTimeout(() => {
|
| 191 |
+
const thinkingDiv = document.createElement('div');
|
| 192 |
+
thinkingDiv.className = 'message response flex mb-4';
|
| 193 |
+
thinkingDiv.innerHTML = `
|
| 194 |
+
<div class="flex-shrink-0 mr-3">
|
| 195 |
+
<div class="gradient-bg text-white rounded-full w-8 h-8 flex items-center justify-center">
|
| 196 |
+
<i data-feather="cpu" class="w-4 h-4"></i>
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
<div class="flex-1">
|
| 200 |
+
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1">MindMeld Streaminator</div>
|
| 201 |
+
<div class="text-gray-800 dark:text-gray-200">
|
| 202 |
+
<span id="newResponse" class="whitespace-pre-wrap"><span class="typing-cursor"></span></span>
|
| 203 |
+
</div>
|
| 204 |
+
</div>
|
| 205 |
+
`;
|
| 206 |
+
messageContainer.appendChild(thinkingDiv);
|
| 207 |
+
|
| 208 |
+
// Scroll to bottom
|
| 209 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
| 210 |
+
|
| 211 |
+
// Generate response
|
| 212 |
+
const responses = [
|
| 213 |
+
`I understand you're asking about "${userInput}". That's an interesting topic! Here's what I know...\n\nAI systems like me process information differently than humans, but we strive to provide accurate and helpful responses.`,
|
| 214 |
+
`Regarding "${userInput}", I can provide information based on my training data. Would you like me to go into more detail about any specific aspect?`,
|
| 215 |
+
`"${userInput}" - great question! My response would be that in an ever-changing technological landscape, adaptability is key to understanding complex topics.`,
|
| 216 |
+
`Let me analyze your query about "${userInput}". Based on patterns in my training data, I can offer several perspectives on this subject.`
|
| 217 |
+
];
|
| 218 |
+
|
| 219 |
+
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
|
| 220 |
+
let newIndex = 0;
|
| 221 |
+
const newResponse = document.getElementById('newResponse');
|
| 222 |
+
|
| 223 |
+
function typeNewResponse() {
|
| 224 |
+
if (newIndex < randomResponse.length) {
|
| 225 |
+
const currentChar = randomResponse.charAt(newIndex);
|
| 226 |
+
if (currentChar === '\n') {
|
| 227 |
+
newResponse.innerHTML = newResponse.innerHTML.replace('<span class="typing-cursor"></span>', '<br><span class="typing-cursor"></span>');
|
| 228 |
+
} else {
|
| 229 |
+
newResponse.innerHTML = newResponse.innerHTML.replace('<span class="typing-cursor"></span>', currentChar + '<span class="typing-cursor"></span>');
|
| 230 |
+
}
|
| 231 |
+
newIndex++;
|
| 232 |
+
setTimeout(typeNewResponse, typingSpeed);
|
| 233 |
+
|
| 234 |
+
// Auto-scroll to bottom
|
| 235 |
+
messageContainer.scrollTop = messageContainer.scrollHeight;
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
setTimeout(typeNewResponse, 500);
|
| 240 |
+
}, 800);
|
| 241 |
+
}
|
| 242 |
+
});
|
| 243 |
+
|
| 244 |
+
// Allow Shift+Enter for new line in textarea
|
| 245 |
+
document.getElementById('userInput').addEventListener('keydown', function(e) {
|
| 246 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
| 247 |
+
e.preventDefault();
|
| 248 |
+
document.getElementById('sendButton').click();
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
// Initialize feather icons after dynamic content is added
|
| 253 |
+
setInterval(() => feather.replace(), 500);
|
| 254 |
+
</script>
|
| 255 |
+
</body>
|
| 256 |
</html>
|