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

feat: Implement filtering by metadata #337

Merged
merged 3 commits into from
May 24, 2024
Merged

Conversation

whiterabbit1983
Copy link
Contributor

@whiterabbit1983 whiterabbit1983 commented May 18, 2024

🚀 This description was created by Ellipsis for commit 3a6bbd2

Summary:

Enhanced document retrieval functionality in the agents and users API by implementing metadata filtering.

Key points:

  • Implemented metadata filtering for document retrieval in the agents and users API
  • Added metadata_filter parameter to list_docs_snippets_by_owner_query in /agents-api/agents_api/models/docs/list_docs.py
  • Updated list_docs endpoints in /agents-api/agents_api/routers/agents/routers.py and /agents-api/agents_api/routers/users/routers.py to accept metadata_filter from requests
  • Implemented JSON parsing and error handling for metadata_filter in the routers

Generated with ❤️ by ellipsis.dev

Copy link
Contributor

sweep-ai bot commented May 18, 2024

Sweep: PR Review

agents-api/agents_api/models/docs/list_docs.py

The changes introduce a new metadata_filter parameter to the list_docs_snippets_by_owner_query function, allowing for metadata-based filtering of documents.

Sweep Found These Issues

  • The use of a mutable default argument metadata_filter: dict[str, Any] = {} can lead to unexpected behavior if the dictionary is modified.
  • metadata_filter: dict[str, Any] = {},

    View Diff

  • The constructed metadata_filter_str does not handle cases where the metadata_filter dictionary is empty, potentially leading to syntax errors in the query.
  • metadata_filter_str = ", ".join(
    [
    f"metadata->{json.dumps(k)} == {json.dumps(v)}"
    for k, v in metadata_filter.items()
    ]
    )

    View Diff


agents-api/agents_api/routers/agents/routers.py

The changes allow the metadata_filter parameter to be used for filtering documents and remove the check for the agent's existence before querying documents.

Sweep Found These Issues


agents-api/agents_api/routers/users/routers.py

The change removes the HTTP 501 Not Implemented error for metadata_filter and updates the function call to support metadata filtering.

Sweep Found These Issues

  • The removal of the HTTP 501 Not Implemented error handling for metadata_filter without ensuring that list_docs_snippets_by_owner_query can handle the filter correctly may lead to unexpected behavior or errors if the filter is not properly implemented.
  • detail="metadata_filter is not a valid JSON",
    )
    if not len(list(ensure_owner_exists_query("user", user_id).iterrows())):
    raise UserNotFoundError("", user_id)
    resp = list_docs_snippets_by_owner_query(
    owner_type="user",
    owner_id=user_id,
    metadata_filter=metadata_filter,

    View Diff


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 8a1053a in 1 minute and 6 seconds

More details
  • Looked at 93 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_rLMNgdq9vJ4GSMEa


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.

@creatorrr creatorrr enabled auto-merge (squash) May 21, 2024 02:00
@creatorrr
Copy link
Contributor

Lgtm

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 3a6bbd2 in 1 minute and 56 seconds

More details
  • Looked at 34 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_G5pE8zbnZhnNkZxz


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.

@whiterabbit1983 whiterabbit1983 merged commit b7d07a0 into dev May 24, 2024
6 checks passed
@whiterabbit1983 whiterabbit1983 deleted the feat/docs-metadata-filter branch May 24, 2024 03:59
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.

2 participants