Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,15 @@ from langchain.document_loaders import PyPDFLoader
|
|
13 |
from fastapi.encoders import jsonable_encoder
|
14 |
from dotenv import load_dotenv
|
15 |
|
16 |
-
load_dotenv()
|
17 |
-
logging.basicConfig(level=logging.DEBUG)
|
18 |
|
19 |
ABS_PATH = os.path.dirname(os.path.abspath(__file__))
|
20 |
DB_DIR = os.path.join(ABS_PATH, "db")
|
21 |
|
|
|
22 |
#embedding_function
|
|
|
23 |
|
24 |
def replace_newlines_and_spaces(text):
|
25 |
# Replace all newline characters with spaces
|
@@ -77,10 +79,10 @@ def query_chromadb():
|
|
77 |
|
78 |
# Select which embeddings we want to use
|
79 |
#embeddings = OpenAIEmbeddings()
|
80 |
-
embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
81 |
|
82 |
# Load Vector store from local disk
|
83 |
-
vectorstore = Chroma(persist_directory=DB_DIR, embedding_function=embeddings)
|
84 |
#vectorstore.persist()
|
85 |
|
86 |
result = vectorstore.similarity_search_with_score(query="how to use AI in water conservation?", k=4)
|
|
|
13 |
from fastapi.encoders import jsonable_encoder
|
14 |
from dotenv import load_dotenv
|
15 |
|
16 |
+
#load_dotenv()
|
17 |
+
#logging.basicConfig(level=logging.DEBUG)
|
18 |
|
19 |
ABS_PATH = os.path.dirname(os.path.abspath(__file__))
|
20 |
DB_DIR = os.path.join(ABS_PATH, "db")
|
21 |
|
22 |
+
vectorstore = None
|
23 |
#embedding_function
|
24 |
+
embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
25 |
|
26 |
def replace_newlines_and_spaces(text):
|
27 |
# Replace all newline characters with spaces
|
|
|
79 |
|
80 |
# Select which embeddings we want to use
|
81 |
#embeddings = OpenAIEmbeddings()
|
82 |
+
#embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
83 |
|
84 |
# Load Vector store from local disk
|
85 |
+
#vectorstore = Chroma(persist_directory=DB_DIR, embedding_function=embeddings)
|
86 |
#vectorstore.persist()
|
87 |
|
88 |
result = vectorstore.similarity_search_with_score(query="how to use AI in water conservation?", k=4)
|