Spaces:
Sleeping
Sleeping
carlosgonzalezmartinez
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -144,12 +144,13 @@ Here are some documents that are relevant to the question.
|
|
144 |
|
145 |
def predict(user_input,company):
|
146 |
|
147 |
-
#filter = "
|
148 |
-
relevant_document_chunks = vectorstore_persisted.similarity_search(user_input, k=5)
|
149 |
|
150 |
# Create context_for_query
|
151 |
|
152 |
-
|
|
|
153 |
context_list = [d.page_content for d in relevant_document_chunks]
|
154 |
context_for_query = ". ".join(context_list)
|
155 |
|
@@ -195,7 +196,7 @@ def predict(user_input,company):
|
|
195 |
with log_file.open("a") as f:
|
196 |
f.write(json.dumps(
|
197 |
{
|
198 |
-
'user_input': user_input,
|
199 |
'retrieved_context': context_for_query,
|
200 |
'model_response': prediction
|
201 |
}
|
|
|
144 |
|
145 |
def predict(user_input,company):
|
146 |
|
147 |
+
#filter = "dataset/"+company+"-10-k-2023.pdf"
|
148 |
+
#relevant_document_chunks = vectorstore_persisted.similarity_search(user_input, k=5, filter={"source":filter})
|
149 |
|
150 |
# Create context_for_query
|
151 |
|
152 |
+
relevant_document_chunks = retriever.invoke(user_input)
|
153 |
+
|
154 |
context_list = [d.page_content for d in relevant_document_chunks]
|
155 |
context_for_query = ". ".join(context_list)
|
156 |
|
|
|
196 |
with log_file.open("a") as f:
|
197 |
f.write(json.dumps(
|
198 |
{
|
199 |
+
'user_input': user_input, company
|
200 |
'retrieved_context': context_for_query,
|
201 |
'model_response': prediction
|
202 |
}
|