Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -89,7 +89,6 @@ from langchain.vectorstores import Chroma
|
|
89 |
import gradio as gr
|
90 |
from transformers import pipeline
|
91 |
from sentence_transformers import SentenceTransformer
|
92 |
-
from langchain.embeddings.openai import OpenAIEmbeddings
|
93 |
|
94 |
__import__('pysqlite3')
|
95 |
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
|
@@ -118,8 +117,8 @@ embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
|
118 |
texts = [doc.page_content for doc in docs]
|
119 |
embeddings = embedding_model.encode(texts).tolist() # Convert numpy arrays to lists
|
120 |
|
121 |
-
# Create a Chroma vector store and add documents and their embeddings
|
122 |
-
vectorstore = Chroma(persist_directory="./db",embedding_function=
|
123 |
vectorstore.add_texts(texts=texts, metadatas=[{"id": i} for i in range(len(texts))], embeddings=embeddings)
|
124 |
vectorstore.persist()
|
125 |
|
@@ -182,3 +181,4 @@ demo.launch(debug=True)
|
|
182 |
|
183 |
|
184 |
|
|
|
|
89 |
import gradio as gr
|
90 |
from transformers import pipeline
|
91 |
from sentence_transformers import SentenceTransformer
|
|
|
92 |
|
93 |
__import__('pysqlite3')
|
94 |
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
|
|
|
117 |
texts = [doc.page_content for doc in docs]
|
118 |
embeddings = embedding_model.encode(texts).tolist() # Convert numpy arrays to lists
|
119 |
|
120 |
+
# Create a Chroma vector store with an embedding function and add documents and their embeddings
|
121 |
+
vectorstore = Chroma(persist_directory="./db", embedding_function=embedding_model.encode)
|
122 |
vectorstore.add_texts(texts=texts, metadatas=[{"id": i} for i in range(len(texts))], embeddings=embeddings)
|
123 |
vectorstore.persist()
|
124 |
|
|
|
181 |
|
182 |
|
183 |
|
184 |
+
|