Allen Park commited on
Commit
1230f78
·
1 Parent(s): 0b27a4e

add file_types parameter to only allow pdfs, docs, & text files; make sure file count is single for visible uploadbutton elements

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -78,6 +78,8 @@ HEADER = """
78
  **Getting Started**: Provide a question and document or context given to your model in addition to the answer given by the model and then click submit. The output panel will indicate whether the reponse is a hallucination (Fail) or if it is faithful to the given document or context (Pass) through the score Pass or Fail and provide reasoning behind the score.
79
  """
80
 
 
 
81
  def update_client_base_url(model_name):
82
  if model_name == "Patronus Lynx 8B v1.1":
83
  return "https://yb15a7dy-patronus-lynx-8b-v1-1.tin.lepton.run/api/v1/"
@@ -138,10 +140,10 @@ def upload_file(filepath):
138
  print("FILEPATH type & file name type", type(filepath), type(name))
139
  return [gr.UploadButton(visible=False), gr.Group(visible=True), gr.Markdown("**Uploaded file:** {name}".format(name=name))]
140
  else:
141
- return [gr.UploadButton(visible=True), gr.Group(visible=False), gr.Markdown("")]
142
  # return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
143
  def reset_buttons():
144
- return [gr.UploadButton(visible=True), gr.Group(visible=False), gr.Markdown("")]
145
 
146
  # def download_file():
147
  # return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
@@ -167,7 +169,7 @@ with gr.Blocks(css=css) as demo:
167
  question = gr.Textbox(label="Question")
168
  with gr.Row():
169
  document = gr.Textbox(label="Document", scale=9)
170
- u = gr.UploadButton("Upload", file_count="single", scale=1)
171
  file_group = gr.Group(visible=False)
172
  with file_group:
173
  file_name = gr.Markdown("")
 
78
  **Getting Started**: Provide a question and document or context given to your model in addition to the answer given by the model and then click submit. The output panel will indicate whether the reponse is a hallucination (Fail) or if it is faithful to the given document or context (Pass) through the score Pass or Fail and provide reasoning behind the score.
79
  """
80
 
81
+ UPLOADABLE_FILE_TYPES = [".pdf", ".txt", ".docx", ".doc"]
82
+
83
  def update_client_base_url(model_name):
84
  if model_name == "Patronus Lynx 8B v1.1":
85
  return "https://yb15a7dy-patronus-lynx-8b-v1-1.tin.lepton.run/api/v1/"
 
140
  print("FILEPATH type & file name type", type(filepath), type(name))
141
  return [gr.UploadButton(visible=False), gr.Group(visible=True), gr.Markdown("**Uploaded file:** {name}".format(name=name))]
142
  else:
143
+ return [gr.UploadButton(visible=True, file_count="single", file_types=UPLOADABLE_FILE_TYPES), gr.Group(visible=False), gr.Markdown("")]
144
  # return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
145
  def reset_buttons():
146
+ return [gr.UploadButton(visible=True, file_count="single", file_types=UPLOADABLE_FILE_TYPES), gr.Group(visible=False), gr.Markdown("")]
147
 
148
  # def download_file():
149
  # return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
 
169
  question = gr.Textbox(label="Question")
170
  with gr.Row():
171
  document = gr.Textbox(label="Document", scale=9)
172
+ u = gr.UploadButton("Upload", visible=True, file_count="single", file_types=UPLOADABLE_FILE_TYPES, scale=1)
173
  file_group = gr.Group(visible=False)
174
  with file_group:
175
  file_name = gr.Markdown("")