From 18feb50d7fb46fa8bb4e0b66ab48782b1ff59b8c Mon Sep 17 00:00:00 2001 From: juk0de Date: Sun, 10 Sep 2023 07:54:17 +0200 Subject: [PATCH] question_cmd: added message filtering by tags --- 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 fdabd62..f439447 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) @@ -77,14 +81,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