Technocoloredgeek commited on
Commit
c8181a4
1 Parent(s): bef4c68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -10,6 +10,7 @@ from langchain_core.runnables import RunnablePassthrough
10
  from qdrant_client import QdrantClient
11
  from qdrant_client.http.models import Distance, VectorParams
12
  from operator import itemgetter
 
13
 
14
  from sentence_transformers import SentenceTransformer
15
 
@@ -44,21 +45,26 @@ def load_and_process_pdfs(pdf_links):
44
  def setup_vectorstore():
45
  LOCATION = ":memory:"
46
  COLLECTION_NAME = "AI_Ethics_Framework"
47
- VECTOR_SIZE = 1536
48
-
49
  qdrant_client = QdrantClient(location=LOCATION)
50
 
 
 
 
 
 
 
51
  # Create the collection
52
  qdrant_client.create_collection(
53
  collection_name=COLLECTION_NAME,
54
  vectors_config=VectorParams(size=VECTOR_SIZE, distance=Distance.COSINE),
55
  )
56
 
57
- # Create the vector store
58
  qdrant_vector_store = QdrantVectorStore(
59
  client=qdrant_client,
60
  collection_name=COLLECTION_NAME,
61
- embedding=OpenAIEmbeddings()
62
  )
63
 
64
  # Load and add documents
 
10
  from qdrant_client import QdrantClient
11
  from qdrant_client.http.models import Distance, VectorParams
12
  from operator import itemgetter
13
+ from langchain_community.embeddings import HuggingFaceEmbeddings # Add this line
14
 
15
  from sentence_transformers import SentenceTransformer
16
 
 
45
  def setup_vectorstore():
46
  LOCATION = ":memory:"
47
  COLLECTION_NAME = "AI_Ethics_Framework"
48
+
 
49
  qdrant_client = QdrantClient(location=LOCATION)
50
 
51
+ # Use your SentenceTransformer model for embeddings
52
+ embeddings = HuggingFaceEmbeddings(model_name="Technocoloredgeek/midterm-finetuned-embedding")
53
+
54
+ # Get the vector size from the embeddings
55
+ VECTOR_SIZE = len(embeddings.embed_query("test"))
56
+
57
  # Create the collection
58
  qdrant_client.create_collection(
59
  collection_name=COLLECTION_NAME,
60
  vectors_config=VectorParams(size=VECTOR_SIZE, distance=Distance.COSINE),
61
  )
62
 
63
+ # Create the vector store with the new embeddings
64
  qdrant_vector_store = QdrantVectorStore(
65
  client=qdrant_client,
66
  collection_name=COLLECTION_NAME,
67
+ embedding=embeddings
68
  )
69
 
70
  # Load and add documents