Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +252 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: gray
|
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: llm
|
3 |
+
emoji: 🐳
|
4 |
colorFrom: gray
|
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,252 @@
|
|
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>Cloudflare LLaMA 2 Chat</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 - 180px);
|
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 |
+
.typing-indicator span {
|
21 |
+
animation: bounce 1.5s infinite ease-in-out;
|
22 |
+
display: inline-block;
|
23 |
+
}
|
24 |
+
.typing-indicator span:nth-child(2) {
|
25 |
+
animation-delay: 0.2s;
|
26 |
+
}
|
27 |
+
.typing-indicator span:nth-child(3) {
|
28 |
+
animation-delay: 0.4s;
|
29 |
+
}
|
30 |
+
@keyframes bounce {
|
31 |
+
0%, 100% { transform: translateY(0); }
|
32 |
+
50% { transform: translateY(-5px); }
|
33 |
+
}
|
34 |
+
.model-selector:hover .model-dropdown {
|
35 |
+
display: block;
|
36 |
+
}
|
37 |
+
</style>
|
38 |
+
</head>
|
39 |
+
<body class="bg-gray-100">
|
40 |
+
<div class="container mx-auto max-w-4xl px-4 py-8">
|
41 |
+
<!-- Header -->
|
42 |
+
<header class="flex items-center justify-between mb-8">
|
43 |
+
<div class="flex items-center">
|
44 |
+
<div class="w-10 h-10 bg-blue-500 rounded-lg flex items-center justify-center mr-3">
|
45 |
+
<i class="fas fa-cloud text-white text-xl"></i>
|
46 |
+
</div>
|
47 |
+
<h1 class="text-2xl font-bold text-gray-800">Cloudflare AI</h1>
|
48 |
+
</div>
|
49 |
+
<div class="relative model-selector">
|
50 |
+
<button class="bg-white px-4 py-2 rounded-lg shadow-sm border border-gray-200 flex items-center">
|
51 |
+
<span class="font-medium">LLaMA 2 7B (int8)</span>
|
52 |
+
<i class="fas fa-chevron-down ml-2 text-gray-500 text-xs"></i>
|
53 |
+
</button>
|
54 |
+
<div class="model-dropdown hidden absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg z-10 border border-gray-200">
|
55 |
+
<div class="px-4 py-2 border-b border-gray-100 bg-gray-50 text-gray-500 text-xs uppercase font-semibold">Text Generation</div>
|
56 |
+
<div class="px-4 py-3 hover:bg-blue-50 cursor-pointer font-medium text-blue-600">
|
57 |
+
<i class="fas fa-check mr-2"></i> LLaMA 2 7B (int8)
|
58 |
+
</div>
|
59 |
+
<div class="px-4 py-3 hover:bg-gray-50 cursor-pointer text-gray-700">LLaMA 2 13B (int8)</div>
|
60 |
+
<div class="px-4 py-3 hover:bg-gray-50 cursor-pointer text-gray-700">LLaMA 2 70B (int8)</div>
|
61 |
+
</div>
|
62 |
+
</div>
|
63 |
+
</header>
|
64 |
+
|
65 |
+
<!-- Model Info Card -->
|
66 |
+
<div class="bg-white rounded-xl shadow-sm p-6 mb-8 border border-gray-200">
|
67 |
+
<div class="flex items-start">
|
68 |
+
<div class="bg-blue-100 p-3 rounded-lg mr-4">
|
69 |
+
<i class="fas fa-robot text-blue-500 text-xl"></i>
|
70 |
+
</div>
|
71 |
+
<div>
|
72 |
+
<h2 class="text-lg font-bold text-gray-800 mb-1">Meta/LLaMA-2-7B-chat-int8</h2>
|
73 |
+
<p class="text-gray-600 mb-3">A 7 billion parameter version of the LLaMA 2 language model, optimized for chat and quantized to 8-bit for efficient inference.</p>
|
74 |
+
<div class="flex flex-wrap gap-2">
|
75 |
+
<span class="bg-gray-100 text-gray-700 px-3 py-1 rounded-full text-xs font-medium">7B Parameters</span>
|
76 |
+
<span class="bg-gray-100 text-gray-700 px-3 py-1 rounded-full text-xs font-medium">8-bit Quantized</span>
|
77 |
+
<span class="bg-gray-100 text-gray-700 px-3 py-1 rounded-full text-xs font-medium">Chat Optimized</span>
|
78 |
+
<span class="bg-gray-100 text-gray-700 px-3 py-1 rounded-full text-xs font-medium">Context: 4096 tokens</span>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<!-- Chat Container -->
|
85 |
+
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
86 |
+
<!-- Messages -->
|
87 |
+
<div class="chat-container overflow-y-auto p-4 space-y-4" id="chat-messages">
|
88 |
+
<div class="flex items-start">
|
89 |
+
<div class="bg-gray-200 p-2 rounded-lg mr-3">
|
90 |
+
<i class="fas fa-robot text-gray-600"></i>
|
91 |
+
</div>
|
92 |
+
<div class="bg-gray-100 rounded-lg px-4 py-3 max-w-[85%] message-animation">
|
93 |
+
<p class="text-gray-800">Hello! I'm LLaMA 2, a large language model running on Cloudflare's infrastructure. How can I assist you today?</p>
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
<!-- Input Area -->
|
99 |
+
<div class="border-t border-gray-200 p-4 bg-gray-50">
|
100 |
+
<form id="chat-form" class="flex items-end">
|
101 |
+
<div class="flex-grow mr-3">
|
102 |
+
<textarea
|
103 |
+
id="user-input"
|
104 |
+
rows="1"
|
105 |
+
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none"
|
106 |
+
placeholder="Message LLaMA 2..."
|
107 |
+
required
|
108 |
+
></textarea>
|
109 |
+
</div>
|
110 |
+
<button
|
111 |
+
type="submit"
|
112 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-5 py-3 rounded-lg transition-colors duration-200 flex items-center justify-center"
|
113 |
+
>
|
114 |
+
<i class="fas fa-paper-plane mr-2"></i>
|
115 |
+
<span>Send</span>
|
116 |
+
</button>
|
117 |
+
</form>
|
118 |
+
<div class="mt-2 text-xs text-gray-500 flex items-center">
|
119 |
+
<i class="fas fa-info-circle mr-1"></i>
|
120 |
+
<span>LLaMA 2 may produce inaccurate information. Consider checking important information.</span>
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<!-- API Info -->
|
126 |
+
<div class="mt-6 bg-white rounded-xl shadow-sm p-6 border border-gray-200">
|
127 |
+
<h3 class="font-bold text-gray-800 mb-3 flex items-center">
|
128 |
+
<i class="fas fa-code mr-2 text-blue-500"></i>
|
129 |
+
API Usage
|
130 |
+
</h3>
|
131 |
+
<div class="bg-gray-800 rounded-lg p-4 mb-4 overflow-x-auto">
|
132 |
+
<pre class="text-gray-300 text-sm"><code>curl -X POST \
|
133 |
+
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/meta/llama-2-7b-chat-int8 \
|
134 |
+
-H "Authorization: Bearer {api_token}" \
|
135 |
+
-H "Content-Type: application/json" \
|
136 |
+
-d '{"messages":[{"role":"user","content":"Explain quantum computing"}]}'</code></pre>
|
137 |
+
</div>
|
138 |
+
<div class="flex items-center text-sm text-gray-600">
|
139 |
+
<i class="fas fa-link mr-2"></i>
|
140 |
+
<a href="https://developers.cloudflare.com/workers-ai/models/text-generation/" class="text-blue-500 hover:underline">View API documentation</a>
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
|
145 |
+
<script>
|
146 |
+
document.addEventListener('DOMContentLoaded', function() {
|
147 |
+
const chatForm = document.getElementById('chat-form');
|
148 |
+
const userInput = document.getElementById('user-input');
|
149 |
+
const chatMessages = document.getElementById('chat-messages');
|
150 |
+
|
151 |
+
// Auto-resize textarea
|
152 |
+
userInput.addEventListener('input', function() {
|
153 |
+
this.style.height = 'auto';
|
154 |
+
this.style.height = (this.scrollHeight) + 'px';
|
155 |
+
});
|
156 |
+
|
157 |
+
// Sample responses to simulate the model
|
158 |
+
const sampleResponses = [
|
159 |
+
"I'm an AI assistant based on Meta's LLaMA 2 model. I can help answer questions, explain concepts, or assist with creative writing.",
|
160 |
+
"LLaMA 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters.",
|
161 |
+
"The int8 quantization reduces the model's memory footprint while maintaining reasonable accuracy, making it more efficient to run.",
|
162 |
+
"Cloudflare's Workers AI platform allows you to run models like me at the edge, close to your users for low latency.",
|
163 |
+
"I can understand and generate human-like text, but I don't have real-time information or access to the internet."
|
164 |
+
];
|
165 |
+
|
166 |
+
chatForm.addEventListener('submit', function(e) {
|
167 |
+
e.preventDefault();
|
168 |
+
const message = userInput.value.trim();
|
169 |
+
if (!message) return;
|
170 |
+
|
171 |
+
// Add user message
|
172 |
+
addMessage('user', message);
|
173 |
+
userInput.value = '';
|
174 |
+
userInput.style.height = 'auto';
|
175 |
+
|
176 |
+
// Show typing indicator
|
177 |
+
const typingId = showTypingIndicator();
|
178 |
+
|
179 |
+
// Simulate API delay and response
|
180 |
+
setTimeout(() => {
|
181 |
+
// Remove typing indicator
|
182 |
+
removeTypingIndicator(typingId);
|
183 |
+
|
184 |
+
// Get random sample response
|
185 |
+
const response = sampleResponses[Math.floor(Math.random() * sampleResponses.length)];
|
186 |
+
|
187 |
+
// Add AI response
|
188 |
+
addMessage('ai', response);
|
189 |
+
}, 1500 + Math.random() * 2000); // Random delay between 1.5-3.5s
|
190 |
+
});
|
191 |
+
|
192 |
+
function addMessage(role, content) {
|
193 |
+
const messageDiv = document.createElement('div');
|
194 |
+
messageDiv.className = 'flex items-start message-animation';
|
195 |
+
|
196 |
+
if (role === 'user') {
|
197 |
+
messageDiv.innerHTML = `
|
198 |
+
<div class="ml-auto max-w-[85%] flex flex-row-reverse">
|
199 |
+
<div class="bg-gray-200 p-2 rounded-lg ml-3">
|
200 |
+
<i class="fas fa-user text-gray-600"></i>
|
201 |
+
</div>
|
202 |
+
<div class="bg-blue-100 rounded-lg px-4 py-3">
|
203 |
+
<p class="text-gray-800">${content}</p>
|
204 |
+
</div>
|
205 |
+
</div>
|
206 |
+
`;
|
207 |
+
} else {
|
208 |
+
messageDiv.innerHTML = `
|
209 |
+
<div class="bg-gray-200 p-2 rounded-lg mr-3">
|
210 |
+
<i class="fas fa-robot text-gray-600"></i>
|
211 |
+
</div>
|
212 |
+
<div class="bg-gray-100 rounded-lg px-4 py-3 max-w-[85%]">
|
213 |
+
<p class="text-gray-800">${content}</p>
|
214 |
+
</div>
|
215 |
+
`;
|
216 |
+
}
|
217 |
+
|
218 |
+
chatMessages.appendChild(messageDiv);
|
219 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
220 |
+
}
|
221 |
+
|
222 |
+
function showTypingIndicator() {
|
223 |
+
const id = 'typing-' + Date.now();
|
224 |
+
const typingDiv = document.createElement('div');
|
225 |
+
typingDiv.id = id;
|
226 |
+
typingDiv.className = 'flex items-start';
|
227 |
+
typingDiv.innerHTML = `
|
228 |
+
<div class="bg-gray-200 p-2 rounded-lg mr-3">
|
229 |
+
<i class="fas fa-robot text-gray-600"></i>
|
230 |
+
</div>
|
231 |
+
<div class="bg-gray-100 rounded-lg px-4 py-3 max-w-[85%] typing-indicator">
|
232 |
+
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full"></span>
|
233 |
+
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full ml-1"></span>
|
234 |
+
<span class="inline-block w-2 h-2 bg-gray-500 rounded-full ml-1"></span>
|
235 |
+
</div>
|
236 |
+
`;
|
237 |
+
|
238 |
+
chatMessages.appendChild(typingDiv);
|
239 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
240 |
+
return id;
|
241 |
+
}
|
242 |
+
|
243 |
+
function removeTypingIndicator(id) {
|
244 |
+
const element = document.getElementById(id);
|
245 |
+
if (element) {
|
246 |
+
element.remove();
|
247 |
+
}
|
248 |
+
}
|
249 |
+
});
|
250 |
+
</script>
|
251 |
+
<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=privateuserh/llm" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
252 |
+
</html>
|