pluto90 commited on
Commit
fe78daa
Β·
verified Β·
1 Parent(s): 674eb2d

Update app/core/embedding_engine.py

Browse files
Files changed (1) hide show
  1. app/core/embedding_engine.py +5 -25
app/core/embedding_engine.py CHANGED
@@ -1,33 +1,13 @@
1
- # embedding_engine.py
 
2
  import uuid, time
3
- from pathlib import Path
4
  from qdrant_client import QdrantClient, models
5
  from qdrant_client.http.models import Distance, VectorParams
6
  from sentence_transformers import SentenceTransformer
7
  from app.core.config import QDRANT_URL, QDRANT_API_KEY
8
 
9
- # MODEL_PATH = "app/core/models/bge-base-en-v1.5"
10
- # embedder = SentenceTransformer(MODEL_PATH)
11
-
12
-
13
- # βœ… Resolve model path relative to THIS file, not the working directory
14
- # Works on local, HuggingFace, Docker β€” anywhere
15
- BASE_DIR = Path(__file__).resolve().parent # β†’ app/core/
16
- MODEL_PATH = BASE_DIR / "models" / "bge-base-en-v1.5"
17
-
18
- print(f"πŸ“ Model path: {MODEL_PATH}")
19
- print(f"πŸ“ Model exists: {MODEL_PATH.exists()}")
20
-
21
- if not MODEL_PATH.exists():
22
- raise RuntimeError(
23
- f"BGE model not found at {MODEL_PATH}. "
24
- f"Ensure the model folder is committed to the repo under app/core/models/bge-base-en-v1.5/"
25
- )
26
-
27
- embedder = SentenceTransformer(str(MODEL_PATH)) # SentenceTransformer needs str, not Path
28
- print("βœ… Embedder loaded successfully")
29
-
30
-
31
 
32
  qdrant = QdrantClient(
33
  url=QDRANT_URL,
@@ -122,6 +102,6 @@ def embed_query(text):
122
  return embedder.encode(
123
  f"query: {text}",
124
  normalize_embeddings=True
125
- ).tolist() # βœ… always return list, not numpy array
126
 
127
 
 
1
+ # app/core/embedding_engine.py
2
+
3
  import uuid, time
 
4
  from qdrant_client import QdrantClient, models
5
  from qdrant_client.http.models import Distance, VectorParams
6
  from sentence_transformers import SentenceTransformer
7
  from app.core.config import QDRANT_URL, QDRANT_API_KEY
8
 
9
+ MODEL_PATH = "app/core/models/bge-base-en-v1.5"
10
+ embedder = SentenceTransformer(MODEL_PATH)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  qdrant = QdrantClient(
13
  url=QDRANT_URL,
 
102
  return embedder.encode(
103
  f"query: {text}",
104
  normalize_embeddings=True
105
+ ).tolist()
106
 
107