Spaces:
Running
Running
Add 3 files
Browse files- README.md +6 -4
- index.html +318 -19
- prompts.txt +0 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
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: food-dora
|
3 |
+
emoji: π³
|
4 |
+
colorFrom: gray
|
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,318 @@
|
|
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>Food Dora - Your Recipe Helper</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 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js"></script>
|
10 |
+
<style>
|
11 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
12 |
+
|
13 |
+
body {
|
14 |
+
font-family: 'Poppins', sans-serif;
|
15 |
+
background-color: #f9f9f9;
|
16 |
+
height: 100vh;
|
17 |
+
overflow: hidden;
|
18 |
+
}
|
19 |
+
|
20 |
+
.message-bubble {
|
21 |
+
max-width: 80%;
|
22 |
+
word-wrap: break-word;
|
23 |
+
}
|
24 |
+
|
25 |
+
.user-message {
|
26 |
+
background-color: #4f46e5;
|
27 |
+
color: white;
|
28 |
+
border-radius: 18px 18px 0 18px;
|
29 |
+
}
|
30 |
+
|
31 |
+
.bot-message {
|
32 |
+
background-color: white;
|
33 |
+
color: #333;
|
34 |
+
border-radius: 18px 18px 18px 0;
|
35 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
36 |
+
}
|
37 |
+
|
38 |
+
.typing-indicator {
|
39 |
+
display: flex;
|
40 |
+
padding: 10px;
|
41 |
+
}
|
42 |
+
|
43 |
+
.typing-dot {
|
44 |
+
width: 8px;
|
45 |
+
height: 8px;
|
46 |
+
background-color: #999;
|
47 |
+
border-radius: 50%;
|
48 |
+
margin: 0 2px;
|
49 |
+
animation: typing 1.4s infinite ease-in-out;
|
50 |
+
}
|
51 |
+
|
52 |
+
.typing-dot:nth-child(1) {
|
53 |
+
animation-delay: 0s;
|
54 |
+
}
|
55 |
+
|
56 |
+
.typing-dot:nth-child(2) {
|
57 |
+
animation-delay: 0.2s;
|
58 |
+
}
|
59 |
+
|
60 |
+
.typing-dot:nth-child(3) {
|
61 |
+
animation-delay: 0.4s;
|
62 |
+
}
|
63 |
+
|
64 |
+
@keyframes typing {
|
65 |
+
0%, 60%, 100% {
|
66 |
+
transform: translateY(0);
|
67 |
+
}
|
68 |
+
30% {
|
69 |
+
transform: translateY(-5px);
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
.suggestions {
|
74 |
+
display: flex;
|
75 |
+
overflow-x: auto;
|
76 |
+
padding: 10px 0;
|
77 |
+
gap: 8px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.suggestion-chip {
|
81 |
+
background-color: #e0e7ff;
|
82 |
+
color: #4f46e5;
|
83 |
+
border-radius: 20px;
|
84 |
+
padding: 8px 16px;
|
85 |
+
font-size: 14px;
|
86 |
+
white-space: nowrap;
|
87 |
+
cursor: pointer;
|
88 |
+
transition: all 0.2s;
|
89 |
+
}
|
90 |
+
|
91 |
+
.suggestion-chip:hover {
|
92 |
+
background-color: #c7d2fe;
|
93 |
+
}
|
94 |
+
|
95 |
+
.recipe-card {
|
96 |
+
border-radius: 12px;
|
97 |
+
overflow: hidden;
|
98 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
99 |
+
}
|
100 |
+
|
101 |
+
.recipe-image {
|
102 |
+
height: 180px;
|
103 |
+
background-size: cover;
|
104 |
+
background-position: center;
|
105 |
+
}
|
106 |
+
</style>
|
107 |
+
</head>
|
108 |
+
<body class="flex flex-col h-screen">
|
109 |
+
<!-- Header -->
|
110 |
+
<header class="bg-indigo-600 text-white p-4 shadow-md">
|
111 |
+
<div class="flex items-center justify-between">
|
112 |
+
<div class="flex items-center">
|
113 |
+
<i class="fas fa-utensils text-2xl mr-3"></i>
|
114 |
+
<h1 class="text-xl font-bold">Food Dora</h1>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
</header>
|
118 |
+
|
119 |
+
<!-- Chat Container -->
|
120 |
+
<div id="chat-container" class="flex-1 overflow-y-auto p-4 space-y-4">
|
121 |
+
<!-- Welcome Message -->
|
122 |
+
<div class="flex items-start">
|
123 |
+
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
|
124 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
125 |
+
</div>
|
126 |
+
<div class="message-bubble bot-message p-4">
|
127 |
+
<p>Hi there! π I'm Food Dora, your personal recipe helper. What would you like to cook today?</p>
|
128 |
+
<div class="suggestions mt-2">
|
129 |
+
<div class="suggestion-chip" onclick="sendSuggestion(this)">Quick dinner ideas</div>
|
130 |
+
<div class="suggestion-chip" onclick="sendSuggestion(this)">Vegetarian recipes</div>
|
131 |
+
<div class="suggestion-chip" onclick="sendSuggestion(this)">Low-carb meals</div>
|
132 |
+
<div class="suggestion-chip" onclick="sendSuggestion(this)">Dessert recipes</div>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
|
138 |
+
<!-- Input Area -->
|
139 |
+
<div class="p-4 border-t border-gray-200 bg-white">
|
140 |
+
<div class="flex items-center">
|
141 |
+
<input
|
142 |
+
id="user-input"
|
143 |
+
type="text"
|
144 |
+
placeholder="Type your recipe request..."
|
145 |
+
class="flex-1 border border-gray-300 rounded-full py-2 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
146 |
+
onkeypress="handleKeyPress(event)"
|
147 |
+
>
|
148 |
+
<button
|
149 |
+
id="send-btn"
|
150 |
+
class="ml-2 bg-indigo-600 text-white rounded-full p-2 w-12 h-12 flex items-center justify-center focus:outline-none hover:bg-indigo-700 transition"
|
151 |
+
onclick="sendMessage()"
|
152 |
+
>
|
153 |
+
<i class="fas fa-paper-plane"></i>
|
154 |
+
</button>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
|
158 |
+
<script>
|
159 |
+
// Generate a UUID for the session
|
160 |
+
const sessionId = uuid.v4();
|
161 |
+
|
162 |
+
// DOM elements
|
163 |
+
const chatContainer = document.getElementById('chat-container');
|
164 |
+
const userInput = document.getElementById('user-input');
|
165 |
+
const sendBtn = document.getElementById('send-btn');
|
166 |
+
|
167 |
+
// API configuration
|
168 |
+
const API_URL = 'https://api-controller.easybits.tech/api/392';
|
169 |
+
const AUTH_TOKEN = 'Bearer 5390f593-db0c-4611-82ee-f1d4ede82467';
|
170 |
+
|
171 |
+
// Show typing indicator
|
172 |
+
function showTypingIndicator() {
|
173 |
+
const typingDiv = document.createElement('div');
|
174 |
+
typingDiv.className = 'flex items-start';
|
175 |
+
typingDiv.innerHTML = `
|
176 |
+
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
|
177 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
178 |
+
</div>
|
179 |
+
<div class="message-bubble bot-message p-3">
|
180 |
+
<div class="typing-indicator">
|
181 |
+
<div class="typing-dot"></div>
|
182 |
+
<div class="typing-dot"></div>
|
183 |
+
<div class="typing-dot"></div>
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
`;
|
187 |
+
chatContainer.appendChild(typingDiv);
|
188 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
189 |
+
return typingDiv;
|
190 |
+
}
|
191 |
+
|
192 |
+
// Remove typing indicator
|
193 |
+
function removeTypingIndicator(indicator) {
|
194 |
+
if (indicator && indicator.parentNode) {
|
195 |
+
indicator.parentNode.removeChild(indicator);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// Add user message to chat
|
200 |
+
function addUserMessage(text) {
|
201 |
+
const messageDiv = document.createElement('div');
|
202 |
+
messageDiv.className = 'flex items-start justify-end';
|
203 |
+
messageDiv.innerHTML = `
|
204 |
+
<div class="message-bubble user-message p-4">
|
205 |
+
<p>${text}</p>
|
206 |
+
</div>
|
207 |
+
<div class="w-10 h-10 rounded-full bg-indigo-600 flex items-center justify-center ml-3">
|
208 |
+
<i class="fas fa-user text-white"></i>
|
209 |
+
</div>
|
210 |
+
`;
|
211 |
+
chatContainer.appendChild(messageDiv);
|
212 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
213 |
+
}
|
214 |
+
|
215 |
+
// Add bot message to chat
|
216 |
+
function addBotMessage(text) {
|
217 |
+
const messageDiv = document.createElement('div');
|
218 |
+
messageDiv.className = 'flex items-start';
|
219 |
+
const printText = text.replaceAll("\n", "<br/>");
|
220 |
+
messageDiv.innerHTML = `
|
221 |
+
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
|
222 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
223 |
+
</div>
|
224 |
+
<div class="message-bubble bot-message p-4">
|
225 |
+
<p>${printText}</p>
|
226 |
+
</div>
|
227 |
+
`;
|
228 |
+
chatContainer.appendChild(messageDiv);
|
229 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
230 |
+
}
|
231 |
+
|
232 |
+
// Send message to API
|
233 |
+
async function sendMessage() {
|
234 |
+
const message = userInput.value.trim();
|
235 |
+
if (!message) return;
|
236 |
+
|
237 |
+
addUserMessage(message);
|
238 |
+
userInput.value = '';
|
239 |
+
|
240 |
+
const typingIndicator = showTypingIndicator();
|
241 |
+
|
242 |
+
try {
|
243 |
+
const payload = {
|
244 |
+
message: {
|
245 |
+
recipient_id: sessionId,
|
246 |
+
text: message
|
247 |
+
},
|
248 |
+
timestamp: Math.floor(Date.now() / 1000)
|
249 |
+
};
|
250 |
+
|
251 |
+
const response = await fetch(API_URL, {
|
252 |
+
method: 'POST',
|
253 |
+
headers: {
|
254 |
+
'Content-Type': 'application/json',
|
255 |
+
'Authorization': AUTH_TOKEN
|
256 |
+
},
|
257 |
+
body: JSON.stringify(payload)
|
258 |
+
});
|
259 |
+
|
260 |
+
const data = await response.json();
|
261 |
+
removeTypingIndicator(typingIndicator);
|
262 |
+
if (data && data.message.data) {
|
263 |
+
addBotMessage(data.message.data);
|
264 |
+
} else {
|
265 |
+
addBotMessage("I couldn't process your request. Could you try again?");
|
266 |
+
}
|
267 |
+
} catch (error) {
|
268 |
+
removeTypingIndicator(typingIndicator);
|
269 |
+
addBotMessage("Oops! Something went wrong. Please check your connection and try again.");
|
270 |
+
console.error('Error:', error);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
// Handle Enter key press
|
275 |
+
function handleKeyPress(event) {
|
276 |
+
if (event.key === 'Enter') {
|
277 |
+
sendMessage();
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
// Send suggestion message
|
282 |
+
function sendSuggestion(element) {
|
283 |
+
const suggestion = element.textContent;
|
284 |
+
userInput.value = suggestion;
|
285 |
+
sendMessage();
|
286 |
+
}
|
287 |
+
|
288 |
+
// Example of how to handle recipe cards (you would parse API response to create these)
|
289 |
+
function addRecipeCard(recipe) {
|
290 |
+
const cardDiv = document.createElement('div');
|
291 |
+
cardDiv.className = 'flex items-start mb-4';
|
292 |
+
cardDiv.innerHTML = `
|
293 |
+
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
|
294 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
295 |
+
</div>
|
296 |
+
<div class="message-bubble bot-message p-0 w-full">
|
297 |
+
<div class="recipe-card">
|
298 |
+
<div class="recipe-image" style="background-image: url('${recipe.image}')"></div>
|
299 |
+
<div class="p-4">
|
300 |
+
<h3 class="font-bold text-lg mb-2">${recipe.title}</h3>
|
301 |
+
<div class="flex items-center text-sm text-gray-600 mb-2">
|
302 |
+
<i class="fas fa-clock mr-1"></i>
|
303 |
+
<span class="mr-3">${recipe.time}</span>
|
304 |
+
<i class="fas fa-utensils mr-1"></i>
|
305 |
+
<span>${recipe.servings}</span>
|
306 |
+
</div>
|
307 |
+
<p class="text-sm mb-3">${recipe.description}</p>
|
308 |
+
<button class="text-indigo-600 font-medium text-sm">View Full Recipe</button>
|
309 |
+
</div>
|
310 |
+
</div>
|
311 |
+
</div>
|
312 |
+
`;
|
313 |
+
chatContainer.appendChild(cardDiv);
|
314 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
315 |
+
}
|
316 |
+
</script>
|
317 |
+
<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=philipp-zettl/food-dora" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
318 |
+
</html>
|
prompts.txt
ADDED
File without changes
|