jasvir-singh1021 commited on
Commit
48e9cf1
·
verified ·
1 Parent(s): 0105ca4

undefined - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +330 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Streamlit App Llms
3
- emoji: 🌍
4
- colorFrom: gray
5
- colorTo: purple
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: streamlit-app-llms
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: gray
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,330 @@
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 App with Streamlit</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-message {
11
+ border-radius: 1rem;
12
+ padding: 1rem;
13
+ margin-bottom: 1rem;
14
+ max-width: 80%;
15
+ }
16
+ .user-message {
17
+ background-color: #3b82f6;
18
+ color: white;
19
+ margin-left: auto;
20
+ border-bottom-right-radius: 0;
21
+ }
22
+ .assistant-message {
23
+ background-color: #f3f4f6;
24
+ margin-right: auto;
25
+ border-bottom-left-radius: 0;
26
+ }
27
+ .typing-indicator {
28
+ display: flex;
29
+ padding: 1rem;
30
+ }
31
+ .typing-dot {
32
+ width: 8px;
33
+ height: 8px;
34
+ border-radius: 50%;
35
+ background-color: #6b7280;
36
+ margin: 0 2px;
37
+ animation: typing 1.4s infinite ease-in-out;
38
+ }
39
+ .typing-dot:nth-child(1) {
40
+ animation-delay: 0s;
41
+ }
42
+ .typing-dot:nth-child(2) {
43
+ animation-delay: 0.2s;
44
+ }
45
+ .typing-dot:nth-child(3) {
46
+ animation-delay: 0.4s;
47
+ }
48
+ @keyframes typing {
49
+ 0%, 60%, 100% {
50
+ transform: translateY(0);
51
+ }
52
+ 30% {
53
+ transform: translateY(-5px);
54
+ }
55
+ }
56
+ .sidebar-option:hover {
57
+ background-color: rgba(59, 130, 246, 0.1);
58
+ }
59
+ </style>
60
+ </head>
61
+ <body class="bg-gray-50 min-h-screen">
62
+ <div class="flex h-screen">
63
+ <!-- Sidebar -->
64
+ <div class="w-64 bg-white border-r border-gray-200 p-4 hidden md:block">
65
+ <div class="flex items-center mb-8">
66
+ <i class="fas fa-robot text-blue-500 text-2xl mr-2"></i>
67
+ <h1 class="text-xl font-bold text-gray-800">LLM Playground</h1>
68
+ </div>
69
+
70
+ <div class="mb-6">
71
+ <button class="w-full bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg mb-2 flex items-center justify-center">
72
+ <i class="fas fa-plus mr-2"></i> New Chat
73
+ </button>
74
+ </div>
75
+
76
+ <div class="mb-6">
77
+ <h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">Models</h2>
78
+ <div class="space-y-1">
79
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
80
+ <i class="fas fa-bolt text-yellow-500 mr-2"></i>
81
+ <span>GPT-4</span>
82
+ </div>
83
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
84
+ <i class="fas fa-brain text-purple-500 mr-2"></i>
85
+ <span>Claude 2</span>
86
+ </div>
87
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
88
+ <i class="fas fa-feather text-green-500 mr-2"></i>
89
+ <span>Llama 2</span>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="mb-6">
95
+ <h2 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">History</h2>
96
+ <div class="space-y-1">
97
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
98
+ <i class="fas fa-comment mr-2 text-gray-400"></i>
99
+ <span class="truncate">Python code review</span>
100
+ </div>
101
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
102
+ <i class="fas fa-comment mr-2 text-gray-400"></i>
103
+ <span class="truncate">Marketing copy ideas</span>
104
+ </div>
105
+ <div class="sidebar-option flex items-center p-2 rounded-lg cursor-pointer">
106
+ <i class="fas fa-comment mr-2 text-gray-400"></i>
107
+ <span class="truncate">Travel recommendations</span>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ <div class="absolute bottom-4 left-4 right-4">
113
+ <div class="flex items-center p-2 rounded-lg hover:bg-gray-100 cursor-pointer">
114
+ <i class="fas fa-cog text-gray-500 mr-2"></i>
115
+ <span>Settings</span>
116
+ </div>
117
+ </div>
118
+ </div>
119
+
120
+ <!-- Main Content -->
121
+ <div class="flex-1 flex flex-col overflow-hidden">
122
+ <!-- Mobile Header -->
123
+ <div class="md:hidden bg-white border-b border-gray-200 p-4 flex items-center">
124
+ <button id="menu-toggle" class="mr-4">
125
+ <i class="fas fa-bars text-gray-600"></i>
126
+ </button>
127
+ <h1 class="text-lg font-bold text-gray-800">LLM Chat</h1>
128
+ </div>
129
+
130
+ <!-- Chat Area -->
131
+ <div class="flex-1 overflow-y-auto p-4 bg-gray-50">
132
+ <div class="max-w-3xl mx-auto space-y-4">
133
+ <!-- Welcome message -->
134
+ <div class="chat-message assistant-message">
135
+ <div class="flex items-start">
136
+ <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-2">
137
+ <i class="fas fa-robot"></i>
138
+ </div>
139
+ <div>
140
+ <p class="font-semibold">AI Assistant</p>
141
+ <p>Hello! I'm your AI assistant. How can I help you today? You can ask me anything from coding help to creative writing.</p>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <!-- Example user message -->
147
+ <div class="chat-message user-message">
148
+ <div class="flex items-start">
149
+ <div class="bg-gray-200 rounded-full w-8 h-8 flex items-center justify-center mr-2">
150
+ <i class="fas fa-user text-gray-600"></i>
151
+ </div>
152
+ <div>
153
+ <p class="font-semibold">You</p>
154
+ <p>Can you explain how to create a Streamlit app for LLMs?</p>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <!-- Example assistant response -->
160
+ <div class="chat-message assistant-message">
161
+ <div class="flex items-start">
162
+ <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-2">
163
+ <i class="fas fa-robot"></i>
164
+ </div>
165
+ <div>
166
+ <p class="font-semibold">AI Assistant</p>
167
+ <p>Certainly! Here's a basic structure for a Streamlit app that interacts with an LLM:</p>
168
+ <pre class="bg-gray-800 text-white p-3 rounded mt-2 overflow-x-auto"><code>import streamlit as st
169
+ from openai import OpenAI
170
+
171
+ # Set up the page
172
+ st.set_page_config(page_title="LLM Chat App", page_icon="🤖")
173
+
174
+ # Initialize the OpenAI client
175
+ client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
176
+
177
+ # Sidebar for settings
178
+ with st.sidebar:
179
+ st.title("LLM Settings")
180
+ model = st.selectbox("Choose a model", ["gpt-4", "gpt-3.5-turbo"])
181
+ temperature = st.slider("Temperature", 0.0, 1.0, 0.7)
182
+
183
+ # Main chat interface
184
+ st.title("💬 LLM Chat")
185
+ if "messages" not in st.session_state:
186
+ st.session_state.messages = []
187
+
188
+ # Display chat messages
189
+ for message in st.session_state.messages:
190
+ with st.chat_message(message["role"]):
191
+ st.markdown(message["content"])
192
+
193
+ # Chat input
194
+ if prompt := st.chat_input("What would you like to ask?"):
195
+ st.session_state.messages.append({"role": "user", "content": prompt})
196
+ with st.chat_message("user"):
197
+ st.markdown(prompt)
198
+
199
+ with st.chat_message("assistant"):
200
+ response = client.chat.completions.create(
201
+ model=model,
202
+ messages=st.session_state.messages,
203
+ temperature=temperature
204
+ )
205
+ reply = response.choices[0].message.content
206
+ st.markdown(reply)
207
+
208
+ st.session_state.messages.append({"role": "assistant", "content": reply})</code></pre>
209
+ <p class="mt-2">To run this, you'll need to install Streamlit (<code>pip install streamlit</code>) and the OpenAI package (<code>pip install openai</code>). Then save this as <code>app.py</code> and run with <code>streamlit run app.py</code>.</p>
210
+ </div>
211
+ </div>
212
+ </div>
213
+
214
+ <!-- Typing indicator (hidden by default) -->
215
+ <div class="typing-indicator hidden" id="typing-indicator">
216
+ <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-2">
217
+ <i class="fas fa-robot"></i>
218
+ </div>
219
+ <div class="flex items-center">
220
+ <div class="typing-dot"></div>
221
+ <div class="typing-dot"></div>
222
+ <div class="typing-dot"></div>
223
+ </div>
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <!-- Input Area -->
229
+ <div class="bg-white border-t border-gray-200 p-4">
230
+ <div class="max-w-3xl mx-auto">
231
+ <form id="chat-form" class="flex space-x-2">
232
+ <input
233
+ type="text"
234
+ id="user-input"
235
+ placeholder="Type your message here..."
236
+ class="flex-1 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
237
+ autocomplete="off"
238
+ >
239
+ <button
240
+ type="submit"
241
+ class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center"
242
+ >
243
+ <i class="fas fa-paper-plane mr-2"></i> Send
244
+ </button>
245
+ </form>
246
+ <div class="flex justify-between mt-2 text-xs text-gray-500">
247
+ <div>
248
+ <button class="mr-2 hover:text-blue-500">
249
+ <i class="fas fa-code mr-1"></i> Code
250
+ </button>
251
+ <button class="hover:text-blue-500">
252
+ <i class="fas fa-image mr-1"></i> Image
253
+ </button>
254
+ </div>
255
+ <div>
256
+ <span>Model: GPT-4</span>
257
+ </div>
258
+ </div>
259
+ </div>
260
+ </div>
261
+ </div>
262
+ </div>
263
+
264
+ <script>
265
+ // Toggle mobile menu
266
+ document.getElementById('menu-toggle').addEventListener('click', function() {
267
+ document.querySelector('.sidebar').classList.toggle('hidden');
268
+ });
269
+
270
+ // Simulate chat interaction
271
+ document.getElementById('chat-form').addEventListener('submit', function(e) {
272
+ e.preventDefault();
273
+ const input = document.getElementById('user-input');
274
+ const message = input.value.trim();
275
+
276
+ if (message) {
277
+ // Add user message to chat
278
+ const chatArea = document.querySelector('.max-w-3xl');
279
+ const userMessage = document.createElement('div');
280
+ userMessage.className = 'chat-message user-message';
281
+ userMessage.innerHTML = `
282
+ <div class="flex items-start">
283
+ <div class="bg-gray-200 rounded-full w-8 h-8 flex items-center justify-center mr-2">
284
+ <i class="fas fa-user text-gray-600"></i>
285
+ </div>
286
+ <div>
287
+ <p class="font-semibold">You</p>
288
+ <p>${message}</p>
289
+ </div>
290
+ </div>
291
+ `;
292
+ chatArea.appendChild(userMessage);
293
+
294
+ // Show typing indicator
295
+ const typingIndicator = document.getElementById('typing-indicator');
296
+ typingIndicator.classList.remove('hidden');
297
+
298
+ // Clear input
299
+ input.value = '';
300
+
301
+ // Scroll to bottom
302
+ chatArea.scrollTop = chatArea.scrollHeight;
303
+
304
+ // Simulate AI response after a delay
305
+ setTimeout(() => {
306
+ typingIndicator.classList.add('hidden');
307
+
308
+ const assistantMessage = document.createElement('div');
309
+ assistantMessage.className = 'chat-message assistant-message';
310
+ assistantMessage.innerHTML = `
311
+ <div class="flex items-start">
312
+ <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-2">
313
+ <i class="fas fa-robot"></i>
314
+ </div>
315
+ <div>
316
+ <p class="font-semibold">AI Assistant</p>
317
+ <p>I'm a simulated response in this demo. In a real Streamlit app, this would be the LLM's actual response to: "${message}"</p>
318
+ </div>
319
+ </div>
320
+ `;
321
+ chatArea.appendChild(assistantMessage);
322
+
323
+ // Scroll to bottom again
324
+ chatArea.scrollTop = chatArea.scrollHeight;
325
+ }, 1500);
326
+ }
327
+ });
328
+ </script>
329
+ <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=jasvir-singh1021/streamlit-app-llms" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
330
+ </html>