Spaces:
Runtime error
Runtime error
Reset game starting state for every refresh
Browse files
app.py
CHANGED
@@ -26,6 +26,7 @@ class Game:
|
|
26 |
|
27 |
with gr.Blocks(theme='gstaff/xkcd') as demo:
|
28 |
game_state = gr.State(Game())
|
|
|
29 |
title = gr.Markdown("# Guessing Game")
|
30 |
chatbot = gr.Chatbot(value=[(None, game_state.value.prompt)])
|
31 |
msg = gr.Textbox()
|
@@ -43,7 +44,7 @@ with gr.Blocks(theme='gstaff/xkcd') as demo:
|
|
43 |
if user_input.strip().lower() in game.word_list:
|
44 |
history[-1][1] = "Wrong guess, try again."
|
45 |
return history, game
|
46 |
-
instructions = f"The
|
47 |
bot_message = model(instructions, max_length=256, do_sample=True)[0]['generated_text']
|
48 |
response = bot_message.replace(game.secret_word, "?????").replace(game.secret_word.title(), "?????")
|
49 |
history[-1][1] = response
|
|
|
26 |
|
27 |
with gr.Blocks(theme='gstaff/xkcd') as demo:
|
28 |
game_state = gr.State(Game())
|
29 |
+
game_state.value.reset()
|
30 |
title = gr.Markdown("# Guessing Game")
|
31 |
chatbot = gr.Chatbot(value=[(None, game_state.value.prompt)])
|
32 |
msg = gr.Textbox()
|
|
|
44 |
if user_input.strip().lower() in game.word_list:
|
45 |
history[-1][1] = "Wrong guess, try again."
|
46 |
return history, game
|
47 |
+
instructions = f"The word is {game.secret_word}. Answer this: {user_input}"
|
48 |
bot_message = model(instructions, max_length=256, do_sample=True)[0]['generated_text']
|
49 |
response = bot_message.replace(game.secret_word, "?????").replace(game.secret_word.title(), "?????")
|
50 |
history[-1][1] = response
|