diff --git a/mind_palace/app.py b/mind_palace/app.py index 3213110..db4265f 100644 --- a/mind_palace/app.py +++ b/mind_palace/app.py @@ -2,6 +2,7 @@ import index import openai import streamlit as st +import welcome from llama_index.query_engine import CitationQueryEngine openai.api_key = st.secrets.openai_key @@ -9,19 +10,13 @@ gpt_model = "gpt-3.5-turbo" st.set_page_config(page_title="Chatting with Steve's PDFs") -st.title("Chat with Steve's 12 PDFs 💬🦙") +st.title("Chat with Steve's PDFs 💬") with st.sidebar: st.markdown("Conversation History") st.text("Coming soon...") -if "messages" not in st.session_state.keys(): # Initialize the chat messages history - st.session_state.messages = [ - {"role": "assistant", "content": "Ask me a question about these PDFs"} - ] - - @st.cache_resource(show_spinner=False) def load_nodes_and_index(xml_dir, model): with st.spinner( @@ -35,6 +30,13 @@ def load_nodes_and_index(xml_dir, model): nodes, vector_index = load_nodes_and_index(xml_dir, gpt_model) query_engine = CitationQueryEngine.from_args(index=vector_index, verbose=True) + +if "messages" not in st.session_state.keys(): # Initialize the chat messages history + st.session_state.messages = [ + {"role": "assistant", "content": welcome.get_welcome_message(nodes)} + ] + + if prompt := st.chat_input( "Your question" ): # Prompt for user input and save to chat history diff --git a/mind_palace/welcome.py b/mind_palace/welcome.py new file mode 100644 index 0000000..bafe0d6 --- /dev/null +++ b/mind_palace/welcome.py @@ -0,0 +1,2 @@ +def get_welcome_message(nodes): + return "Ask me a question about these PDFs"