Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,12 +112,14 @@ for f in os.listdir("multiple_docs"):
|
|
| 112 |
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=10)
|
| 113 |
docs = splitter.split_documents(docs)
|
| 114 |
|
| 115 |
-
#
|
| 116 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 117 |
-
|
|
|
|
| 118 |
|
| 119 |
-
#
|
| 120 |
-
vectorstore = Chroma
|
|
|
|
| 121 |
vectorstore.persist()
|
| 122 |
|
| 123 |
# Load the Hugging Face model for text generation
|
|
@@ -172,3 +174,4 @@ demo.launch(debug=True)
|
|
| 172 |
|
| 173 |
|
| 174 |
|
|
|
|
|
|
| 112 |
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=10)
|
| 113 |
docs = splitter.split_documents(docs)
|
| 114 |
|
| 115 |
+
# Extract the content from documents and create embeddings
|
| 116 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 117 |
+
texts = [doc.page_content for doc in docs]
|
| 118 |
+
embeddings = embedding_model.encode(texts)
|
| 119 |
|
| 120 |
+
# Create a Chroma vector store and add documents and their embeddings
|
| 121 |
+
vectorstore = Chroma(persist_directory="./data")
|
| 122 |
+
vectorstore.add_texts(texts, embeddings)
|
| 123 |
vectorstore.persist()
|
| 124 |
|
| 125 |
# Load the Hugging Face model for text generation
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
+
|