Skip to content

Commit

Permalink
fix: clear the chat history
Browse files Browse the repository at this point in the history
  • Loading branch information
umbertogriffo committed Jan 8, 2024
1 parent 2babff6 commit 89f2056
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chatbot/chatbot_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def init_welcome_message() -> None:

def init_chat_history(conversational_retrieval: ConversationRetrieval) -> None:
"""
Initialize chat history.
Initializes the chat history, allowing users to clear the conversation.
"""
clear_button = st.sidebar.button("Clear Conversation", key="clear")
if clear_button or "messages" not in st.session_state:
Expand Down
5 changes: 3 additions & 2 deletions chatbot/rag_chatbot_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ def init_welcome_message() -> None:
st.write("How can I help you today?")


def init_messages() -> None:
def init_chat_history(conversational_retrieval: ConversationRetrieval) -> None:
"""
Initializes the chat history, allowing users to clear the conversation.
"""
clear_button = st.sidebar.button("Clear Conversation", key="clear")
if clear_button or "messages" not in st.session_state:
st.session_state.messages = []
conversational_retrieval.get_chat_history().clear()


def display_messages_from_history():
Expand Down Expand Up @@ -129,7 +130,7 @@ def main(parameters) -> None:
conversational_retrieval = load_conversational_retrieval(_llm=llm)
ctx_synthesis_strategy = load_ctx_synthesis_strategy(synthesis_strategy_name, _llm=llm)
index = load_index(vector_store_path)
init_messages()
init_chat_history(conversational_retrieval)
init_welcome_message()
display_messages_from_history()

Expand Down

0 comments on commit 89f2056

Please sign in to comment.