Skip to content

Commit

Permalink
community[patch]: Fix the bug that Chroma does not specify `embedding…
Browse files Browse the repository at this point in the history
…_function` (#19277)

- **Issue:** close #18291
- @baskaryan, @eyurtsev PTAL
  • Loading branch information
liugddx committed Mar 27, 2024
1 parent 85f57ab commit 7042934
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libs/community/langchain_community/vectorstores/chroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import chromadb.config
from chromadb.api.types import ID, OneOrMany, Where, WhereDocument


logger = logging.getLogger()
DEFAULT_K = 4 # Number of Documents to return.

Expand Down Expand Up @@ -80,6 +81,7 @@ def __init__(
try:
import chromadb
import chromadb.config
from chromadb.utils import embedding_functions
except ImportError:
raise ImportError(
"Could not import chromadb python package. "
Expand Down Expand Up @@ -122,10 +124,12 @@ def __init__(
_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
Expand Down

0 comments on commit 7042934

Please sign in to comment.