Skip to content

Commit 59e4f43

Browse files
committed
fix: Add cosine distance metric to remaining collection creation calls
- Fix all create_collection calls to use distance_metric='cosine' - Includes exception handlers and error recovery paths - Ensures all new collections use cosine distance for normalized embeddings
1 parent f50442f commit 59e4f43

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

stillme_core/rag/chroma_client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ def __init__(self, persist_directory: str = None, reset_on_error: bool = False,
258258
pass
259259
self.knowledge_collection = self.client.create_collection(
260260
name="stillme_knowledge",
261-
metadata={"description": "Knowledge base for StillMe learning"}
261+
metadata={"description": "Knowledge base for StillMe learning"},
262+
# CRITICAL: Use cosine distance for normalized embeddings
263+
distance_metric="cosine"
262264
)
263265
else:
264266
raise
@@ -282,7 +284,9 @@ def __init__(self, persist_directory: str = None, reset_on_error: bool = False,
282284
pass
283285
self.conversation_collection = self.client.create_collection(
284286
name="stillme_conversations",
285-
metadata={"description": "Conversation history for context"}
287+
metadata={"description": "Conversation history for context"},
288+
# CRITICAL: Use cosine distance for normalized embeddings
289+
distance_metric="cosine"
286290
)
287291
else:
288292
raise
@@ -526,11 +530,15 @@ def __init__(self, persist_directory: str = None, reset_on_error: bool = False,
526530
# Create fresh collections
527531
self.knowledge_collection = self.client.create_collection(
528532
name="stillme_knowledge",
529-
metadata={"description": "Knowledge base for StillMe learning"}
533+
metadata={"description": "Knowledge base for StillMe learning"},
534+
# CRITICAL: Use cosine distance for normalized embeddings
535+
distance_metric="cosine"
530536
)
531537
self.conversation_collection = self.client.create_collection(
532538
name="stillme_conversations",
533-
metadata={"description": "Conversation history for context"}
539+
metadata={"description": "Conversation history for context"},
540+
# CRITICAL: Use cosine distance for normalized embeddings
541+
distance_metric="cosine"
534542
)
535543
logger.info("✅ ChromaDB database reset successfully - fresh collections created")
536544
except Exception as reset_error:

0 commit comments

Comments
 (0)