julep
julep copied to clipboard
feat: Implement filtering by metadata
| :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_filterparameter tolist_docs_snippets_by_owner_queryin/agents-api/agents_api/models/docs/list_docs.py. - Updated
list_docsendpoints in/agents-api/agents_api/routers/agents/routers.pyand/agents-api/agents_api/routers/users/routers.pyto acceptmetadata_filterfrom requests. - Implemented JSON parsing and error handling for
metadata_filterin the routers.
Generated with :heart: by ellipsis.dev
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. - The constructed
metadata_filter_strdoes not handle cases where themetadata_filterdictionary 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#L39 View Diff
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_filterwithout ensuring thatlist_docs_snippets_by_owner_querycan 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