liang-huggingface commited on
Commit
878ce2b
·
1 Parent(s): 6820dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -7
app.py CHANGED
@@ -118,16 +118,49 @@ def summarize_articles(indices, articles_for_display):
118
  summary = summarize_with_huggingface(selected_articles)
119
  return summary
120
 
 
 
 
 
 
 
 
 
121
  # Gradio interface
122
  with gr.Blocks() as demo:
 
123
  gr.Markdown("### PubMed Article Summarizer")
124
- model_input = gr.Textbox(label="Enter the model to use", value="h2oai/h2ogpt-4096-llama2-7b-chat")
125
- query_input = gr.Textbox(label="Query Keywords")
126
- retmax_input = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Number of articles")
127
- search_button = gr.Button("Search")
128
- output_table = gr.Dataframe(headers=["PMID", "Authors", "Title","Abstract" ])
129
- summarize_button = gr.Button("Summarize")
130
- summary_output = gr.Textbox()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
  def update_output_table(query, retmax):
133
  df = search_pubmed(query, retmax)
 
118
  summary = summarize_with_huggingface(selected_articles)
119
  return summary
120
 
121
+ PASSWORD = "pass"
122
+
123
+ def check_password(username, password):
124
+ if username == USERNAME and password == PASSWORD:
125
+ return True, "Welcome!"
126
+ else:
127
+ return False, "Incorrect username or password."
128
+
129
  # Gradio interface
130
  with gr.Blocks() as demo:
131
+
132
  gr.Markdown("### PubMed Article Summarizer")
133
+
134
+ with gr.Row():
135
+ password_input = gr.Textbox(label="Password", type="password")
136
+
137
+ login_button = gr.Button("Login")
138
+ login_result = gr.Textbox(label="Login Result", interactive=False)
139
+
140
+ login_button.click(check_password, inputs=[username_input, password_input], outputs=[login_result])
141
+
142
+ with gr.Row():
143
+ model_input = gr.Textbox(label="Enter the model to use", value="h2oai/h2ogpt-4096-llama2-7b-chat")
144
+ query_input = gr.Textbox(label="Query Keywords")
145
+ retmax_input = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Number of articles")
146
+ search_button = gr.Button("Search")
147
+ output_table = gr.Dataframe(headers=["PMID", "Authors", "Title","Abstract" ])
148
+ summarize_button = gr.Button("Summarize")
149
+ summary_output = gr.Textbox()
150
+
151
+ model_input.visible = False
152
+ query_input.visible = False
153
+ summarize_button.visible = False
154
+
155
+ def process_login(is_success, message):
156
+ if is_success:
157
+ model_input.visible = True
158
+ query_button.visible = True
159
+ summarize_button.visible = True
160
+ login_result.update(value=message)
161
+ login_result.visible = True
162
+
163
+ login_button.click(check_password, inputs=[username_input, password_input], outputs=[process_login])
164
 
165
  def update_output_table(query, retmax):
166
  df = search_pubmed(query, retmax)