Afeezee commited on
Commit
16a932c
·
verified ·
1 Parent(s): 7673c2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -67,17 +67,26 @@ def continue_trivia_game(user_response):
67
  # Start the game and get the initial LLM output
68
  initial_output = start_trivia_game()
69
 
70
- # Creating Gradio Interface
71
- llm_output = gr.Textbox(label="LLM Output", placeholder="The output from the LLM will appear here", lines=10, value=initial_output)
72
- user_response = gr.Textbox(label="Your Response", placeholder="Type your response here", lines=3)
73
-
74
- demo = gr.Interface(
75
- fn=continue_trivia_game,
76
- inputs=user_response,
77
- outputs=llm_output,
78
- title="TriviaVilla--Nigerian Music Trivia Game",
79
- description="How much do you know Nigerian Music? Here is a simple trivia game on Nigerian Music using LLama 3.1",
80
- )
 
 
 
 
 
 
 
 
 
81
 
82
- # Starting the Gradio app
83
  demo.launch()
 
67
  # Start the game and get the initial LLM output
68
  initial_output = start_trivia_game()
69
 
70
+ # Using gr.Blocks to create the interface
71
+ with gr.Blocks() as demo:
72
+ # Title and Description
73
+ gr.Markdown("# TriviaVilla\n A simple trivia game on Nigerian Music using LLama 3.1.")
74
+
75
+ # LLM Output Textbox
76
+ llm_output = gr.Textbox(label="LLM Output", placeholder="The output from the LLM will appear here", lines=10, value=initial_output)
77
+
78
+ # User Response Textbox
79
+ user_response = gr.Textbox(label="Your Response", placeholder="Type your response here", lines=3)
80
+
81
+ # Button to submit the user's response and update the LLM output
82
+ submit_button = gr.Button("Submit")
83
+
84
+ # Function to update the LLM output upon submission
85
+ def update_llm_output(user_input):
86
+ return continue_trivia_game(user_input)
87
+
88
+ # Define interactions
89
+ submit_button.click(fn=update_llm_output, inputs=user_response, outputs=llm_output)
90
 
91
+ # Launch the Gradio app
92
  demo.launch()