Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,8 @@ from langchain_community.embeddings.sentence_transformer import SentenceTransfor
|
|
5 |
from langchain_community.vectorstores import Chroma
|
6 |
import streamlit as st
|
7 |
|
8 |
-
text_loader_kwargs={'autodetect_encoding': True}
|
9 |
-
loader = DirectoryLoader("src_info_hf", glob="./*.txt", loader_cls=TextLoader, loader_kwargs=text_loader_kwargs)
|
10 |
-
docs = loader.load()
|
11 |
-
|
12 |
-
# split it into chunks
|
13 |
-
#text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
14 |
-
#docs = text_splitter.split_documents(documents)
|
15 |
-
|
16 |
-
# create the open-source embedding function
|
17 |
-
#embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
18 |
embedding_function = SentenceTransformerEmbeddings(model_name="all-mpnet-base-v2")
|
19 |
-
|
20 |
-
# load it into Chroma
|
21 |
-
chdb = Chroma.from_documents(docs, embedding_function, collection_metadata={"hnsw:space": "cosine"}, persist_directory='chroma_db_info')
|
22 |
-
|
23 |
|
24 |
text = st.text_area("enter text")
|
25 |
if text:
|
|
|
5 |
from langchain_community.vectorstores import Chroma
|
6 |
import streamlit as st
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
embedding_function = SentenceTransformerEmbeddings(model_name="all-mpnet-base-v2")
|
9 |
+
chdb = Chroma(persist_directory="./chroma_db_info", embedding_function=embedding_function)
|
|
|
|
|
|
|
10 |
|
11 |
text = st.text_area("enter text")
|
12 |
if text:
|