Spaces:
Runtime error
Runtime error
V1.7 - Update to 3072 dimensions
Browse files
app/services/vector_store.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import List
|
|
| 7 |
from ..config import settings
|
| 8 |
|
| 9 |
logger = logging.getLogger("rag-pipeline.vector_store")
|
| 10 |
-
logger.info("VECTOR_STORE_V1.
|
| 11 |
|
| 12 |
# Initialize Gemini Client
|
| 13 |
client = None
|
|
@@ -15,11 +15,10 @@ if settings.GOOGLE_GEMINI_API_KEY:
|
|
| 15 |
client = genai.Client(api_key=settings.GOOGLE_GEMINI_API_KEY)
|
| 16 |
|
| 17 |
# Modern Google GenAI SDK model names
|
| 18 |
-
# Update: 'text-embedding-004' is deprecated in some SDK versions,
|
| 19 |
-
# 'gemini-embedding-001' is the new standard.
|
| 20 |
PRIMARY_MODEL = "gemini-embedding-001"
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
def _get_vecs_collection():
|
| 25 |
"""Helper to get/create a vecs collection with better diagnostics"""
|
|
@@ -32,6 +31,7 @@ def _get_vecs_collection():
|
|
| 32 |
vx = vecs.create_client(db_url)
|
| 33 |
|
| 34 |
# Get or create the collection
|
|
|
|
| 35 |
return vx.get_or_create_collection(name=COLLECTION_NAME, dimension=VECTOR_DIMENSION)
|
| 36 |
except Exception as e:
|
| 37 |
error_msg = str(e)
|
|
|
|
| 7 |
from ..config import settings
|
| 8 |
|
| 9 |
logger = logging.getLogger("rag-pipeline.vector_store")
|
| 10 |
+
logger.info("VECTOR_STORE_V1.7_INITIALIZED")
|
| 11 |
|
| 12 |
# Initialize Gemini Client
|
| 13 |
client = None
|
|
|
|
| 15 |
client = genai.Client(api_key=settings.GOOGLE_GEMINI_API_KEY)
|
| 16 |
|
| 17 |
# Modern Google GenAI SDK model names
|
|
|
|
|
|
|
| 18 |
PRIMARY_MODEL = "gemini-embedding-001"
|
| 19 |
+
# Critical Update: gemini-embedding-001 returns 3072 dimensions by default in the new SDK
|
| 20 |
+
VECTOR_DIMENSION = 3072
|
| 21 |
+
COLLECTION_NAME = "document_embeddings_v3" # Renamed to apply new dimension
|
| 22 |
|
| 23 |
def _get_vecs_collection():
|
| 24 |
"""Helper to get/create a vecs collection with better diagnostics"""
|
|
|
|
| 31 |
vx = vecs.create_client(db_url)
|
| 32 |
|
| 33 |
# Get or create the collection
|
| 34 |
+
logger.info(f"Accessing collection: {COLLECTION_NAME} (Dim: {VECTOR_DIMENSION})")
|
| 35 |
return vx.get_or_create_collection(name=COLLECTION_NAME, dimension=VECTOR_DIMENSION)
|
| 36 |
except Exception as e:
|
| 37 |
error_msg = str(e)
|