Skip to content

Commit

Permalink
refactor out a get_welcome_message() stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantisan committed Sep 27, 2023
1 parent 9d11b5a commit db74fe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mind_palace/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
import index
import openai
import streamlit as st
import welcome
from llama_index.query_engine import CitationQueryEngine

openai.api_key = st.secrets.openai_key
xml_dir = "./resources/xmls/12-pdfs-from-steve-aug-22/"
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(
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mind_palace/welcome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def get_welcome_message(nodes):
return "Ask me a question about these PDFs"

0 comments on commit db74fe3

Please sign in to comment.