Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -85,6 +85,8 @@ def main():
|
|
85 |
st.session_state.conversation = None
|
86 |
if "chat_history" not in st.session_state:
|
87 |
st.session_state.chat_history = None
|
|
|
|
|
88 |
|
89 |
if st.session_state.conversation is None:
|
90 |
if os.path.isdir("./chroma_db"):
|
@@ -92,6 +94,7 @@ def main():
|
|
92 |
with st.spinner("Loading vector store..."):
|
93 |
vectorstore = Chroma(persist_directory="./chroma_db", embedding_function=OpenAIEmbeddings())
|
94 |
st.session_state.conversation = get_conversation_chain(vectorstore)
|
|
|
95 |
|
96 |
if st.session_state.conversation is None:
|
97 |
pdf_doc = getpdfdoc()
|
@@ -110,7 +113,11 @@ def main():
|
|
110 |
|
111 |
if st.session_state.conversation is not None:
|
112 |
st.header("Ask questions from 48 Laws of Power:books:")
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
if user_question:
|
115 |
handle_userinput(user_question)
|
116 |
|
|
|
85 |
st.session_state.conversation = None
|
86 |
if "chat_history" not in st.session_state:
|
87 |
st.session_state.chat_history = None
|
88 |
+
if "vectorstore_saved" not in st.session_state:
|
89 |
+
st.session_state.vectorstore_saved = False
|
90 |
|
91 |
if st.session_state.conversation is None:
|
92 |
if os.path.isdir("./chroma_db"):
|
|
|
94 |
with st.spinner("Loading vector store..."):
|
95 |
vectorstore = Chroma(persist_directory="./chroma_db", embedding_function=OpenAIEmbeddings())
|
96 |
st.session_state.conversation = get_conversation_chain(vectorstore)
|
97 |
+
st.session_state.vectorstore_saved = True
|
98 |
|
99 |
if st.session_state.conversation is None:
|
100 |
pdf_doc = getpdfdoc()
|
|
|
113 |
|
114 |
if st.session_state.conversation is not None:
|
115 |
st.header("Ask questions from 48 Laws of Power:books:")
|
116 |
+
if st.session_state.vectorstore_saved:
|
117 |
+
st.info("Chroma saved")
|
118 |
+
else:
|
119 |
+
st.info("Chroma failed to save")
|
120 |
+
user_question = st.chat_input("Ask a question related 48 Laws of Power:")
|
121 |
if user_question:
|
122 |
handle_userinput(user_question)
|
123 |
|