Skip to content

Commit

Permalink
Use is_empty filter (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
leehuwuj authored Aug 29, 2024
1 parent 5cd12fa commit bedde2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-impalas-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Use is_empty filter for private files in LlamaCloud Index
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bedde2b

Please sign in to comment.