julep icon indicating copy to clipboard operation
julep copied to clipboard

feat: Implement filtering by metadata

Open whiterabbit1983 opened this issue 1 year ago • 2 comments
trafficstars

:rocket: This description was created by Ellipsis for commit 8a1053aa7e41c7fedf5a448679bd81982a8c21f2

Summary:

Implemented metadata filtering for document retrieval in the agents and users API, enhancing the functionality of document queries based on metadata criteria.

Key points:

  • 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 :heart: by ellipsis.dev

whiterabbit1983 avatar May 18 '24 09:05 whiterabbit1983

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.
  • https://github.com/julep-ai/julep/blob/8a1053aa7e41c7fedf5a448679bd81982a8c21f2/agents-api%2Fagents_api%2Fmodels%2Fdocs%2Flist_docs.py#L39 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.
  • https://github.com/julep-ai/julep/blob/8a1053aa7e41c7fedf5a448679bd81982a8c21f2/agents-api%2Fagents_api%2Fmodels%2Fdocs%2Flist_docs.py#L43-L48 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

  • The removal of the check to ensure the agent exists before querying for documents could lead to querying with an invalid agent_id, potentially causing unexpected errors or behavior.
  • https://github.com/julep-ai/julep/blob/8a1053aa7e41c7fedf5a448679bd81982a8c21f2/agents-api%2Fagents_api%2Frouters%2Fagents%2Frouters.py#L9 View Diff


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.
  • https://github.com/julep-ai/julep/blob/8a1053aa7e41c7fedf5a448679bd81982a8c21f2/agents-api%2Fagents_api%2Frouters%2Fusers%2Frouters.py#L288-L297 View Diff


Lgtm

creatorrr avatar May 21 '24 02:05 creatorrr