undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +463 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: hugging-face-code-assistant
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,463 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Hugging Face Coding Assistant</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.message-animation {
|
| 11 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 12 |
+
}
|
| 13 |
+
@keyframes fadeIn {
|
| 14 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 15 |
+
to { opacity: 1; transform: translateY(0); }
|
| 16 |
+
}
|
| 17 |
+
.typing-indicator::after {
|
| 18 |
+
content: '...';
|
| 19 |
+
animation: typing 1.5s infinite;
|
| 20 |
+
}
|
| 21 |
+
@keyframes typing {
|
| 22 |
+
0% { content: '.'; }
|
| 23 |
+
33% { content: '..'; }
|
| 24 |
+
66% { content: '...'; }
|
| 25 |
+
}
|
| 26 |
+
.code-block {
|
| 27 |
+
font-family: 'Courier New', monospace;
|
| 28 |
+
background-color: #2d3748;
|
| 29 |
+
color: #f7fafc;
|
| 30 |
+
border-radius: 0.375rem;
|
| 31 |
+
padding: 1rem;
|
| 32 |
+
overflow-x: auto;
|
| 33 |
+
}
|
| 34 |
+
.copy-btn {
|
| 35 |
+
transition: all 0.2s ease;
|
| 36 |
+
}
|
| 37 |
+
.copy-btn:hover {
|
| 38 |
+
background-color: #4a5568;
|
| 39 |
+
}
|
| 40 |
+
</style>
|
| 41 |
+
</head>
|
| 42 |
+
<body class="bg-gray-100 min-h-screen flex flex-col">
|
| 43 |
+
<!-- Header -->
|
| 44 |
+
<header class="bg-purple-700 text-white shadow-lg">
|
| 45 |
+
<div class="container mx-auto px-4 py-3 flex items-center justify-between">
|
| 46 |
+
<div class="flex items-center space-x-2">
|
| 47 |
+
<i class="fas fa-robot text-2xl"></i>
|
| 48 |
+
<h1 class="text-xl md:text-2xl font-bold">Hugging Face Coding Assistant</h1>
|
| 49 |
+
</div>
|
| 50 |
+
<div class="flex items-center space-x-4">
|
| 51 |
+
<button id="theme-toggle" class="p-2 rounded-full hover:bg-purple-600 transition">
|
| 52 |
+
<i class="fas fa-moon"></i>
|
| 53 |
+
</button>
|
| 54 |
+
<button id="clear-chat" class="px-3 py-1 bg-purple-600 rounded hover:bg-purple-500 transition">
|
| 55 |
+
<i class="fas fa-trash-alt mr-1"></i> Clear
|
| 56 |
+
</button>
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
</header>
|
| 60 |
+
|
| 61 |
+
<!-- Main Content -->
|
| 62 |
+
<main class="flex-1 container mx-auto px-4 py-6 flex flex-col md:flex-row gap-6">
|
| 63 |
+
<!-- Sidebar -->
|
| 64 |
+
<aside class="w-full md:w-64 bg-white rounded-lg shadow-md p-4 h-fit sticky top-6">
|
| 65 |
+
<div class="mb-6">
|
| 66 |
+
<h2 class="text-lg font-semibold text-gray-800 mb-2 flex items-center">
|
| 67 |
+
<i class="fas fa-cog mr-2 text-purple-600"></i> Quick Actions
|
| 68 |
+
</h2>
|
| 69 |
+
<div class="space-y-2">
|
| 70 |
+
<button class="quick-action-btn" data-prompt="Explain Python functions">
|
| 71 |
+
<i class="fas fa-code mr-2"></i> Python Help
|
| 72 |
+
</button>
|
| 73 |
+
<button class="quick-action-btn" data-prompt="Show me JavaScript array methods">
|
| 74 |
+
<i class="fab fa-js-square mr-2"></i> JavaScript Help
|
| 75 |
+
</button>
|
| 76 |
+
<button class="quick-action-btn" data-prompt="How to use Hugging Face models?">
|
| 77 |
+
<i class="fas fa-brain mr-2"></i> HF Models
|
| 78 |
+
</button>
|
| 79 |
+
<button class="quick-action-btn" data-prompt="Git commands cheat sheet">
|
| 80 |
+
<i class="fab fa-git-alt mr-2"></i> Git Help
|
| 81 |
+
</button>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
<div>
|
| 85 |
+
<h2 class="text-lg font-semibold text-gray-800 mb-2 flex items-center">
|
| 86 |
+
<i class="fas fa-history mr-2 text-purple-600"></i> Recent Topics
|
| 87 |
+
</h2>
|
| 88 |
+
<div id="recent-topics" class="space-y-1">
|
| 89 |
+
<!-- Will be populated by JavaScript -->
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</aside>
|
| 93 |
+
|
| 94 |
+
<!-- Chat Area -->
|
| 95 |
+
<section class="flex-1 flex flex-col bg-white rounded-lg shadow-md overflow-hidden">
|
| 96 |
+
<!-- Messages Container -->
|
| 97 |
+
<div id="messages" class="flex-1 p-4 overflow-y-auto space-y-4">
|
| 98 |
+
<!-- Welcome Message -->
|
| 99 |
+
<div class="message-animation bg-purple-100 rounded-lg p-4">
|
| 100 |
+
<div class="flex items-start">
|
| 101 |
+
<div class="flex-shrink-0 bg-purple-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">
|
| 102 |
+
<i class="fas fa-robot"></i>
|
| 103 |
+
</div>
|
| 104 |
+
<div>
|
| 105 |
+
<h3 class="font-semibold text-purple-800">Hugging Face Assistant</h3>
|
| 106 |
+
<p class="text-gray-700 mt-1">Hello! I'm your Hugging Face coding assistant. I can help with programming questions, explain concepts, debug code, and guide you through Hugging Face tools. What would you like to learn today?</p>
|
| 107 |
+
<div class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-2">
|
| 108 |
+
<button class="suggestion-btn">Explain Python decorators</button>
|
| 109 |
+
<button class="suggestion-btn">How to fine-tune a model?</button>
|
| 110 |
+
<button class="suggestion-btn">Show React component example</button>
|
| 111 |
+
<button class="suggestion-btn">Debug this JavaScript code</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<!-- Input Area -->
|
| 119 |
+
<div class="border-t border-gray-200 p-4 bg-gray-50">
|
| 120 |
+
<form id="chat-form" class="flex items-center space-x-2">
|
| 121 |
+
<div class="flex-1 relative">
|
| 122 |
+
<input
|
| 123 |
+
id="user-input"
|
| 124 |
+
type="text"
|
| 125 |
+
placeholder="Ask me anything about coding or Hugging Face..."
|
| 126 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
|
| 127 |
+
autocomplete="off"
|
| 128 |
+
>
|
| 129 |
+
<button type="button" id="voice-btn" class="absolute right-3 top-3 text-gray-400 hover:text-purple-600">
|
| 130 |
+
<i class="fas fa-microphone"></i>
|
| 131 |
+
</button>
|
| 132 |
+
</div>
|
| 133 |
+
<button type="submit" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-3 rounded-lg transition">
|
| 134 |
+
<i class="fas fa-paper-plane"></i>
|
| 135 |
+
</button>
|
| 136 |
+
</form>
|
| 137 |
+
<div class="mt-2 flex flex-wrap gap-2">
|
| 138 |
+
<span class="text-xs text-gray-500">Try:</span>
|
| 139 |
+
<button class="text-xs text-purple-600 hover:text-purple-800" data-prompt="How to use transformers library?">transformers</button>
|
| 140 |
+
<button class="text-xs text-purple-600 hover:text-purple-800" data-prompt="Explain async/await in JavaScript">async/await</button>
|
| 141 |
+
<button class="text-xs text-purple-600 hover:text-purple-800" data-prompt="Show pandas dataframe example">pandas</button>
|
| 142 |
+
<button class="text-xs text-purple-600 hover:text-purple-800" data-prompt="What is a neural network?">neural network</button>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</section>
|
| 146 |
+
</main>
|
| 147 |
+
|
| 148 |
+
<!-- Footer -->
|
| 149 |
+
<footer class="bg-gray-800 text-white py-4">
|
| 150 |
+
<div class="container mx-auto px-4 text-center text-sm">
|
| 151 |
+
<p>Hugging Face Coding Assistant - Powered by AI models</p>
|
| 152 |
+
<p class="mt-1 text-gray-400">This is a demo interface. Not affiliated with Hugging Face.</p>
|
| 153 |
+
</div>
|
| 154 |
+
</footer>
|
| 155 |
+
|
| 156 |
+
<script>
|
| 157 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 158 |
+
// Theme toggle
|
| 159 |
+
const themeToggle = document.getElementById('theme-toggle');
|
| 160 |
+
themeToggle.addEventListener('click', function() {
|
| 161 |
+
document.documentElement.classList.toggle('dark');
|
| 162 |
+
const icon = themeToggle.querySelector('i');
|
| 163 |
+
if (document.documentElement.classList.contains('dark')) {
|
| 164 |
+
icon.classList.replace('fa-moon', 'fa-sun');
|
| 165 |
+
document.body.classList.add('bg-gray-900');
|
| 166 |
+
document.body.classList.remove('bg-gray-100');
|
| 167 |
+
} else {
|
| 168 |
+
icon.classList.replace('fa-sun', 'fa-moon');
|
| 169 |
+
document.body.classList.remove('bg-gray-900');
|
| 170 |
+
document.body.classList.add('bg-gray-100');
|
| 171 |
+
}
|
| 172 |
+
});
|
| 173 |
+
|
| 174 |
+
// Chat functionality
|
| 175 |
+
const chatForm = document.getElementById('chat-form');
|
| 176 |
+
const userInput = document.getElementById('user-input');
|
| 177 |
+
const messagesContainer = document.getElementById('messages');
|
| 178 |
+
const recentTopicsContainer = document.getElementById('recent-topics');
|
| 179 |
+
const clearChatBtn = document.getElementById('clear-chat');
|
| 180 |
+
|
| 181 |
+
// Sample responses for demo purposes
|
| 182 |
+
const sampleResponses = {
|
| 183 |
+
"Explain Python functions": `Python functions are blocks of reusable code that perform a specific task. They help organize code into logical chunks and make it more readable and maintainable.
|
| 184 |
+
|
| 185 |
+
<pre class="code-block mt-3 relative">
|
| 186 |
+
<span class="text-green-400">def</span> <span class="text-yellow-300">greet</span>(name):
|
| 187 |
+
<span class="text-green-400">"""This function greets the person passed in as a parameter"""</span>
|
| 188 |
+
<span class="text-green-400">print</span>(<span class="text-yellow-300">f"Hello, </span>{name}<span class="text-yellow-300">. How are you?"</span>)
|
| 189 |
+
|
| 190 |
+
<span class="text-gray-400"># Calling the function</span>
|
| 191 |
+
greet(<span class="text-yellow-300">"Alice"</span>)
|
| 192 |
+
</pre>
|
| 193 |
+
|
| 194 |
+
Key points about functions:
|
| 195 |
+
- Defined with the <span class="font-mono bg-gray-200 px-1 rounded">def</span> keyword
|
| 196 |
+
- Can accept parameters (inputs)
|
| 197 |
+
- Can return values using the <span class="font-mono bg-gray-200 px-1 rounded">return</span> statement
|
| 198 |
+
- Help avoid code duplication`,
|
| 199 |
+
|
| 200 |
+
"Show me JavaScript array methods": `JavaScript provides many useful array methods. Here are some commonly used ones:
|
| 201 |
+
|
| 202 |
+
<pre class="code-block mt-3 relative">
|
| 203 |
+
<span class="text-green-400">const</span> numbers = [1, 2, 3, 4, 5];
|
| 204 |
+
|
| 205 |
+
<span class="text-gray-400">// map() - creates a new array with results of calling a function on every element</span>
|
| 206 |
+
<span class="text-green-400">const</span> doubled = numbers.map(num => num * 2);
|
| 207 |
+
|
| 208 |
+
<span class="text-gray-400">// filter() - creates new array with elements that pass a test</span>
|
| 209 |
+
<span class="text-green-400">const</span> evens = numbers.filter(num => num % 2 === 0);
|
| 210 |
+
|
| 211 |
+
<span class="text-gray-400">// reduce() - reduces array to a single value</span>
|
| 212 |
+
<span class="text-green-400">const</span> sum = numbers.reduce((total, num) => total + num, 0);
|
| 213 |
+
|
| 214 |
+
<span class="text-gray-400">// forEach() - executes a function for each element</span>
|
| 215 |
+
numbers.forEach(num => console.log(num));
|
| 216 |
+
|
| 217 |
+
<span class="text-gray-400">// includes() - checks if array contains a value</span>
|
| 218 |
+
<span class="text-green-400">const</span> hasThree = numbers.includes(3);
|
| 219 |
+
</pre>
|
| 220 |
+
|
| 221 |
+
Other useful methods: find(), some(), every(), sort(), slice(), splice()`,
|
| 222 |
+
|
| 223 |
+
"How to use Hugging Face models?": `Hugging Face provides thousands of pre-trained models through their <span class="font-mono bg-gray-200 px-1 rounded">transformers</span> library. Here's how to use them:
|
| 224 |
+
|
| 225 |
+
1. First install the library:
|
| 226 |
+
<pre class="code-block mt-3 relative">
|
| 227 |
+
pip install transformers
|
| 228 |
+
</pre>
|
| 229 |
+
|
| 230 |
+
2. Basic usage for text classification:
|
| 231 |
+
<pre class="code-block mt-3 relative">
|
| 232 |
+
<span class="text-green-400">from</span> transformers <span class="text-green-400">import</span> pipeline
|
| 233 |
+
|
| 234 |
+
<span class="text-gray-400"># Create a text classification pipeline</span>
|
| 235 |
+
classifier = pipeline(<span class="text-yellow-300">"text-classification"</span>)
|
| 236 |
+
|
| 237 |
+
<span class="text-gray-400"># Use the model</span>
|
| 238 |
+
result = classifier(<span class="text-yellow-300">"I love using Hugging Face models!"</span>)
|
| 239 |
+
<span class="text-green-400">print</span>(result) <span class="text-gray-400"># Outputs sentiment analysis</span>
|
| 240 |
+
</pre>
|
| 241 |
+
|
| 242 |
+
3. For more control, you can load specific models:
|
| 243 |
+
<pre class="code-block mt-3 relative">
|
| 244 |
+
<span class="text-green-400">from</span> transformers <span class="text-green-400">import</span> AutoTokenizer, AutoModelForSequenceClassification
|
| 245 |
+
|
| 246 |
+
<span class="text-gray-400"># Load tokenizer and model</span>
|
| 247 |
+
model_name = <span class="text-yellow-300">"distilbert-base-uncased-finetuned-sst-2-english"</span>
|
| 248 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 249 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 250 |
+
|
| 251 |
+
<span class="text-gray-400"># Tokenize input and get predictions</span>
|
| 252 |
+
inputs = tokenizer(<span class="text-yellow-300">"Hugging Face is awesome!"</span>, return_tensors=<span class="text-yellow-300">"pt"</span>)
|
| 253 |
+
outputs = model(**inputs)
|
| 254 |
+
</pre>`,
|
| 255 |
+
|
| 256 |
+
"Git commands cheat sheet": `Here's a cheat sheet for common Git commands:
|
| 257 |
+
|
| 258 |
+
<pre class="code-block mt-3 relative">
|
| 259 |
+
<span class="text-gray-400"># Initialize a new repository</span>
|
| 260 |
+
git init
|
| 261 |
+
|
| 262 |
+
<span class="text-gray-400"># Clone an existing repository</span>
|
| 263 |
+
git clone <repository_url>
|
| 264 |
+
|
| 265 |
+
<span class="text-gray-400"># Check status of files</span>
|
| 266 |
+
git status
|
| 267 |
+
|
| 268 |
+
<span class="text-gray-400"># Add files to staging area</span>
|
| 269 |
+
git add <file> <span class="text-gray-400"># Add specific file</span>
|
| 270 |
+
git add . <span class="text-gray-400"># Add all changed files</span>
|
| 271 |
+
|
| 272 |
+
<span class="text-gray-400"># Commit changes</span>
|
| 273 |
+
git commit -m <span class="text-yellow-300">"Commit message"</span>
|
| 274 |
+
|
| 275 |
+
<span class="text-gray-400"># Push changes to remote</span>
|
| 276 |
+
git push origin <branch>
|
| 277 |
+
|
| 278 |
+
<span class="text-gray-400"># Pull latest changes</span>
|
| 279 |
+
git pull
|
| 280 |
+
|
| 281 |
+
<span class="text-gray-400"># Create and switch to new branch</span>
|
| 282 |
+
git checkout -b <new_branch>
|
| 283 |
+
|
| 284 |
+
<span class="text-gray-400"># Merge branches</span>
|
| 285 |
+
git merge <branch>
|
| 286 |
+
|
| 287 |
+
<span class="text-gray-400"># View commit history</span>
|
| 288 |
+
git log
|
| 289 |
+
|
| 290 |
+
<span class="text-gray-400"># Discard changes in working directory</span>
|
| 291 |
+
git checkout -- <file>
|
| 292 |
+
</pre>`
|
| 293 |
+
};
|
| 294 |
+
|
| 295 |
+
// Add message to chat
|
| 296 |
+
function addMessage(content, isUser = false) {
|
| 297 |
+
const messageDiv = document.createElement('div');
|
| 298 |
+
messageDiv.className = `message-animation ${isUser ? 'bg-blue-50' : 'bg-purple-100'} rounded-lg p-4`;
|
| 299 |
+
|
| 300 |
+
const messageContent = isUser
|
| 301 |
+
? `<div class="flex items-start">
|
| 302 |
+
<div class="flex-shrink-0 bg-blue-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">
|
| 303 |
+
<i class="fas fa-user"></i>
|
| 304 |
+
</div>
|
| 305 |
+
<div>
|
| 306 |
+
<h3 class="font-semibold text-blue-800">You</h3>
|
| 307 |
+
<p class="text-gray-700 mt-1">${content}</p>
|
| 308 |
+
</div>
|
| 309 |
+
</div>`
|
| 310 |
+
: `<div class="flex items-start">
|
| 311 |
+
<div class="flex-shrink-0 bg-purple-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">
|
| 312 |
+
<i class="fas fa-robot"></i>
|
| 313 |
+
</div>
|
| 314 |
+
<div>
|
| 315 |
+
<h3 class="font-semibold text-purple-800">Hugging Face Assistant</h3>
|
| 316 |
+
<div class="text-gray-700 mt-1">${content}</div>
|
| 317 |
+
</div>
|
| 318 |
+
</div>`;
|
| 319 |
+
|
| 320 |
+
messageDiv.innerHTML = messageContent;
|
| 321 |
+
messagesContainer.appendChild(messageDiv);
|
| 322 |
+
messageDiv.scrollIntoView({ behavior: 'smooth' });
|
| 323 |
+
|
| 324 |
+
// Add code copy functionality
|
| 325 |
+
messageDiv.querySelectorAll('.code-block').forEach(block => {
|
| 326 |
+
const copyBtn = document.createElement('button');
|
| 327 |
+
copyBtn.className = 'copy-btn absolute top-2 right-2 bg-gray-700 text-white px-2 py-1 text-xs rounded';
|
| 328 |
+
copyBtn.innerHTML = '<i class="fas fa-copy mr-1"></i> Copy';
|
| 329 |
+
copyBtn.addEventListener('click', () => {
|
| 330 |
+
const code = block.textContent;
|
| 331 |
+
navigator.clipboard.writeText(code);
|
| 332 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 333 |
+
setTimeout(() => {
|
| 334 |
+
copyBtn.innerHTML = '<i class="fas fa-copy mr-1"></i> Copy';
|
| 335 |
+
}, 2000);
|
| 336 |
+
});
|
| 337 |
+
block.appendChild(copyBtn);
|
| 338 |
+
});
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// Simulate typing indicator
|
| 342 |
+
function showTypingIndicator() {
|
| 343 |
+
const typingDiv = document.createElement('div');
|
| 344 |
+
typingDiv.className = 'message-animation bg-purple-100 rounded-lg p-4';
|
| 345 |
+
typingDiv.innerHTML = `
|
| 346 |
+
<div class="flex items-start">
|
| 347 |
+
<div class="flex-shrink-0 bg-purple-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">
|
| 348 |
+
<i class="fas fa-robot"></i>
|
| 349 |
+
</div>
|
| 350 |
+
<div>
|
| 351 |
+
<h3 class="font-semibold text-purple-800">Hugging Face Assistant</h3>
|
| 352 |
+
<p class="text-gray-700 mt-1 typing-indicator">Thinking</p>
|
| 353 |
+
</div>
|
| 354 |
+
</div>
|
| 355 |
+
`;
|
| 356 |
+
messagesContainer.appendChild(typingDiv);
|
| 357 |
+
typingDiv.scrollIntoView({ behavior: 'smooth' });
|
| 358 |
+
return typingDiv;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
// Handle form submission
|
| 362 |
+
chatForm.addEventListener('submit', function(e) {
|
| 363 |
+
e.preventDefault();
|
| 364 |
+
const message = userInput.value.trim();
|
| 365 |
+
if (!message) return;
|
| 366 |
+
|
| 367 |
+
// Add user message
|
| 368 |
+
addMessage(message, true);
|
| 369 |
+
userInput.value = '';
|
| 370 |
+
|
| 371 |
+
// Add to recent topics if not already there
|
| 372 |
+
if (!Array.from(recentTopicsContainer.querySelectorAll('button')).some(btn => btn.textContent === message)) {
|
| 373 |
+
const topicBtn = document.createElement('button');
|
| 374 |
+
topicBtn.className = 'w-full text-left px-2 py-1 text-sm text-purple-600 hover:bg-purple-50 rounded transition';
|
| 375 |
+
topicBtn.innerHTML = `<i class="fas fa-comment-dots mr-2"></i>${message}`;
|
| 376 |
+
topicBtn.addEventListener('click', () => {
|
| 377 |
+
userInput.value = message;
|
| 378 |
+
userInput.focus();
|
| 379 |
+
});
|
| 380 |
+
recentTopicsContainer.insertBefore(topicBtn, recentTopicsContainer.firstChild);
|
| 381 |
+
|
| 382 |
+
// Limit to 5 recent topics
|
| 383 |
+
if (recentTopicsContainer.children.length > 5) {
|
| 384 |
+
recentTopicsContainer.removeChild(recentTopicsContainer.lastChild);
|
| 385 |
+
}
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
// Show typing indicator
|
| 389 |
+
const typingIndicator = showTypingIndicator();
|
| 390 |
+
|
| 391 |
+
// Simulate AI response after delay
|
| 392 |
+
setTimeout(() => {
|
| 393 |
+
// Remove typing indicator
|
| 394 |
+
messagesContainer.removeChild(typingIndicator);
|
| 395 |
+
|
| 396 |
+
// Find response or use default
|
| 397 |
+
let response = sampleResponses[message] ||
|
| 398 |
+
`I'd be happy to help with "${message}". Here's what I know about this topic:
|
| 399 |
+
|
| 400 |
+
This is a demo response. In a real implementation, this would connect to a Hugging Face model or API to generate a detailed response about the topic you asked about.
|
| 401 |
+
|
| 402 |
+
For now, try asking about:
|
| 403 |
+
- Python programming
|
| 404 |
+
- JavaScript concepts
|
| 405 |
+
- Hugging Face models
|
| 406 |
+
- Git commands
|
| 407 |
+
- Machine learning basics`;
|
| 408 |
+
|
| 409 |
+
// Add AI response
|
| 410 |
+
addMessage(response);
|
| 411 |
+
}, 1500);
|
| 412 |
+
});
|
| 413 |
+
|
| 414 |
+
// Quick action buttons
|
| 415 |
+
document.querySelectorAll('.quick-action-btn').forEach(btn => {
|
| 416 |
+
btn.addEventListener('click', function() {
|
| 417 |
+
const prompt = this.getAttribute('data-prompt');
|
| 418 |
+
userInput.value = prompt;
|
| 419 |
+
userInput.focus();
|
| 420 |
+
});
|
| 421 |
+
});
|
| 422 |
+
|
| 423 |
+
// Suggestion buttons
|
| 424 |
+
document.querySelectorAll('.suggestion-btn').forEach(btn => {
|
| 425 |
+
btn.addEventListener('click', function() {
|
| 426 |
+
userInput.value = this.textContent;
|
| 427 |
+
userInput.focus();
|
| 428 |
+
});
|
| 429 |
+
});
|
| 430 |
+
|
| 431 |
+
// Quick prompt buttons
|
| 432 |
+
document.querySelectorAll('[data-prompt]').forEach(btn => {
|
| 433 |
+
btn.addEventListener('click', function() {
|
| 434 |
+
userInput.value = this.getAttribute('data-prompt');
|
| 435 |
+
userInput.focus();
|
| 436 |
+
});
|
| 437 |
+
});
|
| 438 |
+
|
| 439 |
+
// Clear chat button
|
| 440 |
+
clearChatBtn.addEventListener('click', function() {
|
| 441 |
+
messagesContainer.innerHTML = `
|
| 442 |
+
<div class="message-animation bg-purple-100 rounded-lg p-4">
|
| 443 |
+
<div class="flex items-start">
|
| 444 |
+
<div class="flex-shrink-0 bg-purple-600 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">
|
| 445 |
+
<i class="fas fa-robot"></i>
|
| 446 |
+
</div>
|
| 447 |
+
<div>
|
| 448 |
+
<h3 class="font-semibold text-purple-800">Hugging Face Assistant</h3>
|
| 449 |
+
<p class="text-gray-700 mt-1">Chat cleared. What would you like to learn about now?</p>
|
| 450 |
+
</div>
|
| 451 |
+
</div>
|
| 452 |
+
</div>
|
| 453 |
+
`;
|
| 454 |
+
});
|
| 455 |
+
|
| 456 |
+
// Voice input button (demo only - would need proper implementation)
|
| 457 |
+
document.getElementById('voice-btn').addEventListener('click', function() {
|
| 458 |
+
alert('Voice input would be implemented here. In a real app, this would use the Web Speech API.');
|
| 459 |
+
});
|
| 460 |
+
});
|
| 461 |
+
</script>
|
| 462 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=bditto5/hugging-face-code-assistant" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 463 |
+
</html>
|