Spaces:
Runtime error
Runtime error
gouravgujariya
commited on
Commit
β’
6763da3
1
Parent(s):
a18d07d
Update app.py
Browse filesupdated version
app.py
CHANGED
@@ -4,19 +4,22 @@ from transformers import pipeline
|
|
4 |
# Load the text generation model
|
5 |
pipe = pipeline("text-generation", model="microsoft/Phi-3.5-mini-instruct", trust_remote_code=True)
|
6 |
|
7 |
-
# Define a function
|
8 |
-
def emoji_game(user_guess):
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
|
21 |
# Create a Gradio interface
|
22 |
interface = gr.Interface(
|
@@ -24,7 +27,7 @@ interface = gr.Interface(
|
|
24 |
inputs="text", # Input widget (user types their guess)
|
25 |
outputs="text", # Output widget (display model response)
|
26 |
title="Guess the Word from Emojis",
|
27 |
-
description="
|
28 |
)
|
29 |
|
30 |
# Launch the interface
|
|
|
4 |
# Load the text generation model
|
5 |
pipe = pipeline("text-generation", model="microsoft/Phi-3.5-mini-instruct", trust_remote_code=True)
|
6 |
|
7 |
+
# Define a function to start the emoji game
|
8 |
+
def emoji_game(user_guess=""):
|
9 |
+
if user_guess == "": # If no guess yet, LLM asks the question first
|
10 |
+
# LLM generates the first emoji sequence
|
11 |
+
messages = [
|
12 |
+
{"role": "user", "content": "Give me an emoji-based puzzle for a word or phrase guessing game."}
|
13 |
+
]
|
14 |
+
response = pipe(messages)
|
15 |
+
return response[0]['generated_text'] # Return the generated emoji puzzle
|
16 |
+
else:
|
17 |
+
# After the user makes a guess, the LLM evaluates the guess
|
18 |
+
messages = [
|
19 |
+
{"role": "user", "content": f"Guess the word or phrase represented by these emojis: {user_guess}."}
|
20 |
+
]
|
21 |
+
response = pipe(messages)
|
22 |
+
return response[0]['generated_text']
|
23 |
|
24 |
# Create a Gradio interface
|
25 |
interface = gr.Interface(
|
|
|
27 |
inputs="text", # Input widget (user types their guess)
|
28 |
outputs="text", # Output widget (display model response)
|
29 |
title="Guess the Word from Emojis",
|
30 |
+
description="The LLM will first present an emoji puzzle, and you try to guess the word or phrase."
|
31 |
)
|
32 |
|
33 |
# Launch the interface
|