mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 14:18:52 +00:00
community[patch]: deprecate persist method in Chroma (#20855)
Thank you for contributing to LangChain! - [x] **PR title** - [x] **PR message**: - **Description:** Deprecate persist method in Chroma no longer exists in Chroma 0.4.x - **Issue:** #20851 - **Dependencies:** None - **Twitter handle:** AndresAlgaba1 - [x] **Add tests and docs**: If you're adding a new integration, please include 1. a test for the integration, preferably unit tests that do not rely on network access, 2. an example notebook showing its use. It lives in `docs/docs/integrations` directory. - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ --------- Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
parent
fdabd3cdf5
commit
05ae8ca7d4
@ -16,6 +16,7 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.embeddings import Embeddings
|
from langchain_core.embeddings import Embeddings
|
||||||
from langchain_core.utils import xor_args
|
from langchain_core.utils import xor_args
|
||||||
@ -610,11 +611,22 @@ class Chroma(VectorStore):
|
|||||||
|
|
||||||
return self._collection.get(**kwargs)
|
return self._collection.get(**kwargs)
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
since="0.1.17",
|
||||||
|
message=(
|
||||||
|
"Since Chroma 0.4.x the manual persistence method is no longer "
|
||||||
|
"supported as docs are automatically persisted."
|
||||||
|
),
|
||||||
|
removal="0.3.0",
|
||||||
|
)
|
||||||
def persist(self) -> None:
|
def persist(self) -> None:
|
||||||
"""Persist the collection.
|
"""Persist the collection.
|
||||||
|
|
||||||
This can be used to explicitly persist the data to disk.
|
This can be used to explicitly persist the data to disk.
|
||||||
It will also be called automatically when the object is destroyed.
|
It will also be called automatically when the object is destroyed.
|
||||||
|
|
||||||
|
Since Chroma 0.4.x the manual persistence method is no longer
|
||||||
|
supported as docs are automatically persisted.
|
||||||
"""
|
"""
|
||||||
if self._persist_directory is None:
|
if self._persist_directory is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -136,8 +136,6 @@ def test_chroma_with_persistence() -> None:
|
|||||||
output = docsearch.similarity_search("foo", k=1)
|
output = docsearch.similarity_search("foo", k=1)
|
||||||
assert output == [Document(page_content="foo")]
|
assert output == [Document(page_content="foo")]
|
||||||
|
|
||||||
docsearch.persist()
|
|
||||||
|
|
||||||
# Get a new VectorStore from the persisted directory
|
# Get a new VectorStore from the persisted directory
|
||||||
docsearch = Chroma(
|
docsearch = Chroma(
|
||||||
collection_name=collection_name,
|
collection_name=collection_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user