mtyrrell commited on
Commit
0881dc7
1 Parent(s): 8711c74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -46,10 +46,12 @@ examples = [
46
 
47
  def get_docs(input_query, country = None):
48
  # Construct a hacky query to focus the retriever on the target country (see notes below)
49
- if country:
50
- query = "For the country of "+country+", "+input_query
51
- else:
52
- query = input_query
 
 
53
  # Get top 150 because we want to make sure we have 10 pertaining to the selected country
54
  # TEMP SOLUTION: not ideal, but FAISS document store doesnt allow metadata filtering. Needs to be tested with the full dataset
55
  docs = retriever.retrieve(query=query,top_k = 150)
@@ -93,7 +95,7 @@ def get_refs(res):
93
  doc = res['documents'][i].to_dict()
94
  ref_id = doc['meta']['ref_id']
95
  if ref_id in ref_ids:
96
- result_str += "Ref. " + str(ref_id) + " [" + doc['meta']['country'] + " " + doc['meta']['document_name'] + "]: " + "'" + doc['content'] + "'<br> <br>" # Add <br> for a line break
97
  return result_str
98
 
99
  def run_query(input_text):
 
46
 
47
  def get_docs(input_query, country = None):
48
  # Construct a hacky query to focus the retriever on the target country (see notes below)
49
+ query = "For the country of "+country+", "+input_query
50
+ # if country:
51
+ # query = "For the country of "+country+", "+input_query
52
+ # else:
53
+ # query = input_query
54
+
55
  # Get top 150 because we want to make sure we have 10 pertaining to the selected country
56
  # TEMP SOLUTION: not ideal, but FAISS document store doesnt allow metadata filtering. Needs to be tested with the full dataset
57
  docs = retriever.retrieve(query=query,top_k = 150)
 
95
  doc = res['documents'][i].to_dict()
96
  ref_id = doc['meta']['ref_id']
97
  if ref_id in ref_ids:
98
+ result_str += "Ref. " + str(ref_id) + " [" + doc['meta']['country'] + " " + doc['meta']['document_name'] + "]: " + "*'" + doc['content'] + "'*<br> <br>" # Add <br> for a line break
99
  return result_str
100
 
101
  def run_query(input_text):