Spaces:
Runtime error
Runtime error
gouravgujariya
commited on
Commit
โข
286a0cd
1
Parent(s):
7952d76
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def reset_game():
|
|
17 |
|
18 |
# Ask LLM for the first emoji puzzle
|
19 |
emoji_prompt = "Give me an emoji-based puzzle for a word or phrase guessing game."
|
20 |
-
response = pipe([{"role": "user", "content": emoji_prompt}])
|
21 |
current_emoji = response[0]['generated_text']
|
22 |
|
23 |
return introduction + f"Here's your first puzzle: {current_emoji}"
|
@@ -45,7 +45,7 @@ def emoji_game(user_input=""):
|
|
45 |
|
46 |
# Check if the user made a guess; LLM evaluates the guess
|
47 |
guess_prompt = f"User guessed '{user_input}'. Was the guess correct for this emoji puzzle: {current_emoji}?"
|
48 |
-
response = pipe([{"role": "user", "content": guess_prompt}])
|
49 |
response_text = response[0]['generated_text'].lower()
|
50 |
|
51 |
# Process response: if it's correct, increase points; otherwise, decrease points
|
@@ -56,7 +56,7 @@ def emoji_game(user_input=""):
|
|
56 |
else:
|
57 |
# Get next emoji puzzle for the user
|
58 |
next_emoji_prompt = "Give me another emoji-based puzzle."
|
59 |
-
response = pipe([{"role": "user", "content": next_emoji_prompt}])
|
60 |
current_emoji = response[0]['generated_text']
|
61 |
return f"โ
Correct! Your current points: {points}. Here's your next puzzle: {current_emoji}"
|
62 |
else: # Incorrect guess
|
@@ -66,14 +66,19 @@ def emoji_game(user_input=""):
|
|
66 |
else:
|
67 |
return f"โ Incorrect! Your current points: {points}. Try again: {current_emoji}"
|
68 |
|
69 |
-
# Create a Gradio interface for the game
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
)
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
# Launch the Gradio interface
|
79 |
interface.launch()
|
|
|
17 |
|
18 |
# Ask LLM for the first emoji puzzle
|
19 |
emoji_prompt = "Give me an emoji-based puzzle for a word or phrase guessing game."
|
20 |
+
response = pipe([{"role": "user", "content": emoji_prompt}], max_new_tokens=30)
|
21 |
current_emoji = response[0]['generated_text']
|
22 |
|
23 |
return introduction + f"Here's your first puzzle: {current_emoji}"
|
|
|
45 |
|
46 |
# Check if the user made a guess; LLM evaluates the guess
|
47 |
guess_prompt = f"User guessed '{user_input}'. Was the guess correct for this emoji puzzle: {current_emoji}?"
|
48 |
+
response = pipe([{"role": "user", "content": guess_prompt}], max_new_tokens=30)
|
49 |
response_text = response[0]['generated_text'].lower()
|
50 |
|
51 |
# Process response: if it's correct, increase points; otherwise, decrease points
|
|
|
56 |
else:
|
57 |
# Get next emoji puzzle for the user
|
58 |
next_emoji_prompt = "Give me another emoji-based puzzle."
|
59 |
+
response = pipe([{"role": "user", "content": next_emoji_prompt}], max_new_tokens=30)
|
60 |
current_emoji = response[0]['generated_text']
|
61 |
return f"โ
Correct! Your current points: {points}. Here's your next puzzle: {current_emoji}"
|
62 |
else: # Incorrect guess
|
|
|
66 |
else:
|
67 |
return f"โ Incorrect! Your current points: {points}. Try again: {current_emoji}"
|
68 |
|
69 |
+
# Create a Gradio interface for the game with horizontal layout and buttons
|
70 |
+
with gr.Blocks() as interface:
|
71 |
+
gr.Markdown("### Guess the Word from Emojis Game ๐ฎ")
|
72 |
+
output = gr.Textbox(label="Game Output", interactive=False)
|
73 |
+
input_box = gr.Textbox(label="Your Guess or Command")
|
74 |
+
|
75 |
+
with gr.Row():
|
76 |
+
start_button = gr.Button("Start Game")
|
77 |
+
next_button = gr.Button("Next Puzzle")
|
78 |
+
|
79 |
+
input_box.submit(emoji_game, inputs=input_box, outputs=output)
|
80 |
+
start_button.click(reset_game, outputs=output)
|
81 |
+
next_button.click(lambda: emoji_game(), outputs=output)
|
82 |
|
83 |
# Launch the Gradio interface
|
84 |
interface.launch()
|