Update index.html
Browse files- index.html +27 -37
index.html
CHANGED
@@ -1,49 +1,39 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
-
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite
|
5 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite
|
6 |
</head>
|
7 |
<body>
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
transformers_js_py
|
12 |
-
</gradio-requirements>
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
"A new opportunity will present itself soon.",
|
22 |
-
"Your creativity will lead you to success.",
|
23 |
-
"An unexpected journey will bring you joy.",
|
24 |
-
"A wise decision lies ahead of you.",
|
25 |
-
"Your kindness will be rewarded tenfold.",
|
26 |
-
"A long-lost friend will reenter your life.",
|
27 |
-
"Your persistence will overcome current challenges.",
|
28 |
-
"A positive change is on the horizon."
|
29 |
-
]
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
fortune_output = gr.Textbox(label="Your Fortune")
|
41 |
-
submit_button = gr.Button("Get Fortune")
|
42 |
-
|
43 |
-
submit_button.click(fn=get_fortune, inputs=name_input, outputs=fortune_output)
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
</body>
|
49 |
</html>
|
|
|
|
|
1 |
<html>
|
2 |
<head>
|
3 |
+
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
|
4 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
|
5 |
</head>
|
6 |
<body>
|
7 |
+
<gradio-lite>
|
8 |
+
<gradio-requirements>transformers_js_py</gradio-requirements>
|
9 |
+
<gradio-file name="app.py" entrypoint>
|
10 |
+
from transformers_js import pipeline
|
11 |
+
import gradio as gr
|
12 |
|
13 |
+
fortune_generator = await pipeline('text-generation', 'Xenova/distilgpt2')
|
|
|
|
|
14 |
|
15 |
+
async def generate_fortune(name):
|
16 |
+
if not name.strip():
|
17 |
+
return "Please enter your name to receive a fortune."
|
18 |
|
19 |
+
prompt = f"Fortune for {name}: In the near future, you will"
|
20 |
+
result = await fortune_generator(prompt, max_new_tokens=30, temperature=0.7)
|
21 |
+
fortune = result[0]['generated_text'].replace(prompt, '')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
return f"{name.strip()}, your fortune: In the near future, you will{fortune}"
|
24 |
+
|
25 |
+
with gr.Blocks(title="AI Fortune Cookie Generator") as demo:
|
26 |
+
gr.Markdown("# 🥠 AI Fortune Cookie Generator")
|
27 |
+
gr.Markdown("Enter your name and receive a personalized AI-generated fortune!")
|
28 |
|
29 |
+
name_input = gr.Textbox(label="Your Name")
|
30 |
+
fortune_output = gr.Textbox(label="Your AI-Generated Fortune")
|
31 |
+
submit_button = gr.Button("🔮 Reveal Your Fortune")
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
submit_button.click(fn=generate_fortune, inputs=name_input, outputs=fortune_output)
|
34 |
+
|
35 |
+
demo.launch()
|
36 |
+
</gradio-file>
|
37 |
+
</gradio-lite>
|
38 |
</body>
|
39 |
</html>
|