Rams901 commited on
Commit
04f8781
1 Parent(s): eef7e20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -32,12 +32,8 @@ def retrieve_thoughts(query, n, db):
32
 
33
  # print(db.similarity_search_with_score(query = query, k = k, fetch_k = k*10))
34
  #filter = {'Product Name': prod}
35
- if yt:
36
- docs_with_score = db.similarity_search_with_score(query = query, filter = {'categories': None},k = len(db.index_to_docstore_id.values()), fetch_k = len(db.index_to_docstore_id.values()))
37
- else:
38
- # Make it include only news + people or just create a whole new db with articles having their common key, and yt/podcasts having their own.
39
-
40
- docs_with_score = db.similarity_search_with_score(query = query, k = len(db.index_to_docstore_id.values()), fetch_k = len(db.index_to_docstore_id.values()))
41
 
42
  df = pd.DataFrame([dict(doc[0])['metadata'] for doc in docs_with_score], )
43
  df = pd.concat((df, pd.DataFrame([dict(doc[0])['page_content'] for doc in docs_with_score], columns = ['page_content'])), axis = 1)
@@ -58,8 +54,8 @@ def retrieve_thoughts(query, n, db):
58
  tier_1_adjusted['score'] = score
59
  tier_1_adjusted.sort_values("score", inplace = True)
60
 
61
- if n:
62
- tier_1_adjusted = tier_1_adjusted[:min(len(tier_1_adjusted), n)]
63
 
64
  return {'tier 1':tier_1_adjusted, }
65
 
 
32
 
33
  # print(db.similarity_search_with_score(query = query, k = k, fetch_k = k*10))
34
  #filter = {'Product Name': prod}
35
+
36
+ docs_with_score = db.similarity_search_with_score(query = query, k = len(db.index_to_docstore_id.values()), fetch_k = len(db.index_to_docstore_id.values()))
 
 
 
 
37
 
38
  df = pd.DataFrame([dict(doc[0])['metadata'] for doc in docs_with_score], )
39
  df = pd.concat((df, pd.DataFrame([dict(doc[0])['page_content'] for doc in docs_with_score], columns = ['page_content'])), axis = 1)
 
54
  tier_1_adjusted['score'] = score
55
  tier_1_adjusted.sort_values("score", inplace = True)
56
 
57
+
58
+ tier_1_adjusted = tier_1_adjusted[:min(len(tier_1_adjusted), 50)]
59
 
60
  return {'tier 1':tier_1_adjusted, }
61