Spaces:
Sleeping
Sleeping
start on reranking
Browse files- rag_app/get_db_retriever.py +2 -1
- rag_app/reranking.py +23 -0
rag_app/get_db_retriever.py
CHANGED
@@ -26,4 +26,5 @@ def get_db_retriever(vector_db:str=None):
|
|
26 |
|
27 |
retriever = db.as_retriever()
|
28 |
|
29 |
-
return retriever
|
|
|
|
26 |
|
27 |
retriever = db.as_retriever()
|
28 |
|
29 |
+
return retriever
|
30 |
+
|
rag_app/reranking.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from get_db_retriever import get_db_retriever
|
2 |
+
from pathlib import Path
|
3 |
+
from langchain_community.vectorstores import FAISS
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
import os
|
6 |
+
from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
|
7 |
+
|
8 |
+
load_dotenv()
|
9 |
+
|
10 |
+
HUGGINGFACEHUB_API_TOKEN = os.getenv('HUGGINGFACEHUB_API_TOKEN')
|
11 |
+
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL")
|
12 |
+
|
13 |
+
embeddings = HuggingFaceInferenceAPIEmbeddings(api_key=HUGGINGFACEHUB_API_TOKEN,
|
14 |
+
model_name=EMBEDDING_MODEL)
|
15 |
+
|
16 |
+
path_to_vector_db = Path("..")/'vectorstore'/'faiss-insurance-agent-500'
|
17 |
+
|
18 |
+
db = FAISS.load_local(FAISS_INDEX_PATH, embeddings)
|
19 |
+
|
20 |
+
# retreiver = get_db_retriever(vector_db=Path("..")/)
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
print(path_to_vector_db.exists())
|