Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
3 |
|
4 |
"""
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
@@ -12,6 +13,74 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
12 |
client = InferenceClient("unsloth/Llama-3.2-3B-Instruct") # Works!
|
13 |
#client = InferenceClient("T3lli/lora_model")
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def respond(
|
16 |
message,
|
17 |
history: list[tuple[str, str]],
|
@@ -24,16 +93,13 @@ def respond(
|
|
24 |
|
25 |
print("message:")
|
26 |
print(message)
|
|
|
27 |
|
28 |
for val in history:
|
29 |
if val[0]:
|
30 |
messages.append({"role": "user", "content": val[0]})
|
31 |
-
print("val[0]:")
|
32 |
-
print(val[0])
|
33 |
if val[1]:
|
34 |
messages.append({"role": "assistant", "content": val[1]})
|
35 |
-
print("val[1]:")
|
36 |
-
print(val[1])
|
37 |
|
38 |
messages.append({"role": "user", "content": message})
|
39 |
|
@@ -52,6 +118,7 @@ def respond(
|
|
52 |
yield response
|
53 |
print("response:")
|
54 |
print(response)
|
|
|
55 |
|
56 |
|
57 |
"""
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
import random
|
4 |
|
5 |
"""
|
6 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
|
|
13 |
client = InferenceClient("unsloth/Llama-3.2-3B-Instruct") # Works!
|
14 |
#client = InferenceClient("T3lli/lora_model")
|
15 |
|
16 |
+
|
17 |
+
|
18 |
+
words = [
|
19 |
+
# Nouns (250)
|
20 |
+
"apple", "bridge", "cat", "door", "engine", "forest", "giraffe", "horizon", "island", "jungle",
|
21 |
+
"kite", "lake", "mountain", "notebook", "ocean", "penguin", "quartz", "rainbow", "snowflake", "tornado",
|
22 |
+
"umbrella", "village", "waterfall", "xylophone", "yard", "zebra", "actor", "ball", "camera", "desert",
|
23 |
+
"elephant", "firefly", "garden", "hat", "igloo", "jacket", "key", "lantern", "mirror", "necklace",
|
24 |
+
"owl", "piano", "quiver", "rocket", "squirrel", "trophy", "unicorn", "vase", "window", "yacht",
|
25 |
+
# ... Add more nouns to total 250
|
26 |
+
|
27 |
+
# Adjectives (250)
|
28 |
+
"brave", "calm", "delightful", "eager", "fancy", "gentle", "happy", "innocent", "jolly", "kind",
|
29 |
+
"lively", "magnificent", "noble", "optimistic", "peaceful", "quick", "radiant", "shy", "tidy", "unique",
|
30 |
+
"vivid", "warm", "yellow", "zealous", "adorable", "beautiful", "charming", "diligent", "energetic", "fierce",
|
31 |
+
"graceful", "humble", "intelligent", "jovial", "keen", "lovely", "merry", "neat", "outstanding", "pleasant",
|
32 |
+
"quirky", "respectful", "silly", "thoughtful", "upbeat", "vibrant", "whimsical", "youthful", "zany",
|
33 |
+
# ... Add more adjectives to total 250
|
34 |
+
|
35 |
+
# Verbs (250)
|
36 |
+
"accept", "bounce", "climb", "dance", "explore", "fly", "gather", "help", "imagine", "jump",
|
37 |
+
"kick", "laugh", "move", "notice", "open", "play", "question", "run", "sing", "talk",
|
38 |
+
"understand", "visit", "wait", "yell", "zoom", "answer", "build", "create", "dig", "enjoy",
|
39 |
+
"focus", "grow", "hunt", "identify", "juggle", "know", "learn", "measure", "negotiate", "observe",
|
40 |
+
"perform", "quiet", "record", "search", "travel", "update", "volunteer", "wander", "write",
|
41 |
+
# ... Add more verbs to total 250
|
42 |
+
|
43 |
+
# Adverbs (250)
|
44 |
+
"abruptly", "beautifully", "carefully", "diligently", "eagerly", "faithfully", "gracefully", "happily",
|
45 |
+
"immediately", "joyfully", "kindly", "loudly", "magically", "neatly", "openly", "politely", "quickly",
|
46 |
+
"rarely", "silently", "thoughtfully", "unexpectedly", "vividly", "warmly", "yawningly", "zealously",
|
47 |
+
"accidentally", "boldly", "cheerfully", "deliberately", "enthusiastically", "frequently", "gently", "honestly",
|
48 |
+
"intensely", "justly", "knowingly", "lightly", "merrily", "nervously", "officially", "partially", "quietly",
|
49 |
+
"readily", "safely", "terribly", "urgently", "vaguely", "wildly", "yearly", "zestfully",
|
50 |
+
# ... Add more adverbs to total 250
|
51 |
+
]
|
52 |
+
|
53 |
+
|
54 |
+
class WordGame:
|
55 |
+
|
56 |
+
def __init__(self):
|
57 |
+
self.points = 0
|
58 |
+
self.target_word = ""
|
59 |
+
self.attempts = 3
|
60 |
+
self.generate_task()
|
61 |
+
|
62 |
+
def generate_task(self):
|
63 |
+
self.attempts = 3
|
64 |
+
self.target_word = random.choice(words)
|
65 |
+
|
66 |
+
def check_input_for_word(self, string):
|
67 |
+
if self.target_word in string:
|
68 |
+
self.generate_task()
|
69 |
+
else:
|
70 |
+
self.attempts -= 1
|
71 |
+
if self.attempts <= 0:
|
72 |
+
self.generate_task()
|
73 |
+
|
74 |
+
def check_output_for_word(self, string):
|
75 |
+
if self.target_word in string:
|
76 |
+
self.points += self.attempts
|
77 |
+
self.generate_task()
|
78 |
+
|
79 |
+
|
80 |
+
game = WordGame()
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
def respond(
|
85 |
message,
|
86 |
history: list[tuple[str, str]],
|
|
|
93 |
|
94 |
print("message:")
|
95 |
print(message)
|
96 |
+
game.check_input_for_word(message)
|
97 |
|
98 |
for val in history:
|
99 |
if val[0]:
|
100 |
messages.append({"role": "user", "content": val[0]})
|
|
|
|
|
101 |
if val[1]:
|
102 |
messages.append({"role": "assistant", "content": val[1]})
|
|
|
|
|
103 |
|
104 |
messages.append({"role": "user", "content": message})
|
105 |
|
|
|
118 |
yield response
|
119 |
print("response:")
|
120 |
print(response)
|
121 |
+
game.check_output_for_word(response)
|
122 |
|
123 |
|
124 |
"""
|