tea-phan-y commited on
Commit
156d401
·
verified ·
1 Parent(s): 1069ecb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -94,9 +94,9 @@ def generate_response(user_query, relevant_segment):
94
  print(f"Error in generating response: {e}")
95
  return f"Error in generating response: {e}"
96
 
97
- def query_model(question):
98
  """
99
- Process a question, find relevant information, and generate a response. If no book title is given, return not relevant_segment.
100
  """
101
  if question == "":
102
  return "Welcome to LitBot! Ask me anything about literature, book themes, and the historical context behind your book."
@@ -135,9 +135,7 @@ books = """
135
  - Lord of the Flies
136
  - Hamlet
137
  """
138
- books2 = """
139
 
140
- """
141
 
142
  # Setup the Gradio Blocks interface with custom layout components
143
  with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
@@ -146,7 +144,6 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
146
  # with gr.Column():
147
  gr.Markdown(books) # Show the topics on the left side
148
  gr.Markdown(topics)
149
- # gr.Markdown(books2)
150
  with gr.Row():
151
  with gr.Column():
152
  book = gr.Dropdown(
@@ -156,7 +153,7 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
156
  question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
157
  answer = gr.Textbox(label="LitBot Response", placeholder="LitBot will respond here...", interactive=False, lines=20)
158
  submit_button = gr.Button("Submit")
159
- submit_button.click(fn=query_model, inputs=question, outputs=answer)
160
 
161
 
162
  # Launch the Gradio app to allow user interaction
 
94
  print(f"Error in generating response: {e}")
95
  return f"Error in generating response: {e}"
96
 
97
+ def query_model(question, book):
98
  """
99
+ Process a question, find relevant information, and generate a response using inputted book title.
100
  """
101
  if question == "":
102
  return "Welcome to LitBot! Ask me anything about literature, book themes, and the historical context behind your book."
 
135
  - Lord of the Flies
136
  - Hamlet
137
  """
 
138
 
 
139
 
140
  # Setup the Gradio Blocks interface with custom layout components
141
  with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
 
144
  # with gr.Column():
145
  gr.Markdown(books) # Show the topics on the left side
146
  gr.Markdown(topics)
 
147
  with gr.Row():
148
  with gr.Column():
149
  book = gr.Dropdown(
 
153
  question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
154
  answer = gr.Textbox(label="LitBot Response", placeholder="LitBot will respond here...", interactive=False, lines=20)
155
  submit_button = gr.Button("Submit")
156
+ submit_button.click(fn=query_model, inputs=question+book, outputs=answer)
157
 
158
 
159
  # Launch the Gradio app to allow user interaction