Gopikanth123 commited on
Commit
7386167
·
verified ·
1 Parent(s): fdbd18a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -5
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
- if past_query.strip():
100
- context_str += f"User asked: '{past_query}'\nBot answered: '{response}'\n"
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}")