mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
force reseting db in care of change in dimensions
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Any, Dict
|
|||||||
|
|
||||||
from embedchain import App
|
from embedchain import App
|
||||||
from embedchain.llm.base import BaseLlm
|
from embedchain.llm.base import BaseLlm
|
||||||
|
from embedchain.vectordb.chroma import InvalidDimensionException
|
||||||
|
|
||||||
from crewai.memory.storage.interface import Storage
|
from crewai.memory.storage.interface import Storage
|
||||||
from crewai.utilities.paths import db_storage_path
|
from crewai.utilities.paths import db_storage_path
|
||||||
@@ -76,11 +77,15 @@ class RAGStorage(Storage):
|
|||||||
score_threshold: float = 0.35,
|
score_threshold: float = 0.35,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
with suppress_logging():
|
with suppress_logging():
|
||||||
results = (
|
try:
|
||||||
self.app.search(query, limit, where=filter)
|
results = (
|
||||||
if filter
|
self.app.search(query, limit, where=filter)
|
||||||
else self.app.search(query, limit)
|
if filter
|
||||||
)
|
else self.app.search(query, limit)
|
||||||
|
)
|
||||||
|
except InvalidDimensionException:
|
||||||
|
self.app.reset()
|
||||||
|
return []
|
||||||
return [r for r in results if r["metadata"]["score"] >= score_threshold]
|
return [r for r in results if r["metadata"]["score"] >= score_threshold]
|
||||||
|
|
||||||
def _generate_embedding(self, text: str, metadata: Dict[str, Any]) -> Any:
|
def _generate_embedding(self, text: str, metadata: Dict[str, Any]) -> Any:
|
||||||
|
|||||||
Reference in New Issue
Block a user