Open HagaiHen opened 1 year ago
facing the same issue
same issue
So I fixed this problem: heres the thing that you to change such that it works.
Switch the functions 'handle_userinput' and 'get_conversation_chain' with those functions:
def get_conversation_chain(vectorstore):
llm = ChatOpenAI()
conversation_chain = ConversationalRetrievalChain.from_llm(
llm=llm,
retriever=vectorstore.as_retriever(),
)
return conversation_chain
def handle_userinput(user_question):
response = st.session_state.conversation({"question": user_question, "chat_history": st.session_state.chat_history})
st.session_state.chat_history.append((user_question, response["answer"]))
history = st.session_state.chat_history[::-1]
for message in history:
st.write(bot_template.replace(
"{{MSG}}", message[1]), unsafe_allow_html=True)
st.write(user_template.replace(
"{{MSG}}", message[0]), unsafe_allow_html=True)
on the main function: initilize 'chat_history' like that:
if "chat_history" not in st.session_state:
st.session_state.chat_history = []
Now, it shuold work.
On the first Question it work good. But after I sent the next question it throw an error: