Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -67,6 +67,13 @@ def data_ingestion_from_directory():
|
|
| 67 |
index.storage_context.persist(persist_dir=PERSIST_DIR)
|
| 68 |
|
| 69 |
def handle_query(query):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
chat_text_qa_msgs = [
|
| 71 |
(
|
| 72 |
"user",
|
|
@@ -92,12 +99,12 @@ def handle_query(query):
|
|
| 92 |
|
| 93 |
storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
|
| 94 |
index = load_index_from_storage(storage_context)
|
| 95 |
-
context_str = ""
|
| 96 |
|
| 97 |
-
# Build context from current chat history
|
| 98 |
-
for past_query, response in reversed(current_chat_history):
|
| 99 |
-
|
| 100 |
-
|
| 101 |
|
| 102 |
query_engine = index.as_query_engine(text_qa_template=text_qa_template, context_str=context_str)
|
| 103 |
print(f"Querying: {query}")
|
|
|
|
| 67 |
index.storage_context.persist(persist_dir=PERSIST_DIR)
|
| 68 |
|
| 69 |
def handle_query(query):
|
| 70 |
+
context_str = ""
|
| 71 |
+
|
| 72 |
+
# Build context from current chat history
|
| 73 |
+
for past_query, response in reversed(current_chat_history):
|
| 74 |
+
if past_query.strip():
|
| 75 |
+
context_str += f"User asked: '{past_query}'\nBot answered: '{response}'\n"
|
| 76 |
+
|
| 77 |
chat_text_qa_msgs = [
|
| 78 |
(
|
| 79 |
"user",
|
|
|
|
| 99 |
|
| 100 |
storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
|
| 101 |
index = load_index_from_storage(storage_context)
|
| 102 |
+
# context_str = ""
|
| 103 |
|
| 104 |
+
# # Build context from current chat history
|
| 105 |
+
# for past_query, response in reversed(current_chat_history):
|
| 106 |
+
# if past_query.strip():
|
| 107 |
+
# context_str += f"User asked: '{past_query}'\nBot answered: '{response}'\n"
|
| 108 |
|
| 109 |
query_engine = index.as_query_engine(text_qa_template=text_qa_template, context_str=context_str)
|
| 110 |
print(f"Querying: {query}")
|