Skip to content

Commit

Permalink
refactor: vectorstore into session state
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-ao committed Jan 30, 2024
1 parent daa2d09 commit 72f51aa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def get_conversational_rag_chain(retriever_chain):
# app config
st.set_page_config(page_title="Chat with websites", page_icon="🤖")
st.title("Chat with websites")
if "chat_history" not in st.session_state:
st.session_state.chat_history = [
AIMessage(content="Hello, I am a bot. How can I help you?"),
]

# sidebar
with st.sidebar:
Expand All @@ -78,9 +74,17 @@ def get_conversational_rag_chain(retriever_chain):
st.info("Please enter a website URL")

else:
vector_store = get_vectorstore_from_url(website_url)
# session state
if "chat_history" not in st.session_state:
st.session_state.chat_history = [
AIMessage(content="Hello, I am a bot. How can I help you?"),
]
if "vector_store" not in st.session_state:
st.session_state.vector_store = get_vectorstore_from_url(website_url)

# create conversation chain
retriever_chain = get_context_retriever_chain(st.session_state.vector_store)

retriever_chain = get_context_retriever_chain(vector_store)


# user input
Expand Down

0 comments on commit 72f51aa

Please sign in to comment.