Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# Load the text generation model | |
pipe = pipeline("text-generation", model="microsoft/Phi-3.5-mini-instruct", trust_remote_code=True) | |
# Define a function for emoji guessing game | |
def emoji_game(user_guess): | |
# Messages to send to the model | |
messages = [ | |
{"role": "user", "content": f"Guess the word or phrase represented by these emojis: ππ©βπΎπͺπͺ."}, | |
{"role": "user", "content": user_guess}, | |
] | |
# Generate response from the model | |
response = pipe(messages) | |
# Process the response (for simplicity, let's just return the generated text) | |
return response[0]['generated_text'] | |
# Create a Gradio interface | |
interface = gr.Interface( | |
fn=emoji_game, # Function to call when user submits input | |
inputs="text", # Input widget (user types their guess) | |
outputs="text", # Output widget (display model response) | |
title="Guess the Word from Emojis", | |
description="Try to guess the word or phrase represented by the emojis. Example: ππ§β‘ = Harry Potter." | |
) | |
# Launch the interface | |
interface.launch() | |