ppsingh commited on
Commit
fad2247
1 Parent(s): 0e01434

Update auditqa/engine/vectorstore.py

Browse files
Files changed (1) hide show
  1. auditqa/engine/vectorstore.py +30 -2
auditqa/engine/vectorstore.py CHANGED
@@ -1,4 +1,6 @@
1
  from langchain.embeddings import OpenAIEmbeddings, HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
 
 
2
  from dotenv import load_dotenv
3
  import os
4
 
@@ -6,6 +8,32 @@ provider_retrieval_model = "HF"
6
  embeddingmodel = "BAAI/bge-small-en-v1.5"
7
  load_dotenv()
8
  HF_Token = os.environ.get("HF_TOKEN")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- def token():
11
- print(HF_Token)
 
 
 
 
 
 
 
 
 
 
 
 
1
  from langchain.embeddings import OpenAIEmbeddings, HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
2
+ from langchain.vectorstores import Chroma, Qdrant
3
+ from qdrant_client import QdrantClient
4
  from dotenv import load_dotenv
5
  import os
6
 
 
8
  embeddingmodel = "BAAI/bge-small-en-v1.5"
9
  load_dotenv()
10
  HF_Token = os.environ.get("HF_TOKEN")
11
+ client_path = f"./vectorstore"
12
+ collection_name = f"collection"
13
+ provider_retrieval_model = "HF"
14
+
15
+ def create_vectorstore(docs):
16
+
17
+ if provider_retrieval_model == "HF":
18
+ qdrantClient = QdrantClient(path=client_path, prefer_grpc=True)
19
+
20
+ embeddings = HuggingFaceInferenceAPIEmbeddings(
21
+ api_key=HF_Token, model_name=embeddingmodel
22
+ )
23
+
24
+ dim = 1024
25
+
26
 
27
+
28
+ qdrantClient.create_collection(
29
+ collection_name=collection_name,
30
+ vectors_config=VectorParams(size=dim, distance=Distance.COSINE),
31
+ )
32
+
33
+ vectorstore = Qdrant(
34
+ client=qdrantClient,
35
+ collection_name=collection_name,
36
+ embeddings=embeddings,
37
+ )
38
+
39
+ vectorstore.add_documents(docs_samp)