Spaces:
Runtime error
Runtime error
Delete auditqa/engine/vectorstore.py
Browse files
auditqa/engine/vectorstore.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
from langchain_community.embeddings import HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
|
2 |
-
from langchain_community.vectorstores import Chroma, Qdrant
|
3 |
-
from qdrant_client import QdrantClient
|
4 |
-
from qdrant_client.models import Distance, VectorParams
|
5 |
-
from dotenv import load_dotenv
|
6 |
-
import os
|
7 |
-
|
8 |
-
provider_retrieval_model = "HF"
|
9 |
-
embeddingmodel = "sentence-transformers/all-MiniLM-l6-v2"
|
10 |
-
load_dotenv()
|
11 |
-
HF_Token = os.environ.get("HF_TOKEN")
|
12 |
-
client_path = "./vectorstore/"
|
13 |
-
collection_name = "collection"
|
14 |
-
provider_retrieval_model = "HF"
|
15 |
-
|
16 |
-
def create_vectorstore(docs):
|
17 |
-
|
18 |
-
if provider_retrieval_model == "HF":
|
19 |
-
qdrantClient = QdrantClient(path=client_path, prefer_grpc=True)
|
20 |
-
|
21 |
-
embeddings = HuggingFaceInferenceAPIEmbeddings(
|
22 |
-
api_key=HF_Token, model_name=embeddingmodel
|
23 |
-
)
|
24 |
-
|
25 |
-
dim = 384
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
qdrantClient.create_collection(
|
30 |
-
collection_name=collection_name,
|
31 |
-
vectors_config=VectorParams(size=dim, distance=Distance.COSINE),
|
32 |
-
)
|
33 |
-
|
34 |
-
vectorstore = Qdrant(
|
35 |
-
client=qdrantClient,
|
36 |
-
collection_name=collection_name,
|
37 |
-
embeddings=embeddings,
|
38 |
-
)
|
39 |
-
|
40 |
-
vectorstore.add_documents(docs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|