Julia Ostheimer commited on
Commit ·
c2a9ca7
1
Parent(s): fdd7f5b
Declare sources history as list and append dictionary for each retrieval query with necessary information
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ from tools.langfuse_client import get_langfuse_handler
|
|
| 24 |
|
| 25 |
from config import app_settings
|
| 26 |
|
| 27 |
-
document_metadata_to_display_in_ui =
|
| 28 |
def get_metadata():
|
| 29 |
global document_metadata_to_display_in_ui
|
| 30 |
return document_metadata_to_display_in_ui # safe to read and return
|
|
@@ -87,11 +87,13 @@ def retrieve(query: str):
|
|
| 87 |
)
|
| 88 |
|
| 89 |
global document_metadata_to_display_in_ui
|
| 90 |
-
document_metadata_to_display_in_ui
|
|
|
|
| 91 |
"filename": [get_document_filename(doc) for doc in retrieved_docs],
|
| 92 |
"author": [doc.metadata["Author"] for doc in retrieved_docs],
|
| 93 |
-
"creation_date": [doc.metadata["CreationDate"] for doc in retrieved_docs]
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
logger.info("Retrieved document metadata to display in UI", content=document_metadata_to_display_in_ui)
|
| 97 |
|
|
|
|
| 24 |
|
| 25 |
from config import app_settings
|
| 26 |
|
| 27 |
+
document_metadata_to_display_in_ui = []
|
| 28 |
def get_metadata():
|
| 29 |
global document_metadata_to_display_in_ui
|
| 30 |
return document_metadata_to_display_in_ui # safe to read and return
|
|
|
|
| 87 |
)
|
| 88 |
|
| 89 |
global document_metadata_to_display_in_ui
|
| 90 |
+
document_metadata_to_display_in_ui.append({
|
| 91 |
+
"query": query,
|
| 92 |
"filename": [get_document_filename(doc) for doc in retrieved_docs],
|
| 93 |
"author": [doc.metadata["Author"] for doc in retrieved_docs],
|
| 94 |
+
"creation_date": [doc.metadata["CreationDate"] for doc in retrieved_docs],
|
| 95 |
+
"source_text_chunk": [doc.page_content for doc in retrieved_docs]
|
| 96 |
+
})
|
| 97 |
|
| 98 |
logger.info("Retrieved document metadata to display in UI", content=document_metadata_to_display_in_ui)
|
| 99 |
|