Spaces:
Running
Running
changed embedding model to HuggingFace mpnet
Browse files
app1.1.py
CHANGED
@@ -7,6 +7,7 @@ from langchain_community.embeddings import OpenAIEmbeddings
|
|
7 |
from langchain.text_splitter import CharacterTextSplitter
|
8 |
from langchain.chat_models import ChatOpenAI
|
9 |
from langchain.schema import Document
|
|
|
10 |
import json
|
11 |
|
12 |
# Load environment variables from .env file
|
@@ -33,7 +34,8 @@ def setup_vector_store_from_json(json_data):
|
|
33 |
documents = [Document(page_content=item["content"], metadata={"url": item["url"]}) for item in json_data]
|
34 |
|
35 |
# Create embeddings and store them in FAISS
|
36 |
-
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
|
|
|
37 |
vector_store = FAISS.from_documents(documents, embeddings)
|
38 |
return vector_store
|
39 |
|
|
|
7 |
from langchain.text_splitter import CharacterTextSplitter
|
8 |
from langchain.chat_models import ChatOpenAI
|
9 |
from langchain.schema import Document
|
10 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
11 |
import json
|
12 |
|
13 |
# Load environment variables from .env file
|
|
|
34 |
documents = [Document(page_content=item["content"], metadata={"url": item["url"]}) for item in json_data]
|
35 |
|
36 |
# Create embeddings and store them in FAISS
|
37 |
+
#embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
|
38 |
+
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
39 |
vector_store = FAISS.from_documents(documents, embeddings)
|
40 |
return vector_store
|
41 |
|