Karthikeyan commited on
Commit
f7645e3
·
1 Parent(s): 6dbbe77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -126,10 +126,11 @@ class Chatbot:
126
  str: The answer to the question.
127
  """
128
 
129
-
130
  # Retrieve the knowledge base from the state dictionary
131
  knowledge_base = state["knowledge_base"]
132
  retriever = knowledge_base.as_retriever()
 
133
  qa = ConversationalRetrievalChain.from_llm(
134
  llm=OpenAI(temperature=0),
135
  retriever=retriever,
@@ -148,6 +149,7 @@ class Chatbot:
148
  result = qa({"question": query, "chat_history": chat_history})
149
  # Perform a similarity search on the knowledge base to retrieve relevant documents
150
  response = result["answer"]
 
151
  # Return the response as the answer to the question
152
  history[-1][1] = response
153
  return history
 
126
  str: The answer to the question.
127
  """
128
 
129
+ chat_history = []
130
  # Retrieve the knowledge base from the state dictionary
131
  knowledge_base = state["knowledge_base"]
132
  retriever = knowledge_base.as_retriever()
133
+ chat_history.append(question)
134
  qa = ConversationalRetrievalChain.from_llm(
135
  llm=OpenAI(temperature=0),
136
  retriever=retriever,
 
149
  result = qa({"question": query, "chat_history": chat_history})
150
  # Perform a similarity search on the knowledge base to retrieve relevant documents
151
  response = result["answer"]
152
+ chat_history.append(response)
153
  # Return the response as the answer to the question
154
  history[-1][1] = response
155
  return history