Skip to content

Commit

Permalink
Add value filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
duckduckgrayduck committed Apr 17, 2024
1 parent b6d617e commit bd13f3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ properties:
filter_key:
title: "Filter Key"
type: string
description: "If you need to narrow down the document set further, provide a key name you want to filter by"
description: "If you need to narrow down the document set further, provide a key name you want to filter by. If value isn't also specified, then it will filter on any documents that have that key."
filter_value:
title: "Filter Value"
type: string
description: "If you want to provide a specific key/value pair to narrow on, provide the value here and the key in filter key. "
prompt:
title: "Prompt"
type: string
Expand Down
12 changes: 9 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ def main(self):
prompt = self.data.get("prompt")
limiter = self.data.get("limiter")
filter_key = self.data.get("filter_key")
filter_value = self.data.get("filter_value")

if filter_key is not None:
documents = self.client.documents.search(
f"+project:{proj_id} -data_{key_name}:* data_{filter_key}:*"
)
if filter_value is not None:
documents = self.client.documents.search(
f"+project:{proj_id} -data_{key_name}:* data_{filter_key}:{filter_value}"
)
else:
documents = self.client.documents.search(
f"+project:{proj_id} -data_{key_name}:* data_{filter_key}:*"
)
else:
documents = self.client.documents.search(
f"+project:{proj_id} -data_{key_name}:*"
Expand Down

0 comments on commit bd13f3f

Please sign in to comment.