Spaces:
Runtime error
Runtime error
Try making game non-global
Browse files
app.py
CHANGED
@@ -21,9 +21,8 @@ class Game:
|
|
21 |
return f"Try to guess the word! Either enter the word or ask a hint. The word will be one of {self.word_list}"
|
22 |
|
23 |
|
24 |
-
game = Game()
|
25 |
-
|
26 |
with gr.Blocks(theme='gstaff/xkcd') as demo:
|
|
|
27 |
title = gr.Markdown("# Guessing Game")
|
28 |
chatbot = gr.Chatbot(value=[(None, game.prompt)])
|
29 |
msg = gr.Textbox()
|
@@ -40,7 +39,7 @@ with gr.Blocks(theme='gstaff/xkcd') as demo:
|
|
40 |
if user_input.strip().lower() in game.word_list:
|
41 |
history[-1][1] = "Wrong guess, try again."
|
42 |
return history
|
43 |
-
instructions = f"The secret word is {game.secret_word}. {user_input}"
|
44 |
bot_message = model(instructions, max_length=256, do_sample=True)[0]['generated_text']
|
45 |
response = bot_message.replace(game.secret_word, "?????").replace(game.secret_word.title(), "?????")
|
46 |
history[-1][1] = response
|
|
|
21 |
return f"Try to guess the word! Either enter the word or ask a hint. The word will be one of {self.word_list}"
|
22 |
|
23 |
|
|
|
|
|
24 |
with gr.Blocks(theme='gstaff/xkcd') as demo:
|
25 |
+
game = Game()
|
26 |
title = gr.Markdown("# Guessing Game")
|
27 |
chatbot = gr.Chatbot(value=[(None, game.prompt)])
|
28 |
msg = gr.Textbox()
|
|
|
39 |
if user_input.strip().lower() in game.word_list:
|
40 |
history[-1][1] = "Wrong guess, try again."
|
41 |
return history
|
42 |
+
instructions = f"The secret word is {game.secret_word}. Answer this: {user_input}"
|
43 |
bot_message = model(instructions, max_length=256, do_sample=True)[0]['generated_text']
|
44 |
response = bot_message.replace(game.secret_word, "?????").replace(game.secret_word.title(), "?????")
|
45 |
history[-1][1] = response
|