Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,7 +53,7 @@ def get_vectorstore(text_chunks):
|
|
53 |
with st.spinner("Creating vectorstore..."):
|
54 |
metadatas = [{"source": f"{i}-pl"} for i in range(len(text_chunks))]
|
55 |
embeddings = OpenAIEmbeddings()
|
56 |
-
vectorstore = Chroma.from_texts(texts=text_chunks, embedding=embeddings, persist_directory="./
|
57 |
return vectorstore
|
58 |
|
59 |
def get_conversation_chain(vectorstore):
|
@@ -99,10 +99,10 @@ def main():
|
|
99 |
st.session_state.chat_history = None
|
100 |
|
101 |
if st.session_state.conversation is None:
|
102 |
-
if os.path.isdir("./
|
103 |
-
if os.listdir("./
|
104 |
with st.spinner("Loading vector store..."):
|
105 |
-
vectorstore = Chroma(persist_directory="./
|
106 |
st.session_state.conversation = get_conversation_chain(vectorstore)
|
107 |
else:
|
108 |
retrain_model()
|
|
|
53 |
with st.spinner("Creating vectorstore..."):
|
54 |
metadatas = [{"source": f"{i}-pl"} for i in range(len(text_chunks))]
|
55 |
embeddings = OpenAIEmbeddings()
|
56 |
+
vectorstore = Chroma.from_texts(texts=text_chunks, embedding=embeddings, persist_directory="./data/vectorstore", metadatas=metadatas)
|
57 |
return vectorstore
|
58 |
|
59 |
def get_conversation_chain(vectorstore):
|
|
|
99 |
st.session_state.chat_history = None
|
100 |
|
101 |
if st.session_state.conversation is None:
|
102 |
+
if os.path.isdir("./data/vectorstore"):
|
103 |
+
if os.listdir("./data/vectorstore"):
|
104 |
with st.spinner("Loading vector store..."):
|
105 |
+
vectorstore = Chroma(persist_directory="./data/vectorstore", embedding_function=OpenAIEmbeddings())
|
106 |
st.session_state.conversation = get_conversation_chain(vectorstore)
|
107 |
else:
|
108 |
retrain_model()
|