gouravgujariya commited on
Commit
1e7d879
β€’
1 Parent(s): b362fc8

Create app.py

Browse files

the main code based on llm

Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
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 for emoji guessing game
8
+ def emoji_game(user_guess):
9
+ # Messages to send to the model
10
+ messages = [
11
+ {"role": "user", "content": f"Guess the word or phrase represented by these emojis: πŸŽπŸ‘©β€πŸŒΎπŸšͺπŸͺž."},
12
+ {"role": "user", "content": user_guess},
13
+ ]
14
+
15
+ # Generate response from the model
16
+ response = pipe(messages)
17
+
18
+ # Process the response (for simplicity, let's just return the generated text)
19
+ return response[0]['generated_text']
20
+
21
+ # Create a Gradio interface
22
+ interface = gr.Interface(
23
+ fn=emoji_game, # Function to call when user submits input
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="Try to guess the word or phrase represented by the emojis. Example: πŸπŸ§™βš‘ = Harry Potter."
28
+ )
29
+
30
+ # Launch the interface
31
+ interface.launch()