John Graham Reynolds commited on
Commit
4b39932
·
1 Parent(s): 312a2f7

readd entire chat history - see if this helps halucination

Browse files
Files changed (1) hide show
  1. chain.py +5 -3
chain.py CHANGED
@@ -130,14 +130,16 @@ class ChainBuilder:
130
  history = self.extract_chat_history(chat_messages_array)
131
  formatted_chat_history = []
132
  if len(history) > 0:
133
- # grab at most just the last three sets of queries and respones as chat history for relevant context - limit history so as to not overflow 32k context window
134
- for chat_message in history[-6:]:
 
 
135
  if chat_message["role"] == "user":
136
  formatted_chat_history.append(HumanMessage(content=chat_message["content"]))
137
  elif chat_message["role"] == "assistant":
138
  formatted_chat_history.append(AIMessage(content=chat_message["content"]))
139
  return formatted_chat_history
140
-
141
  def get_query_rewrite_prompt(self):
142
  # Prompt template for query rewriting from chat history. This will translate a query such as "how does it work?" after a question like "what is spark?" to "how does spark work?"
143
  query_rewrite_template = """Based on the chat history below, we want you to generate a query for an external data source to retrieve relevant information so
 
130
  history = self.extract_chat_history(chat_messages_array)
131
  formatted_chat_history = []
132
  if len(history) > 0:
133
+ # TODO grab at most just the last three sets of queries and respones as chat history for relevant context - limit history so as to not overflow 32k context window
134
+ # model seems to be hallucinating, readd entire chat history.
135
+ # for chat_message in history[-6:]:
136
+ for chat_message in history:
137
  if chat_message["role"] == "user":
138
  formatted_chat_history.append(HumanMessage(content=chat_message["content"]))
139
  elif chat_message["role"] == "assistant":
140
  formatted_chat_history.append(AIMessage(content=chat_message["content"]))
141
  return formatted_chat_history
142
+
143
  def get_query_rewrite_prompt(self):
144
  # Prompt template for query rewriting from chat history. This will translate a query such as "how does it work?" after a question like "what is spark?" to "how does spark work?"
145
  query_rewrite_template = """Based on the chat history below, we want you to generate a query for an external data source to retrieve relevant information so