Update app.py
Browse files
app.py
CHANGED
@@ -27,10 +27,17 @@ embeddings = HuggingFaceEmbeddings()
|
|
27 |
db = FAISS.load_local('db_full', embeddings)
|
28 |
mp_docs = {}
|
29 |
|
30 |
-
def retrieve_thoughts(query, n):
|
31 |
|
32 |
# print(db.similarity_search_with_score(query = query, k = k, fetch_k = k*10))
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
df = pd.DataFrame([dict(doc[0])['metadata'] for doc in docs_with_score], )
|
35 |
df = pd.concat((df, pd.DataFrame([dict(doc[0])['page_content'] for doc in docs_with_score], columns = ['page_content'])), axis = 1)
|
36 |
df = pd.concat((df, pd.DataFrame([doc[1] for doc in docs_with_score], columns = ['score'])), axis = 1)
|
@@ -78,7 +85,7 @@ def qa_retrieve_art(query,):
|
|
78 |
return {'Reference': reference}
|
79 |
|
80 |
|
81 |
-
def
|
82 |
|
83 |
docs = ""
|
84 |
|
|
|
27 |
db = FAISS.load_local('db_full', embeddings)
|
28 |
mp_docs = {}
|
29 |
|
30 |
+
def retrieve_thoughts(query, n, yt = False):
|
31 |
|
32 |
# print(db.similarity_search_with_score(query = query, k = k, fetch_k = k*10))
|
33 |
+
#filter = {'Product Name': prod}
|
34 |
+
if yt:
|
35 |
+
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()))
|
36 |
+
else:
|
37 |
+
# 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.
|
38 |
+
|
39 |
+
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()))
|
40 |
+
|
41 |
df = pd.DataFrame([dict(doc[0])['metadata'] for doc in docs_with_score], )
|
42 |
df = pd.concat((df, pd.DataFrame([dict(doc[0])['page_content'] for doc in docs_with_score], columns = ['page_content'])), axis = 1)
|
43 |
df = pd.concat((df, pd.DataFrame([doc[1] for doc in docs_with_score], columns = ['score'])), axis = 1)
|
|
|
85 |
return {'Reference': reference}
|
86 |
|
87 |
|
88 |
+
def qa_retrieve_yt(query,):
|
89 |
|
90 |
docs = ""
|
91 |
|