Add 2 files
Browse files- README.md +7 -5
- index.html +560 -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: t1
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: green
|
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,560 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Gemini Nano Chat Interface</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 |
+
@keyframes pulse {
|
11 |
+
0%, 100% { opacity: 1; }
|
12 |
+
50% { opacity: 0.5; }
|
13 |
+
}
|
14 |
+
.typing-indicator span {
|
15 |
+
animation: pulse 1.5s infinite;
|
16 |
+
}
|
17 |
+
.typing-indicator span:nth-child(2) {
|
18 |
+
animation-delay: 0.2s;
|
19 |
+
}
|
20 |
+
.typing-indicator span:nth-child(3) {
|
21 |
+
animation-delay: 0.4s;
|
22 |
+
}
|
23 |
+
.chat-container {
|
24 |
+
height: calc(100vh - 160px);
|
25 |
+
}
|
26 |
+
.message-transition {
|
27 |
+
transition: all 0.3s ease;
|
28 |
+
}
|
29 |
+
.gradient-bg {
|
30 |
+
background: linear-gradient(135deg, #4285f4 0%, #34a853 50%, #fbbc05 100%);
|
31 |
+
}
|
32 |
+
.markdown-style p {
|
33 |
+
margin-bottom: 1em;
|
34 |
+
}
|
35 |
+
.markdown-style ul, .markdown-style ol {
|
36 |
+
margin-left: 1.5em;
|
37 |
+
margin-bottom: 1em;
|
38 |
+
}
|
39 |
+
.markdown-style li {
|
40 |
+
margin-bottom: 0.5em;
|
41 |
+
}
|
42 |
+
.markdown-style code {
|
43 |
+
background-color: #f3f4f6;
|
44 |
+
padding: 0.2em 0.4em;
|
45 |
+
border-radius: 0.25em;
|
46 |
+
font-family: monospace;
|
47 |
+
}
|
48 |
+
.markdown-style pre {
|
49 |
+
background-color: #f3f4f6;
|
50 |
+
padding: 1em;
|
51 |
+
border-radius: 0.5em;
|
52 |
+
overflow-x: auto;
|
53 |
+
margin-bottom: 1em;
|
54 |
+
}
|
55 |
+
.markdown-style blockquote {
|
56 |
+
border-left: 4px solid #e5e7eb;
|
57 |
+
padding-left: 1em;
|
58 |
+
margin-left: 0;
|
59 |
+
color: #6b7280;
|
60 |
+
margin-bottom: 1em;
|
61 |
+
}
|
62 |
+
.token-counter {
|
63 |
+
position: absolute;
|
64 |
+
right: 1rem;
|
65 |
+
bottom: -1.5rem;
|
66 |
+
font-size: 0.75rem;
|
67 |
+
color: #6b7280;
|
68 |
+
}
|
69 |
+
.token-limit {
|
70 |
+
color: #ef4444;
|
71 |
+
}
|
72 |
+
</style>
|
73 |
+
</head>
|
74 |
+
<body class="bg-gray-100">
|
75 |
+
<div class="flex flex-col h-screen">
|
76 |
+
<!-- Header -->
|
77 |
+
<header class="gradient-bg text-white p-4 shadow-md">
|
78 |
+
<div class="container mx-auto flex items-center justify-between">
|
79 |
+
<div class="flex items-center space-x-3">
|
80 |
+
<div class="w-10 h-10 bg-white rounded-full flex items-center justify-center">
|
81 |
+
<i class="fas fa-robot text-2xl text-blue-600"></i>
|
82 |
+
</div>
|
83 |
+
<h1 class="text-2xl font-bold">Gemini Nano</h1>
|
84 |
+
</div>
|
85 |
+
<div class="flex items-center space-x-4">
|
86 |
+
<button id="clear-chat" class="p-2 rounded-full hover:bg-white/20 transition" title="Clear conversation">
|
87 |
+
<i class="fas fa-trash-alt"></i>
|
88 |
+
</button>
|
89 |
+
<button class="p-2 rounded-full hover:bg-white/20 transition" title="Settings">
|
90 |
+
<i class="fas fa-cog"></i>
|
91 |
+
</button>
|
92 |
+
<button class="p-2 rounded-full hover:bg-white/20 transition" title="History">
|
93 |
+
<i class="fas fa-history"></i>
|
94 |
+
</button>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
</header>
|
98 |
+
|
99 |
+
<!-- Chat Container -->
|
100 |
+
<div class="chat-container container mx-auto p-4 overflow-y-auto flex-1">
|
101 |
+
<div class="max-w-3xl mx-auto space-y-4" id="chat-messages">
|
102 |
+
<!-- Welcome message -->
|
103 |
+
<div class="flex justify-start">
|
104 |
+
<div class="bg-white rounded-2xl p-4 shadow-sm max-w-[80%] message-transition">
|
105 |
+
<div class="flex items-center mb-2">
|
106 |
+
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-2">
|
107 |
+
<i class="fas fa-robot text-blue-600"></i>
|
108 |
+
</div>
|
109 |
+
<span class="font-semibold">Gemini Nano</span>
|
110 |
+
</div>
|
111 |
+
<div class="markdown-style">
|
112 |
+
<p>Hello! I'm Gemini Nano, your built-in AI assistant with extended context memory (up to 128K tokens). I can help with:</p>
|
113 |
+
<ul>
|
114 |
+
<li>Detailed technical explanations</li>
|
115 |
+
<li>Creative writing and brainstorming</li>
|
116 |
+
<li>Code generation and debugging</li>
|
117 |
+
<li>Research and information synthesis</li>
|
118 |
+
<li>And much more with my extended capabilities</li>
|
119 |
+
</ul>
|
120 |
+
<p>What would you like to explore today? You can ask complex, multi-part questions and I'll maintain context throughout our conversation.</p>
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</div>
|
126 |
+
|
127 |
+
<!-- Input Area -->
|
128 |
+
<div class="bg-white border-t border-gray-200 p-4 shadow-lg">
|
129 |
+
<div class="container mx-auto max-w-3xl relative">
|
130 |
+
<form id="chat-form" class="flex space-x-2">
|
131 |
+
<div class="flex-1 relative">
|
132 |
+
<textarea
|
133 |
+
id="user-input"
|
134 |
+
placeholder="Message Gemini Nano..."
|
135 |
+
class="w-full p-4 pr-12 rounded-2xl border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"
|
136 |
+
rows="1"
|
137 |
+
autocomplete="off"
|
138 |
+
spellcheck="true"
|
139 |
+
></textarea>
|
140 |
+
<div id="token-counter" class="token-counter">0/128000 tokens</div>
|
141 |
+
<div class="absolute right-3 top-1/2 transform -translate-y-1/2 flex space-x-1">
|
142 |
+
<button type="button" class="p-2 text-gray-500 hover:text-blue-600" title="Attach file">
|
143 |
+
<i class="fas fa-paperclip"></i>
|
144 |
+
</button>
|
145 |
+
<button type="button" class="p-2 text-gray-500 hover:text-blue-600" title="Voice input">
|
146 |
+
<i class="fas fa-microphone"></i>
|
147 |
+
</button>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
<button
|
151 |
+
type="submit"
|
152 |
+
id="send-button"
|
153 |
+
class="bg-blue-600 hover:bg-blue-700 text-white rounded-full w-12 h-12 flex items-center justify-center transition disabled:opacity-50"
|
154 |
+
disabled
|
155 |
+
>
|
156 |
+
<i class="fas fa-paper-plane"></i>
|
157 |
+
</button>
|
158 |
+
</form>
|
159 |
+
<div class="mt-2 text-xs text-gray-500 text-center">
|
160 |
+
Gemini Nano may display inaccurate info, including about people, so double-check its responses.
|
161 |
+
<span class="block">Current context window: 128K tokens | Max response length: 32K tokens</span>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
|
167 |
+
<script>
|
168 |
+
document.addEventListener('DOMContentLoaded', function() {
|
169 |
+
const chatForm = document.getElementById('chat-form');
|
170 |
+
const userInput = document.getElementById('user-input');
|
171 |
+
const chatMessages = document.getElementById('chat-messages');
|
172 |
+
const sendButton = document.getElementById('send-button');
|
173 |
+
const clearChatButton = document.getElementById('clear-chat');
|
174 |
+
const tokenCounter = document.getElementById('token-counter');
|
175 |
+
|
176 |
+
// Conversation context (simulating 128K token memory)
|
177 |
+
let conversationContext = [];
|
178 |
+
const MAX_CONTEXT_TOKENS = 128000;
|
179 |
+
const MAX_RESPONSE_TOKENS = 32000;
|
180 |
+
let currentTokenCount = 0;
|
181 |
+
|
182 |
+
// Auto-resize textarea
|
183 |
+
userInput.addEventListener('input', function() {
|
184 |
+
this.style.height = 'auto';
|
185 |
+
this.style.height = (this.scrollHeight) + 'px';
|
186 |
+
updateTokenCounter(this.value);
|
187 |
+
});
|
188 |
+
|
189 |
+
function updateTokenCounter(text) {
|
190 |
+
// Simple token estimation (4 chars ≈ 1 token)
|
191 |
+
const estimatedTokens = Math.ceil(text.length / 4);
|
192 |
+
currentTokenCount = estimatedTokens;
|
193 |
+
|
194 |
+
tokenCounter.textContent = `${estimatedTokens}/128000 tokens`;
|
195 |
+
tokenCounter.className = estimatedTokens > MAX_CONTEXT_TOKENS ?
|
196 |
+
'token-counter token-limit' : 'token-counter';
|
197 |
+
|
198 |
+
sendButton.disabled = text.trim() === '' || estimatedTokens > MAX_CONTEXT_TOKENS;
|
199 |
+
}
|
200 |
+
|
201 |
+
// Sample knowledge base for extended responses
|
202 |
+
const knowledgeBase = {
|
203 |
+
// Technical topics
|
204 |
+
"javascript": {
|
205 |
+
title: "JavaScript",
|
206 |
+
content: `<p>JavaScript is a versatile programming language used for web development. Key features include:</p>
|
207 |
+
<ul>
|
208 |
+
<li><strong>Event-driven programming:</strong> Handles user interactions and browser events</li>
|
209 |
+
<li><strong>First-class functions:</strong> Functions are treated as objects</li>
|
210 |
+
<li><strong>Prototypal inheritance:</strong> Objects inherit directly from other objects</li>
|
211 |
+
<li><strong>Asynchronous programming:</strong> Promises, async/await for non-blocking operations</li>
|
212 |
+
</ul>
|
213 |
+
<p>Modern JavaScript (ES6+) introduced:</p>
|
214 |
+
<ul>
|
215 |
+
<li>let/const declarations</li>
|
216 |
+
<li>Arrow functions</li>
|
217 |
+
<li>Classes</li>
|
218 |
+
<li>Modules</li>
|
219 |
+
<li>Destructuring</li>
|
220 |
+
</ul>`
|
221 |
+
},
|
222 |
+
"python": {
|
223 |
+
title: "Python",
|
224 |
+
content: `<p>Python is a high-level, interpreted programming language known for its readability. Key aspects:</p>
|
225 |
+
<ul>
|
226 |
+
<li><strong>Duck typing:</strong> Objects are determined by their methods/properties</li>
|
227 |
+
<li><strong>Indentation:</strong> Uses whitespace for block delimitation</li>
|
228 |
+
<li><strong>Dynamic typing:</strong> Variables don't need type declarations</li>
|
229 |
+
<li><strong>Batteries included:</strong> Extensive standard library</li>
|
230 |
+
</ul>
|
231 |
+
<p>Popular Python frameworks:</p>
|
232 |
+
<ul>
|
233 |
+
<li>Django (web development)</li>
|
234 |
+
<li>Flask (micro web framework)</li>
|
235 |
+
<li>NumPy/SciPy (scientific computing)</li>
|
236 |
+
<li>Pandas (data analysis)</li>
|
237 |
+
<li>TensorFlow/PyTorch (machine learning)</li>
|
238 |
+
</ul>`
|
239 |
+
},
|
240 |
+
// Creative topics
|
241 |
+
"creative writing": {
|
242 |
+
title: "Creative Writing",
|
243 |
+
content: `<p>Creative writing techniques to enhance your storytelling:</p>
|
244 |
+
<ol>
|
245 |
+
<li><strong>Show, don't tell:</strong> Use vivid descriptions instead of direct statements</li>
|
246 |
+
<li><strong>Character development:</strong> Create complex characters with flaws and motivations</li>
|
247 |
+
<li><strong>Plot structure:</strong> Consider the three-act structure or hero's journey</li>
|
248 |
+
<li><strong>Dialogue:</strong> Make it natural and reveal character traits</li>
|
249 |
+
<li><strong>Setting:</strong> Use all five senses to describe environments</li>
|
250 |
+
</ol>
|
251 |
+
<p>Writing prompts to get started:</p>
|
252 |
+
<ul>
|
253 |
+
<li>A character discovers a hidden room in their home that wasn't there yesterday</li>
|
254 |
+
<li>Write a story that begins with "The last thing I expected to find in the freezer was..."</li>
|
255 |
+
<li>Create a dialogue between two people where one is lying but doesn't know the other can tell</li>
|
256 |
+
</ul>`
|
257 |
+
},
|
258 |
+
// General knowledge
|
259 |
+
"history": {
|
260 |
+
title: "World History",
|
261 |
+
content: `<p>Key periods in world history:</p>
|
262 |
+
<ol>
|
263 |
+
<li><strong>Ancient Civilizations</strong> (3000 BCE - 500 CE): Mesopotamia, Egypt, Greece, Rome</li>
|
264 |
+
<li><strong>Middle Ages</strong> (500 - 1500): Feudalism, Crusades, Black Death</li>
|
265 |
+
<li><strong>Renaissance</strong> (14th - 17th century): Revival of art and learning</li>
|
266 |
+
<li><strong>Industrial Revolution</strong> (1760 - 1840): Shift to manufacturing</li>
|
267 |
+
<li><strong>Modern Era</strong> (20th century - present): World Wars, technology boom</li>
|
268 |
+
</ol>
|
269 |
+
<p>Important historical figures:</p>
|
270 |
+
<ul>
|
271 |
+
<li>Alexander the Great (military leader)</li>
|
272 |
+
<li>Leonardo da Vinci (Renaissance polymath)</li>
|
273 |
+
<li>Marie Curie (scientist)</li>
|
274 |
+
<li>Mahatma Gandhi (civil rights leader)</li>
|
275 |
+
<li>Winston Churchill (wartime leader)</li>
|
276 |
+
</ul>`
|
277 |
+
}
|
278 |
+
};
|
279 |
+
|
280 |
+
// Extended response templates
|
281 |
+
const extendedResponses = {
|
282 |
+
technical: (topic) => {
|
283 |
+
if (knowledgeBase[topic.toLowerCase()]) {
|
284 |
+
const item = knowledgeBase[topic.toLowerCase()];
|
285 |
+
return `<h3>${item.title}</h3>${item.content}
|
286 |
+
<p>Would you like me to go deeper into any specific aspect of ${item.title}?</p>`;
|
287 |
+
}
|
288 |
+
return `While I have extensive knowledge about ${topic}, could you specify which aspect you're interested in? I can provide detailed information on:
|
289 |
+
<ul>
|
290 |
+
<li>Core concepts and fundamentals</li>
|
291 |
+
<li>Advanced techniques and best practices</li>
|
292 |
+
<li>Historical development and evolution</li>
|
293 |
+
<li>Current trends and future directions</li>
|
294 |
+
<li>Practical applications and case studies</li>
|
295 |
+
</ul>`;
|
296 |
+
},
|
297 |
+
creative: (prompt) => {
|
298 |
+
return `<p>Here's an extended creative response to "${prompt}":</p>
|
299 |
+
<blockquote>
|
300 |
+
The city slept beneath a blanket of stars, unaware of the cosmic events unfolding just beyond human perception.
|
301 |
+
In the quiet between heartbeats, the universe whispered secrets to those who dared to listen...
|
302 |
+
</blockquote>
|
303 |
+
<p>This opening establishes:</p>
|
304 |
+
<ol>
|
305 |
+
<li>A sense of mystery and scale</li>
|
306 |
+
<li>Contrast between the mundane and extraordinary</li>
|
307 |
+
<li>Potential for cosmic or supernatural elements</li>
|
308 |
+
<li>An invitation to explore deeper meaning</li>
|
309 |
+
</ol>
|
310 |
+
<p>Would you like me to continue this narrative or explore different creative directions?</p>`;
|
311 |
+
},
|
312 |
+
analytical: (question) => {
|
313 |
+
return `<p>Let me analyze "${question}" from multiple perspectives:</p>
|
314 |
+
<h4>1. Historical Context</h4>
|
315 |
+
<p>This question relates to developments that began in the early 20th century when...</p>
|
316 |
+
|
317 |
+
<h4>2. Current State</h4>
|
318 |
+
<p>As of 2023, the situation has evolved to include...</p>
|
319 |
+
|
320 |
+
<h4>3. Future Projections</h4>
|
321 |
+
<p>Experts predict several potential outcomes:</p>
|
322 |
+
<ul>
|
323 |
+
<li>Optimistic scenario: 45% probability</li>
|
324 |
+
<li>Moderate scenario: 35% probability</li>
|
325 |
+
<li>Pessimistic scenario: 20% probability</li>
|
326 |
+
</ul>
|
327 |
+
|
328 |
+
<h4>4. Critical Factors</h4>
|
329 |
+
<p>The resolution depends largely on:</p>
|
330 |
+
<ol>
|
331 |
+
<li>Technological advancements</li>
|
332 |
+
<li>Policy decisions</li>
|
333 |
+
<li>Public acceptance</li>
|
334 |
+
<li>Economic conditions</li>
|
335 |
+
</ol>
|
336 |
+
|
337 |
+
<p>Would you like me to focus on any particular aspect of this analysis?</p>`;
|
338 |
+
}
|
339 |
+
};
|
340 |
+
|
341 |
+
// Clear chat handler
|
342 |
+
clearChatButton.addEventListener('click', function() {
|
343 |
+
if (confirm('Are you sure you want to clear the conversation? This will reset the context memory.')) {
|
344 |
+
chatMessages.innerHTML = `
|
345 |
+
<div class="flex justify-start">
|
346 |
+
<div class="bg-white rounded-2xl p-4 shadow-sm max-w-[80%] message-transition">
|
347 |
+
<div class="flex items-center mb-2">
|
348 |
+
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-2">
|
349 |
+
<i class="fas fa-robot text-blue-600"></i>
|
350 |
+
</div>
|
351 |
+
<span class="font-semibold">Gemini Nano</span>
|
352 |
+
</div>
|
353 |
+
<div class="markdown-style">
|
354 |
+
<p>Hello! I'm Gemini Nano, your built-in AI assistant with extended context memory (up to 128K tokens). What would you like to explore today?</p>
|
355 |
+
</div>
|
356 |
+
</div>
|
357 |
+
</div>
|
358 |
+
`;
|
359 |
+
conversationContext = [];
|
360 |
+
currentTokenCount = 0;
|
361 |
+
updateTokenCounter('');
|
362 |
+
}
|
363 |
+
});
|
364 |
+
|
365 |
+
chatForm.addEventListener('submit', function(e) {
|
366 |
+
e.preventDefault();
|
367 |
+
const message = userInput.value.trim();
|
368 |
+
|
369 |
+
if (message && currentTokenCount <= MAX_CONTEXT_TOKENS) {
|
370 |
+
// Add user message to chat and context
|
371 |
+
addMessage(message, 'user');
|
372 |
+
conversationContext.push({role: 'user', content: message});
|
373 |
+
userInput.value = '';
|
374 |
+
updateTokenCounter('');
|
375 |
+
|
376 |
+
// Show typing indicator
|
377 |
+
showTypingIndicator();
|
378 |
+
|
379 |
+
// Simulate processing delay based on message complexity
|
380 |
+
const processingTime = Math.min(2000 + Math.random() * 3000,
|
381 |
+
Math.max(1000, message.length / 10));
|
382 |
+
|
383 |
+
setTimeout(() => {
|
384 |
+
// Remove typing indicator
|
385 |
+
removeTypingIndicator();
|
386 |
+
|
387 |
+
// Generate response based on context
|
388 |
+
const response = generateExtendedResponse(message);
|
389 |
+
|
390 |
+
// Add to chat and context
|
391 |
+
addMessage(response, 'bot', true);
|
392 |
+
conversationContext.push({role: 'assistant', content: response});
|
393 |
+
|
394 |
+
// Simulate token usage
|
395 |
+
currentTokenCount += Math.ceil(response.length / 4);
|
396 |
+
updateTokenCounter('');
|
397 |
+
|
398 |
+
// Scroll to bottom
|
399 |
+
scrollToBottom();
|
400 |
+
}, processingTime);
|
401 |
+
}
|
402 |
+
});
|
403 |
+
|
404 |
+
function addMessage(text, sender, isMarkdown = false) {
|
405 |
+
const messageDiv = document.createElement('div');
|
406 |
+
messageDiv.className = `flex justify-${sender === 'user' ? 'end' : 'start'} message-transition`;
|
407 |
+
|
408 |
+
const bubbleDiv = document.createElement('div');
|
409 |
+
bubbleDiv.className = `rounded-2xl p-4 shadow-sm max-w-[80%] ${
|
410 |
+
sender === 'user' ? 'bg-blue-600 text-white' : 'bg-white text-gray-800'
|
411 |
+
}`;
|
412 |
+
|
413 |
+
if (sender === 'bot') {
|
414 |
+
const headerDiv = document.createElement('div');
|
415 |
+
headerDiv.className = 'flex items-center mb-2';
|
416 |
+
headerDiv.innerHTML = `
|
417 |
+
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-2">
|
418 |
+
<i class="fas fa-robot text-blue-600"></i>
|
419 |
+
</div>
|
420 |
+
<span class="font-semibold">Gemini Nano</span>
|
421 |
+
`;
|
422 |
+
bubbleDiv.appendChild(headerDiv);
|
423 |
+
}
|
424 |
+
|
425 |
+
const contentDiv = document.createElement('div');
|
426 |
+
if (isMarkdown) {
|
427 |
+
contentDiv.className = 'markdown-style';
|
428 |
+
contentDiv.innerHTML = text; // Note: In real app, sanitize this!
|
429 |
+
} else {
|
430 |
+
contentDiv.textContent = text;
|
431 |
+
}
|
432 |
+
bubbleDiv.appendChild(contentDiv);
|
433 |
+
|
434 |
+
messageDiv.appendChild(bubbleDiv);
|
435 |
+
chatMessages.appendChild(messageDiv);
|
436 |
+
|
437 |
+
scrollToBottom();
|
438 |
+
}
|
439 |
+
|
440 |
+
function showTypingIndicator() {
|
441 |
+
const typingDiv = document.createElement('div');
|
442 |
+
typingDiv.className = 'flex justify-start';
|
443 |
+
typingDiv.id = 'typing-indicator';
|
444 |
+
|
445 |
+
const bubbleDiv = document.createElement('div');
|
446 |
+
bubbleDiv.className = 'bg-white rounded-2xl p-4 shadow-sm max-w-[80%]';
|
447 |
+
|
448 |
+
const headerDiv = document.createElement('div');
|
449 |
+
headerDiv.className = 'flex items-center mb-2';
|
450 |
+
headerDiv.innerHTML = `
|
451 |
+
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-2">
|
452 |
+
<i class="fas fa-robot text-blue-600"></i>
|
453 |
+
</div>
|
454 |
+
<span class="font-semibold">Gemini Nano</span>
|
455 |
+
`;
|
456 |
+
bubbleDiv.appendChild(headerDiv);
|
457 |
+
|
458 |
+
const typingContent = document.createElement('div');
|
459 |
+
typingContent.className = 'typing-indicator flex space-x-1';
|
460 |
+
typingContent.innerHTML = `
|
461 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full"></span>
|
462 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full"></span>
|
463 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full"></span>
|
464 |
+
`;
|
465 |
+
bubbleDiv.appendChild(typingContent);
|
466 |
+
|
467 |
+
typingDiv.appendChild(bubbleDiv);
|
468 |
+
chatMessages.appendChild(typingDiv);
|
469 |
+
|
470 |
+
scrollToBottom();
|
471 |
+
}
|
472 |
+
|
473 |
+
function removeTypingIndicator() {
|
474 |
+
const typingIndicator = document.getElementById('typing-indicator');
|
475 |
+
if (typingIndicator) {
|
476 |
+
typingIndicator.remove();
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
function generateExtendedResponse(message) {
|
481 |
+
// Analyze message for response type
|
482 |
+
const lowerMsg = message.toLowerCase();
|
483 |
+
|
484 |
+
// Check for technical topics
|
485 |
+
const techTopics = ['javascript', 'python', 'code', 'programming', 'algorithm', 'react', 'database'];
|
486 |
+
if (techTopics.some(topic => lowerMsg.includes(topic))) {
|
487 |
+
const topic = techTopics.find(t => lowerMsg.includes(t)) || 'technology';
|
488 |
+
return extendedResponses.technical(topic);
|
489 |
+
}
|
490 |
+
|
491 |
+
// Check for creative requests
|
492 |
+
if (lowerMsg.includes('write') || lowerMsg.includes('story') ||
|
493 |
+
lowerMsg.includes('poem') || lowerMsg.includes('creative')) {
|
494 |
+
return extendedResponses.creative(message);
|
495 |
+
}
|
496 |
+
|
497 |
+
// Check for analytical questions
|
498 |
+
if (lowerMsg.includes('analyze') || lowerMsg.includes('compare') ||
|
499 |
+
lowerMsg.startsWith('why') || lowerMsg.startsWith('how')) {
|
500 |
+
return extendedResponses.analytical(message);
|
501 |
+
}
|
502 |
+
|
503 |
+
// Default extended response
|
504 |
+
return `<p>Thank you for your question. I'll provide a comprehensive response:</p>
|
505 |
+
<h3>Overview</h3>
|
506 |
+
<p>${message} relates to a broad field of study that encompasses multiple disciplines. At its core, this topic addresses fundamental questions about...</p>
|
507 |
+
|
508 |
+
<h3>Key Concepts</h3>
|
509 |
+
<ol>
|
510 |
+
<li><strong>Concept A:</strong> Explanation of the first important concept</li>
|
511 |
+
<li><strong>Concept B:</strong> Description of the second key element</li>
|
512 |
+
<li><strong>Concept C:</strong> Analysis of the third critical component</li>
|
513 |
+
</ol>
|
514 |
+
|
515 |
+
<h3>Current Understanding</h3>
|
516 |
+
<p>As of 2023, the scientific/technical/artistic community has reached consensus on several aspects:</p>
|
517 |
+
<ul>
|
518 |
+
<li>Established fact 1 with supporting evidence</li>
|
519 |
+
<li>Established fact 2 with relevant studies</li>
|
520 |
+
<li>Ongoing debate about controversial aspect</li>
|
521 |
+
</ul>
|
522 |
+
|
523 |
+
<h3>Practical Applications</h3>
|
524 |
+
<p>This knowledge is applied in various real-world scenarios:</p>
|
525 |
+
<ul>
|
526 |
+
<li>Industry application 1</li>
|
527 |
+
<li>Everyday use case 2</li>
|
528 |
+
<li>Cutting-edge implementation 3</li>
|
529 |
+
</ul>
|
530 |
+
|
531 |
+
<h3>Further Exploration</h3>
|
532 |
+
<p>To deepen your understanding, consider these directions:</p>
|
533 |
+
<ol>
|
534 |
+
<li>Read foundational papers by Author X and Researcher Y</li>
|
535 |
+
<li>Experiment with practical exercises</li>
|
536 |
+
<li>Explore related concepts Z and W</li>
|
537 |
+
</ol>
|
538 |
+
|
539 |
+
<p>Would you like me to elaborate on any specific part of this response?</p>`;
|
540 |
+
}
|
541 |
+
|
542 |
+
function scrollToBottom() {
|
543 |
+
const container = document.querySelector('.chat-container');
|
544 |
+
container.scrollTop = container.scrollHeight;
|
545 |
+
}
|
546 |
+
|
547 |
+
// Allow pressing Enter to submit (but Shift+Enter for new line)
|
548 |
+
userInput.addEventListener('keydown', function(e) {
|
549 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
550 |
+
e.preventDefault();
|
551 |
+
chatForm.dispatchEvent(new Event('submit'));
|
552 |
+
}
|
553 |
+
});
|
554 |
+
|
555 |
+
// Initial setup
|
556 |
+
updateTokenCounter('');
|
557 |
+
});
|
558 |
+
</script>
|
559 |
+
<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=fhsp93/t1" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
560 |
+
</html>
|