mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 14:43:07 +00:00
community[patch]: Fix the bug that Chroma does not specify embedding_function (#19277)
- **Issue:** close #18291 - @baskaryan, @eyurtsev PTAL
This commit is contained in:
committed by
William Fu-Hinthorn
parent
9cdc2dc3d5
commit
d6b8be6c9b
@@ -28,6 +28,7 @@ if TYPE_CHECKING:
|
||||
import chromadb.config
|
||||
from chromadb.api.types import ID, OneOrMany, Where, WhereDocument
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
DEFAULT_K = 4 # Number of Documents to return.
|
||||
|
||||
@@ -80,6 +81,7 @@ class Chroma(VectorStore):
|
||||
try:
|
||||
import chromadb
|
||||
import chromadb.config
|
||||
from chromadb.utils import embedding_functions
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Could not import chromadb python package. "
|
||||
@@ -122,10 +124,12 @@ class Chroma(VectorStore):
|
||||
_client_settings.persist_directory or persist_directory
|
||||
)
|
||||
|
||||
self._embedding_function = embedding_function
|
||||
self._embedding_function = (
|
||||
embedding_function or embedding_functions.DefaultEmbeddingFunction()
|
||||
)
|
||||
self._collection = self._client.get_or_create_collection(
|
||||
name=collection_name,
|
||||
embedding_function=None,
|
||||
embedding_function=self._embedding_function,
|
||||
metadata=collection_metadata,
|
||||
)
|
||||
self.override_relevance_score_fn = relevance_score_fn
|
||||
|
||||
Reference in New Issue
Block a user