Update appChatbot.py
Browse files- appChatbot.py +5 -2
appChatbot.py
CHANGED
@@ -7,6 +7,7 @@ import gradio as gr
|
|
7 |
from huggingface_hub import InferenceClient
|
8 |
|
9 |
#from chromadb.utils import embedding_functions
|
|
|
10 |
|
11 |
from langchain.text_splitter import CharacterTextSplitter
|
12 |
from langchain.embeddings import OpenAIEmbeddings
|
@@ -50,7 +51,8 @@ def init_chromadb():
|
|
50 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
51 |
texts = text_splitter.split_documents(documents)
|
52 |
# Select which embeddings we want to use
|
53 |
-
embeddings = OpenAIEmbeddings()
|
|
|
54 |
#query_chromadb()
|
55 |
|
56 |
# Create the vectorestore to use as the index
|
@@ -64,7 +66,8 @@ def query_chromadb(ASK):
|
|
64 |
raise Exception(f"{DB_DIR} does not exist, nothing can be queried")
|
65 |
|
66 |
# Select which embeddings we want to use
|
67 |
-
embeddings = OpenAIEmbeddings()
|
|
|
68 |
# Load Vector store from local disk
|
69 |
vectorstore = Chroma(persist_directory=DB_DIR, embedding_function=embeddings)
|
70 |
|
|
|
7 |
from huggingface_hub import InferenceClient
|
8 |
|
9 |
#from chromadb.utils import embedding_functions
|
10 |
+
from langchain_community.embeddings import SentenceTransformerEmbeddings
|
11 |
|
12 |
from langchain.text_splitter import CharacterTextSplitter
|
13 |
from langchain.embeddings import OpenAIEmbeddings
|
|
|
51 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
52 |
texts = text_splitter.split_documents(documents)
|
53 |
# Select which embeddings we want to use
|
54 |
+
#embeddings = OpenAIEmbeddings()
|
55 |
+
embeddings = SentenceTransformerEmbeddings(model_name="nomic-ai/nomic-embed-text-v1", model_kwargs={"trust_remote_code":True})
|
56 |
#query_chromadb()
|
57 |
|
58 |
# Create the vectorestore to use as the index
|
|
|
66 |
raise Exception(f"{DB_DIR} does not exist, nothing can be queried")
|
67 |
|
68 |
# Select which embeddings we want to use
|
69 |
+
#embeddings = OpenAIEmbeddings()
|
70 |
+
embeddings = SentenceTransformerEmbeddings(model_name="nomic-ai/nomic-embed-text-v1", model_kwargs={"trust_remote_code":True})
|
71 |
# Load Vector store from local disk
|
72 |
vectorstore = Chroma(persist_directory=DB_DIR, embedding_function=embeddings)
|
73 |
|