Askoscar commited on
Commit
b55a14c
·
verified ·
1 Parent(s): b240fc3

Upload 5 files

Browse files
Files changed (5) hide show
  1. c46cfe98-a47f-4596-a93b-ea93bb8806f3.jpg +0 -0
  2. index.html +310 -19
  3. runtime.yaml +1 -0
  4. script.js +59 -0
  5. style.css +112 -28
c46cfe98-a47f-4596-a93b-ea93bb8806f3.jpg ADDED
index.html CHANGED
@@ -1,19 +1,310 @@
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>AskOscar Herbal AI 🌿</title>
7
+ <style>
8
+ body {
9
+ font-family: "Garamond", serif;
10
+ background-image: url("c46cfe98-a47f-4596-a93b-ea93bb8806f3.jpg");
11
+ background-size: cover;
12
+ background-position: center;
13
+ color: #fff;
14
+ text-align: center;
15
+ height: 100vh;
16
+ margin: 0;
17
+ display: flex;
18
+ flex-direction: column;
19
+ justify-content: center;
20
+ backdrop-filter: brightness(0.4);
21
+ }
22
+
23
+ h1 {
24
+ font-size: 2.5em;
25
+ margin-bottom: 10px;
26
+ text-shadow: 2px 2px 5px #000;
27
+ }
28
+
29
+ p {
30
+ margin-top: 0;
31
+ font-size: 1.2em;
32
+ text-shadow: 1px 1px 3px #000;
33
+ }
34
+
35
+ .container {
36
+ background-color: rgba(0, 0, 0, 0.6);
37
+ border-radius: 20px;
38
+ padding: 30px;
39
+ max-width: 650px;
40
+ margin: 0 auto;
41
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
42
+ display: flex;
43
+ flex-direction: column;
44
+ align-items: center;
45
+ height: 80vh;
46
+ }
47
+
48
+ #chat-box {
49
+ background-color: rgba(255, 255, 255, 0.1);
50
+ border-radius: 10px;
51
+ padding: 15px;
52
+ width: 100%;
53
+ height: 65%;
54
+ overflow-y: auto;
55
+ text-align: left;
56
+ margin-bottom: 15px;
57
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
58
+ }
59
+
60
+ .message {
61
+ margin-bottom: 15px;
62
+ line-height: 1.4em;
63
+ }
64
+
65
+ .user {
66
+ text-align: right;
67
+ color: #aef7c7;
68
+ }
69
+
70
+ .bot {
71
+ text-align: left;
72
+ color: #fffbe6;
73
+ }
74
+
75
+ .input-container {
76
+ width: 100%;
77
+ display: flex;
78
+ justify-content: center;
79
+ align-items: center;
80
+ }
81
+
82
+ input {
83
+ width: 70%;
84
+ padding: 12px;
85
+ border: none;
86
+ border-radius: 10px;
87
+ font-size: 1em;
88
+ margin-top: 10px;
89
+ }
90
+
91
+ button {
92
+ background-color: #00b894;
93
+ border: none;
94
+ border-radius: 10px;
95
+ padding: 12px 20px;
96
+ font-size: 1em;
97
+ color: white;
98
+ cursor: pointer;
99
+ margin-left: 10px;
100
+ transition: background 0.3s ease;
101
+ }
102
+
103
+ button:hover {
104
+ background-color: #019870;
105
+ }
106
+
107
+ .top-buttons {
108
+ position: absolute;
109
+ top: 15px;
110
+ right: 15px;
111
+ display: flex;
112
+ gap: 10px;
113
+ z-index: 1000;
114
+ }
115
+
116
+ .top-buttons button {
117
+ background-color: #019870;
118
+ border-radius: 8px;
119
+ padding: 8px 14px;
120
+ font-size: 0.9em;
121
+ }
122
+
123
+ footer {
124
+ position: absolute;
125
+ bottom: 10px;
126
+ width: 100%;
127
+ text-align: center;
128
+ font-size: 0.9em;
129
+ color: #ccc;
130
+ }
131
+
132
+ /* Modal Styling */
133
+ .modal {
134
+ display: none;
135
+ position: fixed;
136
+ z-index: 999;
137
+ left: 0;
138
+ top: 0;
139
+ width: 100%;
140
+ height: 100%;
141
+ overflow: auto;
142
+ background-color: rgba(0, 0, 0, 0.8);
143
+ }
144
+
145
+ .modal-content {
146
+ background-color: #222;
147
+ margin: 15% auto;
148
+ padding: 20px;
149
+ border-radius: 10px;
150
+ width: 80%;
151
+ max-width: 500px;
152
+ text-align: left;
153
+ color: #eee;
154
+ box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
155
+ }
156
+
157
+ .close {
158
+ color: #aaa;
159
+ float: right;
160
+ font-size: 22px;
161
+ cursor: pointer;
162
+ }
163
+
164
+ .close:hover {
165
+ color: white;
166
+ }
167
+ </style>
168
+ </head>
169
+ <body>
170
+ <div class="top-buttons">
171
+ <button id="aboutBtn">About</button>
172
+ <button id="donateBtn">Donate</button>
173
+ </div>
174
+
175
+ <div class="container">
176
+ <h1>🌿 AskOscar Herbal AI 🌿</h1>
177
+ <p>Ask me anything about medicinal plants, healing herbs, or natural remedies.</p>
178
+
179
+ <div id="chat-box"></div>
180
+
181
+ <div class="input-container">
182
+ <input id="userInput" placeholder="Ask about any medicinal plant..." />
183
+ <button id="askButton">Send</button>
184
+ </div>
185
+ </div>
186
+
187
+ <footer>Powered by Hugging Face • Herbal Wisdom by Oscar</footer>
188
+
189
+ <!-- About Modal -->
190
+ <div id="aboutModal" class="modal">
191
+ <div class="modal-content">
192
+ <span class="close" id="closeAbout">&times;</span>
193
+ <h2>About Oscar Teye</h2>
194
+ <p>
195
+ Oscar Teye is the visionary founder of <strong>AskOscar.ai</strong> — a digital herbal intelligence
196
+ created to reconnect humanity with the healing power of nature.
197
+ Born with a passion for natural medicine and innovation, Oscar blends African herbal wisdom with
198
+ artificial intelligence to make herbal knowledge accessible, practical, and inspiring for all.
199
+ </p>
200
+ </div>
201
+ </div>
202
+
203
+ <!-- Donate Modal -->
204
+ <div id="donateModal" class="modal">
205
+ <div class="modal-content">
206
+ <span class="close" id="closeDonate">&times;</span>
207
+ <h2>Support AskOscar.ai</h2>
208
+ <p>
209
+ 🌿 Every seed of support helps this herbal AI grow stronger!
210
+ If you believe in natural healing and want to keep AskOscar.ai running,
211
+ you can support through donations.
212
+ </p>
213
+ <p><strong>Ways to Support:</strong></p>
214
+ <ul>
215
+ <li>Mobile Money: +233 XXX XXX XXX</li>
216
+ <li>PayPal: coming soon</li>
217
+ <li>Share the website with friends 🌍</li>
218
+ </ul>
219
+ <p>Thank you for helping sustain a greener, wiser future 🌱</p>
220
+ </div>
221
+ </div>
222
+
223
+ <script>
224
+ document.addEventListener("DOMContentLoaded", () => {
225
+ const API_URL = "https://api-inference.huggingface.co/models/google/gemma-2b-it";
226
+ const HF_TOKEN = "hf_your_token_here"; // Replace with your actual Hugging Face token
227
+
228
+ async function askOscarAI(question) {
229
+ const herbalWords = ["plant", "herb", "leaves", "roots", "bark", "healing", "natural", "disease", "dosage", "scientific name"];
230
+ const isHerbal = herbalWords.some(word => question.toLowerCase().includes(word));
231
+
232
+ if (!isHerbal) {
233
+ return "🍃 Sorry, I only answer questions about medicinal plants, natural healing, and herbal remedies.";
234
+ }
235
+
236
+ const prompt = `
237
+ You are AskOscar Herbal AI — an expert in natural and traditional medicine.
238
+ Respond like a warm, intelligent herbalist from Ghana, giving scientific names, local names, healing uses, dosage, and any cultural facts.
239
+ User's question: ${question}
240
+ `;
241
+
242
+ try {
243
+ const response = await fetch(API_URL, {
244
+ method: "POST",
245
+ headers: {
246
+ "Authorization": \`Bearer \${HF_TOKEN}\`,
247
+ "Content-Type": "application/json",
248
+ },
249
+ body: JSON.stringify({ inputs: prompt }),
250
+ });
251
+
252
+ const result = await response.json();
253
+ if (result.error) return "🌿 The herbal spirits are resting... please try again soon.";
254
+ return result[0]?.generated_text || "No response received.";
255
+ } catch (error) {
256
+ console.error(error);
257
+ return "⚠️ Unable to connect to the herbal network. Check your internet or token.";
258
+ }
259
+ }
260
+
261
+ const chatBox = document.getElementById("chat-box");
262
+ const input = document.getElementById("userInput");
263
+ const sendBtn = document.getElementById("askButton");
264
+
265
+ sendBtn.addEventListener("click", async () => {
266
+ const question = input.value.trim();
267
+ if (!question) return;
268
+
269
+ const userMsg = document.createElement("div");
270
+ userMsg.classList.add("message", "user");
271
+ userMsg.textContent = "🧍 " + question;
272
+ chatBox.appendChild(userMsg);
273
+
274
+ const botMsg = document.createElement("div");
275
+ botMsg.classList.add("message", "bot");
276
+ botMsg.textContent = "🌿 Thinking...";
277
+ chatBox.appendChild(botMsg);
278
+ chatBox.scrollTop = chatBox.scrollHeight;
279
+
280
+ input.value = "";
281
+
282
+ const answer = await askOscarAI(question);
283
+ botMsg.textContent = "🪴 " + answer;
284
+ chatBox.scrollTop = chatBox.scrollHeight;
285
+ });
286
+
287
+ // Handle modals
288
+ const aboutModal = document.getElementById("aboutModal");
289
+ const donateModal = document.getElementById("donateModal");
290
+
291
+ const aboutBtn = document.getElementById("aboutBtn");
292
+ const donateBtn = document.getElementById("donateBtn");
293
+
294
+ const closeAbout = document.getElementById("closeAbout");
295
+ const closeDonate = document.getElementById("closeDonate");
296
+
297
+ aboutBtn.onclick = () => (aboutModal.style.display = "block");
298
+ donateBtn.onclick = () => (donateModal.style.display = "block");
299
+
300
+ closeAbout.onclick = () => (aboutModal.style.display = "none");
301
+ closeDonate.onclick = () => (donateModal.style.display = "none");
302
+
303
+ window.onclick = (event) => {
304
+ if (event.target === aboutModal) aboutModal.style.display = "none";
305
+ if (event.target === donateModal) donateModal.style.display = "none";
306
+ };
307
+ });
308
+ </script>
309
+ </body>
310
+ </html>
runtime.yaml ADDED
@@ -0,0 +1 @@
 
 
1
+ sdk: static
script.js ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ const aboutBtn = document.getElementById("aboutBtn");
3
+ const donateBtn = document.getElementById("donateBtn");
4
+ const aboutModal = document.getElementById("aboutModal");
5
+ const donateModal = document.getElementById("donateModal");
6
+ const closeAbout = document.getElementById("closeAbout");
7
+ const closeDonate = document.getElementById("closeDonate");
8
+ const sendBtn = document.getElementById("askButton");
9
+ const chatBox = document.getElementById("chat-box");
10
+ const input = document.getElementById("userInput");
11
+
12
+ // open / close modals
13
+ aboutBtn.onclick = () => aboutModal.style.display = "block";
14
+ donateBtn.onclick = () => donateModal.style.display = "block";
15
+ closeAbout.onclick = () => aboutModal.style.display = "none";
16
+ closeDonate.onclick = () => donateModal.style.display = "none";
17
+ window.onclick = e => {
18
+ if (e.target === aboutModal) aboutModal.style.display = "none";
19
+ if (e.target === donateModal) donateModal.style.display = "none";
20
+ };
21
+
22
+ // send message
23
+ sendBtn.onclick = sendMessage;
24
+ input.addEventListener("keydown", e => { if (e.key === "Enter") sendMessage(); });
25
+
26
+ function appendMessage(who, text) {
27
+ const div = document.createElement("div");
28
+ div.classList.add("message", who);
29
+ div.textContent = (who === "user" ? "🧍 " : "🪴 ") + text;
30
+ chatBox.appendChild(div);
31
+ chatBox.scrollTop = chatBox.scrollHeight;
32
+ }
33
+
34
+ function sendMessage() {
35
+ const q = input.value.trim();
36
+ if (!q) return;
37
+ appendMessage("user", q);
38
+ input.value = "";
39
+ appendMessage("bot", "🌿 Thinking...");
40
+ setTimeout(() => {
41
+ const a = simulateHerbalAnswer(q);
42
+ replaceLastBotMessage(a);
43
+ }, 1000);
44
+ }
45
+
46
+ function replaceLastBotMessage(text) {
47
+ const bots = chatBox.querySelectorAll(".bot");
48
+ if (bots.length === 0) return appendMessage("bot", text);
49
+ bots[bots.length - 1].textContent = "🪴 " + text;
50
+ }
51
+
52
+ function simulateHerbalAnswer(q) {
53
+ const s = q.toLowerCase();
54
+ if (s.includes("moringa")) return "Moringa oleifera — known locally as Nkruma. Rich in nutrients and supports **anti-inflammatory** and **antioxidant** activity.";
55
+ if (s.includes("neem")) return "Azadirachta indica (Neem). Locally Nkwanta. Famous for **antimicrobial** and **skin-cleansing** effects.";
56
+ if (s.includes("hello") || s.includes("hi")) return "Hello 🌿! Ask about any medicinal plant or natural remedy.";
57
+ return "I’m trained for herbal knowledge. Try asking about a plant, its healing uses, or safe dosage.";
58
+ }
59
+ });
style.css CHANGED
@@ -1,28 +1,112 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
-
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
- }
10
-
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
- }
17
-
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
- }
25
-
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: Garamond, serif;
3
+ background-image: url("c46cfe98-a47f-4596-a93b-ea93bb8806f3.jpg");
4
+ background-size: cover;
5
+ background-position: center;
6
+ color: #fff;
7
+ margin: 0;
8
+ height: 100vh;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ text-align: center;
13
+ backdrop-filter: brightness(0.4);
14
+ }
15
+
16
+ .container {
17
+ background-color: rgba(0, 0, 0, 0.6);
18
+ border-radius: 20px;
19
+ padding: 30px;
20
+ width: 90%;
21
+ max-width: 600px;
22
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
23
+ }
24
+
25
+ h1 {
26
+ font-size: 2.2em;
27
+ margin: 0 0 10px;
28
+ text-shadow: 2px 2px 5px #000;
29
+ }
30
+
31
+ p { text-shadow: 1px 1px 3px #000; }
32
+
33
+ .chat-window {
34
+ background-color: rgba(255,255,255,0.1);
35
+ border-radius: 10px;
36
+ height: 300px;
37
+ overflow-y: auto;
38
+ padding: 10px;
39
+ text-align: left;
40
+ margin-top: 15px;
41
+ }
42
+
43
+ .input-row {
44
+ display: flex;
45
+ margin-top: 10px;
46
+ justify-content: center;
47
+ }
48
+
49
+ input {
50
+ flex: 1;
51
+ padding: 10px;
52
+ border: none;
53
+ border-radius: 8px;
54
+ font-size: 1em;
55
+ }
56
+
57
+ button {
58
+ background-color: #00b894;
59
+ border: none;
60
+ border-radius: 8px;
61
+ padding: 10px 16px;
62
+ font-size: 1em;
63
+ color: white;
64
+ margin-left: 10px;
65
+ cursor: pointer;
66
+ }
67
+
68
+ button:hover { background-color: #019870; }
69
+
70
+ .buttons {
71
+ margin-top: 15px;
72
+ }
73
+
74
+ .modal {
75
+ display: none;
76
+ position: fixed;
77
+ z-index: 10;
78
+ left: 0; top: 0;
79
+ width: 100%; height: 100%;
80
+ background-color: rgba(0,0,0,0.7);
81
+ }
82
+
83
+ .modal-content {
84
+ background-color: #333;
85
+ margin: 10% auto;
86
+ padding: 20px;
87
+ border-radius: 10px;
88
+ width: 80%;
89
+ max-width: 400px;
90
+ color: #fff;
91
+ }
92
+
93
+ .close {
94
+ float: right;
95
+ font-size: 1.5em;
96
+ cursor: pointer;
97
+ }
98
+
99
+ .message {
100
+ margin: 8px 0;
101
+ padding: 6px 10px;
102
+ border-radius: 10px;
103
+ }
104
+
105
+ .user {
106
+ background: rgba(255,255,255,0.2);
107
+ align-self: flex-end;
108
+ }
109
+
110
+ .bot {
111
+ background: rgba(0,0,0,0.4);
112
+ }