Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Collection' object has no attribute 'update_document' #5031

Closed
2 of 14 tasks
martinholecekmax opened this issue May 20, 2023 · 4 comments
Closed
2 of 14 tasks

Comments

@martinholecekmax
Copy link
Contributor

System Info

aiohttp==3.8.4
aiosignal==1.3.1
aniso8601==9.0.1
anyio==3.6.2
async-timeout==4.0.2
attrs==23.1.0
backoff==2.2.1
blinker==1.6.2
certifi==2023.5.7
charset-normalizer==3.1.0
chromadb==0.3.23
click==8.1.3
clickhouse-connect==0.5.24
colorama==0.4.6
dataclasses-json==0.5.7
duckdb==0.8.0
environs==9.5.0
fastapi==0.95.2
filelock==3.12.0
Flask==2.3.2
Flask-RESTful==0.3.9
frozenlist==1.3.3
fsspec==2023.5.0
greenlet==2.0.2
grpcio==1.53.0
h11==0.14.0
hnswlib==0.7.0
httptools==0.5.0
huggingface-hub==0.14.1
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
joblib==1.2.0
langchain==0.0.174
lz4==4.3.2
MarkupSafe==2.1.2
marshmallow==3.19.0
marshmallow-enum==1.5.1
monotonic==1.6
mpmath==1.3.0
multidict==6.0.4
mypy-extensions==1.0.0
networkx==3.1
nltk==3.8.1
numexpr==2.8.4
numpy==1.24.3
openai==0.27.6
openapi-schema-pydantic==1.2.4
packaging==23.1
pandas==2.0.1
Pillow==9.5.0
posthog==3.0.1
protobuf==4.23.1
pydantic==1.10.7
pymilvus==2.2.8
python-dateutil==2.8.2
python-dotenv==1.0.0
pytz==2023.3
PyYAML==6.0
regex==2023.5.5
requests==2.30.0
scikit-learn==1.2.2
scipy==1.10.1
sentence-transformers==2.2.2
sentencepiece==0.1.99
six==1.16.0
sniffio==1.3.0
SQLAlchemy==2.0.13
starlette==0.27.0
sympy==1.12
tenacity==8.2.2
threadpoolctl==3.1.0
tiktoken==0.4.0
tokenizers==0.13.3
torch==2.0.1
torchvision==0.15.2
tqdm==4.65.0
transformers==4.29.2
typing-inspect==0.8.0
typing_extensions==4.5.0
tzdata==2023.3
ujson==5.7.0
urllib3==2.0.2
uvicorn==0.22.0
watchfiles==0.19.0
websockets==11.0.3
Werkzeug==2.3.4
yarl==1.9.2
zstandard==0.21.0

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

Reproduction Steps:

  1. Create an instance of the Collection class.
  2. Initialize the LangChain object and make sure it is properly configured.
  3. Create a Document object and set its page_content and metadata attributes appropriately.
  4. Call the update_document method on the LangChain object, passing the document_id and document as arguments.

Expected Result:
The update_document method should update the specified document in the collection with the provided text and metadata.

Actual Result:
An AttributeError is raised with the following traceback:

File "E:\AI Projects\flask-backend\venv\lib\site-packages\langchain\vectorstores\chroma.py", line 351, in update_document
    self._collection.update_document(document_id, text, metadata)
AttributeError: 'Collection' object has no attribute 'update_document'

Note that the error occurs in the chroma.py file, specifically in the update_document method of the Collection class.

Expected behavior

The update_document method should update the specified document in the collection with the provided text and metadata.

@2796gaurav
Copy link
Contributor

Having same issue in my side too.

@ethanyys
Copy link

Installed langchain 0.0.177, still having the same issue...

@martinholecekmax
Copy link
Contributor Author

I've just created a PR for this issue which can be found here #5359.

hwchase17 pushed a commit that referenced this issue May 29, 2023
# Fix for `update_document` Function in Chroma

## Summary
This pull request addresses an issue with the `update_document` function
in the Chroma class, as described in
[#5031](#5031 (comment)).
The issue was identified as an `AttributeError` raised when calling
`update_document` due to a missing corresponding method in the
`Collection` object. This fix refactors the `update_document` method in
`Chroma` to correctly interact with the `Collection` object.

## Changes
1. Fixed the `update_document` method in the `Chroma` class to correctly
call methods on the `Collection` object.
2. Added the corresponding test `test_chroma_update_document` in
`tests/integration_tests/vectorstores/test_chroma.py` to reflect the
updated method call.
3. Added an example and explanation of how to use the `update_document`
function in the Jupyter notebook tutorial for Chroma.

## Test Plan
All existing tests pass after this change. In addition, the
`test_chroma_update_document` test case now correctly checks the
functionality of `update_document`, ensuring that the function works as
expected and updates the content of documents correctly.

## Reviewers
@dev2049

This fix will ensure that users are able to use the `update_document`
function as expected, without encountering the previous
`AttributeError`. This will enhance the usability and reliability of the
Chroma class for all users.

Thank you for considering this pull request. I look forward to your
feedback and suggestions.
vowelparrot pushed a commit that referenced this issue May 31, 2023
# Fix for `update_document` Function in Chroma

## Summary
This pull request addresses an issue with the `update_document` function
in the Chroma class, as described in
[#5031](#5031 (comment)).
The issue was identified as an `AttributeError` raised when calling
`update_document` due to a missing corresponding method in the
`Collection` object. This fix refactors the `update_document` method in
`Chroma` to correctly interact with the `Collection` object.

## Changes
1. Fixed the `update_document` method in the `Chroma` class to correctly
call methods on the `Collection` object.
2. Added the corresponding test `test_chroma_update_document` in
`tests/integration_tests/vectorstores/test_chroma.py` to reflect the
updated method call.
3. Added an example and explanation of how to use the `update_document`
function in the Jupyter notebook tutorial for Chroma.

## Test Plan
All existing tests pass after this change. In addition, the
`test_chroma_update_document` test case now correctly checks the
functionality of `update_document`, ensuring that the function works as
expected and updates the content of documents correctly.

## Reviewers
@dev2049

This fix will ensure that users are able to use the `update_document`
function as expected, without encountering the previous
`AttributeError`. This will enhance the usability and reliability of the
Chroma class for all users.

Thank you for considering this pull request. I look forward to your
feedback and suggestions.
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this issue Jun 19, 2023
…ai#5359)

# Fix for `update_document` Function in Chroma

## Summary
This pull request addresses an issue with the `update_document` function
in the Chroma class, as described in
[langchain-ai#5031](langchain-ai#5031 (comment)).
The issue was identified as an `AttributeError` raised when calling
`update_document` due to a missing corresponding method in the
`Collection` object. This fix refactors the `update_document` method in
`Chroma` to correctly interact with the `Collection` object.

## Changes
1. Fixed the `update_document` method in the `Chroma` class to correctly
call methods on the `Collection` object.
2. Added the corresponding test `test_chroma_update_document` in
`tests/integration_tests/vectorstores/test_chroma.py` to reflect the
updated method call.
3. Added an example and explanation of how to use the `update_document`
function in the Jupyter notebook tutorial for Chroma.

## Test Plan
All existing tests pass after this change. In addition, the
`test_chroma_update_document` test case now correctly checks the
functionality of `update_document`, ensuring that the function works as
expected and updates the content of documents correctly.

## Reviewers
@dev2049

This fix will ensure that users are able to use the `update_document`
function as expected, without encountering the previous
`AttributeError`. This will enhance the usability and reliability of the
Chroma class for all users.

Thank you for considering this pull request. I look forward to your
feedback and suggestions.
@dosubot
Copy link

dosubot bot commented Sep 12, 2023

Hi, @martinholecekmax! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you reported an AttributeError when calling the update_document method on the LangChain object. Other users, such as 2796gaurav and ethanyys, have also experienced the same issue. However, I see that you have created a pull request (PR) to address this problem, which can be found at this link.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution and we appreciate your understanding!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 12, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants