Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,8 +24,6 @@ from itertools import combinations
|
|
| 24 |
import pypdf
|
| 25 |
import requests
|
| 26 |
|
| 27 |
-
from chromadb.utils import embedding_functions
|
| 28 |
-
from chromadb import Documents, EmbeddingFunction, Embeddings
|
| 29 |
|
| 30 |
# LLM: openai and google_genai
|
| 31 |
import openai
|
|
@@ -87,13 +85,6 @@ cohere_api_key = os.environ['cohere_api']
|
|
| 87 |
|
| 88 |
current_dir = os.getcwd()
|
| 89 |
|
| 90 |
-
# for new Chromadb
|
| 91 |
-
class MyEmbeddingFunction(EmbeddingFunction[Documents]):
|
| 92 |
-
def __call__(self, input: Documents) -> Embeddings:
|
| 93 |
-
sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="BAAI/bge-large-en-v1.5")
|
| 94 |
-
embeddings = sentence_transformer_ef(input)
|
| 95 |
-
return embeddings
|
| 96 |
-
custom = MyEmbeddingFunction()
|
| 97 |
|
| 98 |
|
| 99 |
|
|
@@ -255,8 +246,7 @@ embeddings_HuggingFace = select_embeddings_model(LLM_service="HuggingFace")
|
|
| 255 |
def create_vectorstore(embeddings,documents,vectorstore_name):
|
| 256 |
"""Create a Chroma vector database."""
|
| 257 |
persist_directory = (current_dir + "/" + vectorstore_name)
|
| 258 |
-
|
| 259 |
-
embedding_function=custom
|
| 260 |
vector_store = Chroma.from_documents(
|
| 261 |
documents=documents,
|
| 262 |
embedding=embeddings,
|
|
|
|
| 24 |
import pypdf
|
| 25 |
import requests
|
| 26 |
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# LLM: openai and google_genai
|
| 29 |
import openai
|
|
|
|
| 85 |
|
| 86 |
current_dir = os.getcwd()
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
|
|
|
|
| 246 |
def create_vectorstore(embeddings,documents,vectorstore_name):
|
| 247 |
"""Create a Chroma vector database."""
|
| 248 |
persist_directory = (current_dir + "/" + vectorstore_name)
|
| 249 |
+
embedding_function=embeddings
|
|
|
|
| 250 |
vector_store = Chroma.from_documents(
|
| 251 |
documents=documents,
|
| 252 |
embedding=embeddings,
|