Spaces:
Runtime error
Runtime error
gouravgujariya
commited on
Commit
β’
4f48e66
1
Parent(s):
286a0cd
Update app.py
Browse files
app.py
CHANGED
@@ -18,8 +18,9 @@ def reset_game():
|
|
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}"
|
24 |
|
25 |
# Function to handle the game logic and user interactions
|
@@ -46,7 +47,7 @@ def emoji_game(user_input=""):
|
|
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
|
52 |
if "correct" in response_text: # Correct guess
|
@@ -57,7 +58,7 @@ def emoji_game(user_input=""):
|
|
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
|
63 |
points -= 1
|
|
|
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'].strip()
|
22 |
|
23 |
+
# Return introduction and the emoji puzzle
|
24 |
return introduction + f"Here's your first puzzle: {current_emoji}"
|
25 |
|
26 |
# Function to handle the game logic and user interactions
|
|
|
47 |
# Check if the user made a guess; LLM evaluates the guess
|
48 |
guess_prompt = f"User guessed '{user_input}'. Was the guess correct for this emoji puzzle: {current_emoji}?"
|
49 |
response = pipe([{"role": "user", "content": guess_prompt}], max_new_tokens=30)
|
50 |
+
response_text = response[0]['generated_text'].strip().lower()
|
51 |
|
52 |
# Process response: if it's correct, increase points; otherwise, decrease points
|
53 |
if "correct" in response_text: # Correct guess
|
|
|
58 |
# Get next emoji puzzle for the user
|
59 |
next_emoji_prompt = "Give me another emoji-based puzzle."
|
60 |
response = pipe([{"role": "user", "content": next_emoji_prompt}], max_new_tokens=30)
|
61 |
+
current_emoji = response[0]['generated_text'].strip()
|
62 |
return f"β
Correct! Your current points: {points}. Here's your next puzzle: {current_emoji}"
|
63 |
else: # Incorrect guess
|
64 |
points -= 1
|