added option '-a' to match all tags when selecting chat history entries

This commit is contained in:
2023-08-05 11:41:36 +02:00
parent 5d55bed0ec
commit 8e4a02b932
3 changed files with 11 additions and 4 deletions
+6 -2
View File
@@ -64,6 +64,7 @@ def create_chat(question: Optional[str],
tags: Optional[List[str]],
extags: Optional[List[str]],
config: Dict[str, Any],
match_all_tags: bool = False,
with_tags: bool = False,
with_file: bool = False
) -> List[Dict[str, str]]:
@@ -78,8 +79,11 @@ def create_chat(question: Optional[str],
else:
continue
data_tags = set(data.get('tags', []))
tags_match = \
not tags or data_tags.intersection(tags)
tags_match: bool
if match_all_tags:
tags_match = not tags or set(tags).issubset(data_tags)
else:
tags_match = not tags or bool(data_tags.intersection(tags))
extags_do_not_match = \
not extags or not data_tags.intersection(extags)
if tags_match and extags_do_not_match: