Tonic commited on
Commit
7608608
·
1 Parent(s): def0a86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -84,24 +84,23 @@ def retrieve_info(query):
84
 
85
  return {"results": formatted_results}
86
 
87
- # Gradio interface
 
 
 
 
 
 
 
88
  iface = gr.Interface(
89
- fn=retrieve_info,
90
  inputs=[
91
- gr.Textbox(label="Query")
 
 
92
  ],
93
  outputs="text",
94
  allow_flagging="never"
95
  )
96
 
97
- # Embed PDF function
98
- iface.add_endpoint(
99
- fn=embed_pdf,
100
- inputs=[
101
- gr.File(label="PDF File", type="file"),
102
- gr.Textbox(label="Collection Name")
103
- ],
104
- outputs="text"
105
- )
106
-
107
  iface.launch()
 
84
 
85
  return {"results": formatted_results}
86
 
87
+ def combined_interface(query, file, collection_name):
88
+ if query:
89
+ return retrieve_info(query)
90
+ elif file is not None and collection_name:
91
+ return embed_pdf(file, collection_name)
92
+ else:
93
+ return "Please enter a query or upload a PDF file."
94
+
95
  iface = gr.Interface(
96
+ fn=combined_interface,
97
  inputs=[
98
+ gr.Textbox(label="Query", optional=True),
99
+ gr.File(label="PDF File", type="file", optional=True),
100
+ gr.Textbox(label="Collection Name", optional=True)
101
  ],
102
  outputs="text",
103
  allow_flagging="never"
104
  )
105
 
 
 
 
 
 
 
 
 
 
 
106
  iface.launch()