8000 Append and Replace Document Metadata by NolanTrem · Pull Request #2054 · SciPhi-AI/R2R · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Append and Replace Document Metadata #2054

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

Merged
merged 3 commits into from
Mar 18, 2025
Merged

Conversation

NolanTrem
Copy link
Collaborator
@NolanTrem NolanTrem commented Mar 18, 2025

Adds the ability to append and replace the metadata of an existing document via PATCH and PUT requests.

Closes #2030


Important

Add support for appending and replacing document metadata via PATCH and PUT requests, with corresponding client methods and tests.

  • Behavior:
    • Adds appendMetadata() and replaceMetadata() methods to DocumentsClient in documents.ts for appending and replacing document metadata via PATCH and PUT requests.
    • Updates DocumentsRouter in documents_router.py to handle /documents/{id}/metadata endpoints for appending and replacing metadata.
    • Implements update_document_metadata() in management_service.py and documents.py to support metadata operations.
  • Tests:
    • Adds tests for appending and replacing metadata in DocumentsIntegrationSuperUser.test.ts.
  • Misc:
    • Updates package.json and pyproject.toml to increment version numbers.

This description was created by Ellipsis for 264f398. It will automatically update as commits are pushed.

Copy link
Contributor
@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 0f2aae8 in 3 minutes and 12 seconds

More details
  • Looked at 448 lines of code in 9 files
  • Skipped 2 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. py/sdk/sync_methods/documents.py:102
  • Draft comment:
    Use a context manager for file opening to ensure proper closure in case of exceptions. For example, use with open(file_path, 'rb') as file_instance:.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. py/sdk/sync_methods/documents.py:289
  • Draft comment:
    Verify that response.iter_bytes() exists in the client library. Typically, requests uses iter_content() for streaming binary data.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. py/sdk/asnyc_methods/documents.py:1
  • Draft comment:
    The directory/file name 'asnyc_methods' appears to be a typo; consider renaming it to 'async_methods' to improve clarity and maintain consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. js/sdk/__tests__/DocumentsIntegrationSuperUser.test.ts:396
  • Draft comment:
    The test name uses 'non-existant', which appears to be a typographical error. Consider replacing it with 'non-existent' to improve clarity and consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. js/sdk/src/v3/clients/documents.ts:187
  • Draft comment:
    The JSDoc comment for the 'retrieve' method is misleading. It mentions an optional list of document IDs, offset, and limit, and states that it returns a WrappedDocumentsResponse, while the method signature only accepts a single 'id' parameter and returns a WrappedDocumentResponse. Please update the documentation to accurately reflect the method's parameters and return type.
  • Reason this comment was not posted:
    Comment was on unchanged code.
6. py/sdk/asnyc_methods/documents.py:1
  • Draft comment:
    The directory name 'asnyc_methods' appears to be a misspelling of 'async_methods'. Please confirm if this is intentional or if it should be corrected.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. py/sdk/asnyc_methods/documents.py:47
  • Draft comment:
    In the 'create' method docstring, the argument is described as 'content' (line 48) whereas the actual parameter name is 'raw_text'. This inconsistency can be confusing. Please update the documentation to match the parameter name.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. py/sdk/asnyc_methods/documents.py:654
  • Draft comment:
    In the 'search' method docstring, the parameter description for 'search_settings' has an extra closing bracket: 'Optional[dict, SearchSettings]]'. Please remove the extra ']' to fix the typo.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
9. py/sdk/sync_methods/documents.py:658
  • Draft comment:
    Typo: In the search method docstring, the type for search_settings is written as 'Optional[dict, SearchSettings]]'. Consider removing the extra ']' to make it 'Optional[dict, SearchSettings]'.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_og5A6ov76Xk9l2uy


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@self.router.put(
"/documents/{id}/metadata",
dependencies=[Depends(self.rate_limit_dependency)],
summary="Append metadata to a document",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PUT endpoint’s summary still states "Append metadata to a document". Since it calls update_document_metadata with overwrite=True (replacing metadata), update the summary to reflect that this endpoint replaces metadata.

Suggested change
summary="Append metadata to a document",
summary="Replace metadata of a document",

Copy link
Contributor
@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on a8a1698 in 2 minutes and 8 seconds

More details
  • Looked at 90 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. py/core/main/api/v3/documents_router.py:690
  • Draft comment:
    The docstring for the PUT endpoint still says 'Appends metadata to a document' while the summary and behavior indicate a replacement. Update the docstring to clarify that metadata is replaced.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. py/core/main/api/v3/documents_router.py:575
  • Draft comment:
    Good addition of code samples for the PATCH endpoint to append metadata.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_OVqfFAjtlWkiqbEF


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor
@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on 264f398 in 41 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. py/core/main/api/v3/documents_router.py:700
  • Draft comment:
    Docstring updated to reflect metadata replacement behavior. Ensure that this aligns with the underlying service call (overwrite=True) as expected.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. py/core/main/api/v3/documents_router.py:691
  • Draft comment:
    The PUT endpoint docstring now states 'Replaces metadata' but the parameter descriptions (for 'id' and 'metadata') still mention 'append'. Please update these to accurately reflect the replacement behavior.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. py/core/main/api/v3/documents_router.py:691
  • Draft comment:
    In the put_metadata endpoint, the parameter description for the document ID still refers to 'append metadata' even though the endpoint is now intended to replace metadata. Please update the description to match the intended replace behavior (e.g., "The ID of the document for which metadata is to be replaced.").
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_0weSJHTO3KGj8Vmb


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@NolanTrem NolanTrem merged commit 79e9a33 into main Mar 18, 2025
23 of 29 checks passed
@NolanTrem NolanTrem deleted the Nolan/PatchAndPutMetadata branch March 18, 2025 23:26
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

Successfully merging this pull request may close these issues.

Ability to update metadata of an already ingested document
1 participant
0