From 77a42367b52fcba9a17c6ca451ffe8487217845d Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Sat, 9 Sep 2023 21:18:29 +0200 Subject: [PATCH] Fix the filter for `question -a` --- chatmastermind/commands/question.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chatmastermind/commands/question.py b/chatmastermind/commands/question.py index 5f72c7e..110eaf3 100644 --- a/chatmastermind/commands/question.py +++ b/chatmastermind/commands/question.py @@ -3,7 +3,7 @@ from pathlib import Path from itertools import zip_longest from ..configuration import Config from ..chat import ChatDB -from ..message import Message, Question, source_code +from ..message import Message, MessageFilter, Question, source_code from ..ai_factory import create_ai from ..ai import AI, AIResponse @@ -52,8 +52,12 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None: """ Handler for the 'question' command. """ + mfilter = MessageFilter(tags_or=args.or_tags, + tags_and=args.and_tags, + tags_not=args.exclude_tags) chat = ChatDB.from_dir(cache_path=Path('.'), - db_path=Path(config.db)) + db_path=Path(config.db), + mfilter=mfilter) # if it's a new question, create and store it immediately if args.ask or args.create: message = create_message(chat, args) @@ -76,14 +80,14 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None: if response.tokens: print("===============") print(response.tokens) - elif args.repeat: + elif args.repeat is not None: lmessage = chat.latest_message() assert lmessage # TODO: repeat either the last question or the # one(s) given in 'args.repeat' (overwrite # existing ones if 'args.overwrite' is True) pass - elif args.process: + elif args.process is not None: # TODO: process either all questions without an # answer or the one(s) given in 'args.process' pass