mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
fix(core): handle chromadb import error gracefully (#192)
- Changed CHROMADB_AVAILABLE flag to _CHROMADB_IMPORT_ERROR exception storage - Updated version from 0.3.1.7 to 0.3.1.8 - Modified import error handling to preserve original exception details - Removed hardcoded ImportError message in favor of dynamic exception raising - Added proper logger initialization using get_logger utility
This commit is contained in:
parent
9ad8120959
commit
a97635752b
2 changed files with 9 additions and 10 deletions
|
|
@ -6,7 +6,7 @@ from . import extension
|
|||
from . import memory
|
||||
from .reme import ReMe
|
||||
|
||||
__version__ = "0.3.1.7"
|
||||
__version__ = "0.3.1.8"
|
||||
|
||||
__all__ = [
|
||||
"config",
|
||||
|
|
|
|||
|
|
@ -5,19 +5,20 @@ import random
|
|||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from .base_file_store import BaseFileStore
|
||||
from ..enumeration import MemorySource
|
||||
from ..schema import FileMetadata, MemoryChunk, MemorySearchResult
|
||||
from ..utils import get_logger
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
try:
|
||||
import chromadb
|
||||
from chromadb.config import Settings
|
||||
|
||||
CHROMADB_AVAILABLE = True
|
||||
except ImportError:
|
||||
CHROMADB_AVAILABLE = False
|
||||
_CHROMADB_IMPORT_ERROR: ImportError | None = None
|
||||
except ImportError as e:
|
||||
_CHROMADB_IMPORT_ERROR = e
|
||||
chromadb = None
|
||||
Settings = None
|
||||
|
||||
|
|
@ -39,10 +40,8 @@ class ChromaFileStore(BaseFileStore):
|
|||
self,
|
||||
**kwargs,
|
||||
):
|
||||
if not CHROMADB_AVAILABLE:
|
||||
raise ImportError(
|
||||
"chromadb package is required for ChromaFileStore. Install it with: pip install chromadb",
|
||||
)
|
||||
if _CHROMADB_IMPORT_ERROR is not None:
|
||||
raise _CHROMADB_IMPORT_ERROR
|
||||
|
||||
super().__init__(**kwargs)
|
||||
self.client: "chromadb.ClientAPI | None" = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue