rajkumar218 commited on
Commit
a6cbede
·
verified ·
1 Parent(s): 0e09d56

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -4
  2. index.html +391 -19
  3. prompts.txt +0 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Llm Chat
3
- emoji: 🐢
4
- colorFrom: blue
5
  colorTo: green
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: llm-chat
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,391 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
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>LLM 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
+ .chat-container {
11
+ height: calc(100vh - 200px);
12
+ }
13
+ .message-animation {
14
+ animation: fadeIn 0.3s ease-in-out;
15
+ }
16
+ @keyframes fadeIn {
17
+ from { opacity: 0; transform: translateY(10px); }
18
+ to { opacity: 1; transform: translateY(0); }
19
+ }
20
+ .slide-in {
21
+ animation: slideIn 0.3s ease-out;
22
+ }
23
+ @keyframes slideIn {
24
+ from { transform: translateX(100%); }
25
+ to { transform: translateX(0); }
26
+ }
27
+ .pulse {
28
+ animation: pulse 1.5s infinite;
29
+ }
30
+ @keyframes pulse {
31
+ 0%, 100% { opacity: 1; }
32
+ 50% { opacity: 0.5; }
33
+ }
34
+ </style>
35
+ </head>
36
+ <body class="bg-gray-100 font-sans">
37
+ <div class="container mx-auto max-w-6xl p-4">
38
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden">
39
+ <!-- Header -->
40
+ <div class="bg-indigo-600 text-white p-4 flex justify-between items-center">
41
+ <h1 class="text-xl font-bold">LLM Chat Interface</h1>
42
+ <button id="config-btn" class="bg-indigo-700 hover:bg-indigo-800 px-4 py-2 rounded-lg transition">
43
+ <i class="fas fa-cog mr-2"></i>Configure
44
+ </button>
45
+ </div>
46
+
47
+ <!-- Configuration Panel -->
48
+ <div id="config-panel" class="hidden bg-gray-50 p-4 border-b border-gray-200 slide-in">
49
+ <div class="mb-4">
50
+ <label class="block text-gray-700 font-medium mb-2">LLM Provider</label>
51
+ <select id="provider-select" class="w-full p-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
52
+ <option value="">Select a provider</option>
53
+ <option value="azure-openai">Azure OpenAI</option>
54
+ <option value="groq">Groq</option>
55
+ <option value="openai">OpenAI</option>
56
+ <option value="anthropic">Anthropic</option>
57
+ <option value="cohere">Cohere</option>
58
+ </select>
59
+ </div>
60
+
61
+ <!-- Dynamic Credential Form -->
62
+ <div id="credential-form" class="space-y-4">
63
+ <!-- Form will be dynamically populated based on provider -->
64
+ </div>
65
+
66
+ <div class="flex justify-end mt-4">
67
+ <button id="save-config" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg transition">
68
+ Save Configuration
69
+ </button>
70
+ </div>
71
+ </div>
72
+
73
+ <!-- Chat Area -->
74
+ <div class="flex flex-col">
75
+ <div id="chat-messages" class="chat-container p-4 overflow-y-auto space-y-4">
76
+ <div class="text-center text-gray-500 py-10">
77
+ <i class="fas fa-comments text-4xl mb-2"></i>
78
+ <p>Configure your LLM provider to start chatting</p>
79
+ </div>
80
+ </div>
81
+
82
+ <!-- Input Area -->
83
+ <div class="p-4 border-t border-gray-200 bg-white">
84
+ <div id="connection-status" class="hidden mb-2 flex items-center">
85
+ <span class="w-3 h-3 rounded-full mr-2 bg-gray-400"></span>
86
+ <span class="text-sm text-gray-600">Disconnected</span>
87
+ </div>
88
+
89
+ <div class="flex space-x-2">
90
+ <input id="message-input" type="text" placeholder="Type your message..."
91
+ class="flex-1 p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50" disabled>
92
+ <button id="send-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg transition disabled:opacity-50" disabled>
93
+ <i class="fas fa-paper-plane"></i>
94
+ </button>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </div>
100
+
101
+ <script>
102
+ document.addEventListener('DOMContentLoaded', function() {
103
+ // DOM Elements
104
+ const configBtn = document.getElementById('config-btn');
105
+ const configPanel = document.getElementById('config-panel');
106
+ const providerSelect = document.getElementById('provider-select');
107
+ const credentialForm = document.getElementById('credential-form');
108
+ const saveConfigBtn = document.getElementById('save-config');
109
+ const chatMessages = document.getElementById('chat-messages');
110
+ const messageInput = document.getElementById('message-input');
111
+ const sendBtn = document.getElementById('send-btn');
112
+ const connectionStatus = document.getElementById('connection-status');
113
+
114
+ // Current configuration
115
+ let currentConfig = {
116
+ provider: null,
117
+ credentials: null,
118
+ connected: false
119
+ };
120
+
121
+ // Provider configuration templates
122
+ const providerConfigs = {
123
+ 'azure-openai': {
124
+ name: 'Azure OpenAI',
125
+ fields: [
126
+ { id: 'api-key', label: 'API Key', type: 'password', required: true },
127
+ { id: 'endpoint', label: 'Endpoint URL', type: 'text', placeholder: 'https://your-resource.openai.azure.com/', required: true },
128
+ { id: 'deployment-name', label: 'Deployment Name', type: 'text', required: true },
129
+ { id: 'api-version', label: 'API Version', type: 'text', value: '2023-05-15', required: true }
130
+ ]
131
+ },
132
+ 'groq': {
133
+ name: 'Groq',
134
+ fields: [
135
+ { id: 'api-key', label: 'API Key', type: 'password', required: true },
136
+ { id: 'model', label: 'Model', type: 'text', value: 'mixtral-8x7b-32768', required: true }
137
+ ]
138
+ },
139
+ 'openai': {
140
+ name: 'OpenAI',
141
+ fields: [
142
+ { id: 'api-key', label: 'API Key', type: 'password', required: true },
143
+ { id: 'model', label: 'Model', type: 'text', value: 'gpt-4', required: true }
144
+ ]
145
+ },
146
+ 'anthropic': {
147
+ name: 'Anthropic',
148
+ fields: [
149
+ { id: 'api-key', label: 'API Key', type: 'password', required: true },
150
+ { id: 'model', label: 'Model', type: 'text', value: 'claude-2', required: true }
151
+ ]
152
+ },
153
+ 'cohere': {
154
+ name: 'Cohere',
155
+ fields: [
156
+ { id: 'api-key', label: 'API Key', type: 'password', required: true },
157
+ { id: 'model', label: 'Model', type: 'text', value: 'command', required: true }
158
+ ]
159
+ }
160
+ };
161
+
162
+ // Toggle configuration panel
163
+ configBtn.addEventListener('click', function() {
164
+ configPanel.classList.toggle('hidden');
165
+ });
166
+
167
+ // Handle provider selection change
168
+ providerSelect.addEventListener('change', function() {
169
+ const selectedProvider = this.value;
170
+
171
+ if (!selectedProvider) {
172
+ credentialForm.innerHTML = '';
173
+ return;
174
+ }
175
+
176
+ const provider = providerConfigs[selectedProvider];
177
+ let formHTML = `<h3 class="font-medium text-gray-700 mb-3">${provider.name} Configuration</h3>`;
178
+
179
+ provider.fields.forEach(field => {
180
+ formHTML += `
181
+ <div class="mb-3">
182
+ <label for="${field.id}" class="block text-sm font-medium text-gray-700 mb-1">${field.label}</label>
183
+ <input type="${field.type}" id="${field.id}"
184
+ class="w-full p-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
185
+ ${field.placeholder ? `placeholder="${field.placeholder}"` : ''}
186
+ ${field.value ? `value="${field.value}"` : ''}
187
+ ${field.required ? 'required' : ''}>
188
+ </div>
189
+ `;
190
+ });
191
+
192
+ credentialForm.innerHTML = formHTML;
193
+ });
194
+
195
+ // Save configuration
196
+ saveConfigBtn.addEventListener('click', function() {
197
+ const selectedProvider = providerSelect.value;
198
+
199
+ if (!selectedProvider) {
200
+ alert('Please select a provider');
201
+ return;
202
+ }
203
+
204
+ const provider = providerConfigs[selectedProvider];
205
+ const credentials = {};
206
+ let isValid = true;
207
+
208
+ provider.fields.forEach(field => {
209
+ const input = document.getElementById(field.id);
210
+ if (field.required && !input.value.trim()) {
211
+ input.classList.add('border-red-500');
212
+ isValid = false;
213
+ } else {
214
+ input.classList.remove('border-red-500');
215
+ credentials[field.id] = input.value.trim();
216
+ }
217
+ });
218
+
219
+ if (!isValid) {
220
+ alert('Please fill in all required fields');
221
+ return;
222
+ }
223
+
224
+ // Save configuration
225
+ currentConfig.provider = selectedProvider;
226
+ currentConfig.credentials = credentials;
227
+
228
+ // Test connection (simulated)
229
+ testConnection();
230
+
231
+ // Close config panel
232
+ configPanel.classList.add('hidden');
233
+
234
+ // Add system message
235
+ addMessage('system', `Configuration saved for ${provider.name}. You can now start chatting.`);
236
+ });
237
+
238
+ // Simulate connection test
239
+ function testConnection() {
240
+ connectionStatus.classList.remove('hidden');
241
+ const statusDot = connectionStatus.querySelector('span:first-child');
242
+ const statusText = connectionStatus.querySelector('span:last-child');
243
+
244
+ statusDot.classList.remove('bg-green-500', 'bg-red-500');
245
+ statusDot.classList.add('bg-yellow-500', 'pulse');
246
+ statusText.textContent = 'Connecting...';
247
+
248
+ // Simulate API call
249
+ setTimeout(() => {
250
+ statusDot.classList.remove('bg-yellow-500', 'pulse');
251
+
252
+ // For demo purposes, we'll assume connection is successful
253
+ currentConfig.connected = true;
254
+ statusDot.classList.add('bg-green-500');
255
+ statusText.textContent = 'Connected';
256
+
257
+ // Enable chat
258
+ messageInput.disabled = false;
259
+ sendBtn.disabled = false;
260
+ }, 1500);
261
+ }
262
+
263
+ // Add message to chat
264
+ function addMessage(role, content) {
265
+ const messageDiv = document.createElement('div');
266
+ messageDiv.classList.add('message-animation');
267
+
268
+ if (role === 'user') {
269
+ messageDiv.innerHTML = `
270
+ <div class="flex justify-end">
271
+ <div class="bg-indigo-600 text-white rounded-lg p-3 max-w-3/4">
272
+ <p>${content}</p>
273
+ </div>
274
+ </div>
275
+ `;
276
+ } else if (role === 'assistant') {
277
+ messageDiv.innerHTML = `
278
+ <div class="flex justify-start">
279
+ <div class="bg-gray-200 text-gray-800 rounded-lg p-3 max-w-3/4">
280
+ <p>${content}</p>
281
+ </div>
282
+ </div>
283
+ `;
284
+ } else { // system
285
+ messageDiv.innerHTML = `
286
+ <div class="flex justify-center">
287
+ <div class="bg-gray-100 text-gray-600 text-sm rounded-lg p-2 max-w-3/4">
288
+ <p>${content}</p>
289
+ </div>
290
+ </div>
291
+ `;
292
+ }
293
+
294
+ chatMessages.appendChild(messageDiv);
295
+ chatMessages.scrollTop = chatMessages.scrollHeight;
296
+ }
297
+
298
+ // Handle send message
299
+ sendBtn.addEventListener('click', sendMessage);
300
+ messageInput.addEventListener('keypress', function(e) {
301
+ if (e.key === 'Enter') {
302
+ sendMessage();
303
+ }
304
+ });
305
+
306
+ function sendMessage() {
307
+ const message = messageInput.value.trim();
308
+ if (!message || !currentConfig.connected) return;
309
+
310
+ // Add user message
311
+ addMessage('user', message);
312
+ messageInput.value = '';
313
+
314
+ // Show typing indicator
315
+ const typingIndicator = document.createElement('div');
316
+ typingIndicator.id = 'typing-indicator';
317
+ typingIndicator.innerHTML = `
318
+ <div class="flex justify-start">
319
+ <div class="bg-gray-200 text-gray-800 rounded-lg p-3 max-w-3/4">
320
+ <div class="flex space-x-2">
321
+ <div class="w-2 h-2 rounded-full bg-gray-500 animate-bounce" style="animation-delay: 0s"></div>
322
+ <div class="w-2 h-2 rounded-full bg-gray-500 animate-bounce" style="animation-delay: 0.2s"></div>
323
+ <div class="w-2 h-2 rounded-full bg-gray-500 animate-bounce" style="animation-delay: 0.4s"></div>
324
+ </div>
325
+ </div>
326
+ </div>
327
+ `;
328
+ chatMessages.appendChild(typingIndicator);
329
+ chatMessages.scrollTop = chatMessages.scrollHeight;
330
+
331
+ // Simulate API call to backend
332
+ const apiEndpoint = '/api/chat'; // Your FastAPI endpoint
333
+ const requestData = {
334
+ provider: currentConfig.provider,
335
+ credentials: currentConfig.credentials,
336
+ message: message
337
+ };
338
+
339
+ // In a real implementation, you would use fetch or axios
340
+ console.log('Sending to backend:', requestData);
341
+
342
+ // Simulate API response after delay
343
+ setTimeout(() => {
344
+ // Remove typing indicator
345
+ const indicator = document.getElementById('typing-indicator');
346
+ if (indicator) chatMessages.removeChild(indicator);
347
+
348
+ // For demo purposes, we'll use a mock response
349
+ const mockResponses = {
350
+ 'azure-openai': `I'm your Azure OpenAI assistant. How can I help you today?`,
351
+ 'groq': `I'm powered by Groq's ultra-fast LLMs. What would you like to know?`,
352
+ 'openai': `Hello! I'm an OpenAI model. How can I assist you?`,
353
+ 'anthropic': `Greetings! I'm Claude from Anthropic. How may I help?`,
354
+ 'cohere': `I'm using Cohere's language model. What's on your mind?`
355
+ };
356
+
357
+ const response = mockResponses[currentConfig.provider] ||
358
+ "I'm your AI assistant. How can I help you today?";
359
+
360
+ addMessage('assistant', response);
361
+ }, 1500);
362
+ }
363
+
364
+ // Initial setup
365
+ if (localStorage.getItem('llmConfig')) {
366
+ try {
367
+ currentConfig = JSON.parse(localStorage.getItem('llmConfig'));
368
+ if (currentConfig.provider) {
369
+ providerSelect.value = currentConfig.provider;
370
+ const event = new Event('change');
371
+ providerSelect.dispatchEvent(event);
372
+
373
+ // Populate fields with saved values
374
+ if (currentConfig.credentials) {
375
+ for (const [key, value] of Object.entries(currentConfig.credentials)) {
376
+ const input = document.getElementById(key);
377
+ if (input) input.value = value;
378
+ }
379
+ }
380
+
381
+ // Test connection
382
+ testConnection();
383
+ }
384
+ } catch (e) {
385
+ console.error('Failed to load config:', e);
386
+ }
387
+ }
388
+ });
389
+ </script>
390
+ <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=rajkumar218/llm-chat" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
391
+ </html>
prompts.txt ADDED
File without changes