asimmetti commited on
Commit
0d07c12
·
verified ·
1 Parent(s): f373cd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -318,33 +318,26 @@ bm25_retriever = BM25Retriever(index_dir="output/bm25_index_b")
318
 
319
  corpus_dict = {doc.collection_id: doc.text for doc in sciq.corpus}
320
 
321
- # Search function for the BM25 system
322
- def search(query: str) -> List[Hit]:
323
- # Replace the following placeholder with actual retrieval logic
324
  results = bm25_retriever.retrieve(query)
325
  hits = [
326
  {
327
  "cid": cid,
328
  "score": score,
329
- "text": corpus_dict[cid] # Assuming sciq.corpus maps cids to document texts
330
  }
331
  for cid, score in results.items()
332
  ]
333
  return hits
334
 
335
- def handle_search(query):
336
- results = search(query)
337
- return results
338
-
339
-
340
  demo = gr.Interface(
341
- fn=handle_search, # The function to process input
342
- inputs=gr.Textbox(label="Enter your search query"), # Input: Textbox
343
- outputs=gr.Textbox(label="Search Results", lines=20, interactive=False), # Output: Textbox
344
- title="BM25 Search Engine Demo on SciQ Dataset", # Title of the app
345
- description="Enter your search query to get the results from the SciQ dataset." # Description
346
  )
347
-
348
- # Launch the app with shareable URL
349
- demo.launch(debug=True)
350
 
 
318
 
319
  corpus_dict = {doc.collection_id: doc.text for doc in sciq.corpus}
320
 
321
+ def get_query(query):
 
 
322
  results = bm25_retriever.retrieve(query)
323
  hits = [
324
  {
325
  "cid": cid,
326
  "score": score,
327
+ "text": corpus_dict[cid]
328
  }
329
  for cid, score in results.items()
330
  ]
331
  return hits
332
 
333
+
334
+
 
 
 
335
  demo = gr.Interface(
336
+ fn=get_query,
337
+ inputs=gr.Textbox(label="Enter your query"),
338
+ outputs=gr.Textbox(label="Results", lines=20, interactive=False),
339
+ title="BM25 Query Engine"
 
340
  )
341
+ ## YOUR_CODE_ENDS_HERE
342
+ demo.launch()
 
343