Update app.py
Browse files
app.py
CHANGED
|
@@ -71,6 +71,7 @@ for i, doc in enumerate(chunks):
|
|
| 71 |
|
| 72 |
"""Retriever"""
|
| 73 |
bm25_retriever = BM25Retriever.from_documents(chunks_bm25, k = 2) # 2 most similar contexts
|
|
|
|
| 74 |
def retriever(query):
|
| 75 |
tmp = bm25_retriever.invoke(preprocess_for_bm25(query))
|
| 76 |
context = []
|
|
@@ -78,8 +79,9 @@ def retriever(query):
|
|
| 78 |
index = doc.metadata['index']
|
| 79 |
context.append(chunks[index])
|
| 80 |
return context
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
return match.group(0).strip() if match else None
|
| 84 |
"""Chain"""
|
| 85 |
|
|
|
|
| 71 |
|
| 72 |
"""Retriever"""
|
| 73 |
bm25_retriever = BM25Retriever.from_documents(chunks_bm25, k = 2) # 2 most similar contexts
|
| 74 |
+
|
| 75 |
def retriever(query):
|
| 76 |
tmp = bm25_retriever.invoke(preprocess_for_bm25(query))
|
| 77 |
context = []
|
|
|
|
| 79 |
index = doc.metadata['index']
|
| 80 |
context.append(chunks[index])
|
| 81 |
return context
|
| 82 |
+
|
| 83 |
+
def extract_question(text_):
|
| 84 |
+
match = re.search(r'(?<=question:)(.*?)(?=\n\n|$)', text_, re.IGNORECASE | re.DOTALL)
|
| 85 |
return match.group(0).strip() if match else None
|
| 86 |
"""Chain"""
|
| 87 |
|