diff --git a/.changeset/four-impalas-pay.md b/.changeset/four-impalas-pay.md new file mode 100644 index 00000000..802f6e8b --- /dev/null +++ b/.changeset/four-impalas-pay.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Use is_empty filter for private files in LlamaCloud Index diff --git a/templates/components/vectordbs/python/llamacloud/query_filter.py b/templates/components/vectordbs/python/llamacloud/query_filter.py index b9a5ca40..fdaabd6a 100644 --- a/templates/components/vectordbs/python/llamacloud/query_filter.py +++ b/templates/components/vectordbs/python/llamacloud/query_filter.py @@ -5,11 +5,11 @@ def generate_filters(doc_ids): """ Generate public/private document filters based on the doc_ids and the vector store. """ - # Using "nin" filter to include the documents don't have the "private" key because they're uploaded in LlamaCloud UI + # Using "is_empty" filter to include the documents don't have the "private" key because they're uploaded in LlamaCloud UI public_doc_filter = MetadataFilter( key="private", - value=["true"], - operator="nin", # type: ignore + value=None, + operator="is_empty", # type: ignore ) selected_doc_filter = MetadataFilter( key="file_id", # Note: LLamaCloud uses "file_id" to reference private document ids as "doc_id" is a restricted field in LlamaCloud diff --git a/templates/components/vectordbs/typescript/llamacloud/queryFilter.ts b/templates/components/vectordbs/typescript/llamacloud/queryFilter.ts index 359e7f9f..c3ed6e3e 100644 --- a/templates/components/vectordbs/typescript/llamacloud/queryFilter.ts +++ b/templates/components/vectordbs/typescript/llamacloud/queryFilter.ts @@ -4,8 +4,8 @@ export function generateFilters(documentIds: string[]): MetadataFilters { // public documents don't have the "private" field or it's set to "false" const publicDocumentsFilter: MetadataFilter = { key: "private", - value: ["true"], - operator: "nin", + value: null, + operator: "is_empty", }; // if no documentIds are provided, only retrieve information from public documents