From b83b396c7b853f566e5f393ec1ae0b37adde465d Mon Sep 17 00:00:00 2001 From: juk0de Date: Fri, 22 Sep 2023 22:05:05 +0200 Subject: [PATCH] question_cmd: fixed msg specific argument creation --- chatmastermind/commands/question.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/chatmastermind/commands/question.py b/chatmastermind/commands/question.py index 4c8b81c..da77e1a 100644 --- a/chatmastermind/commands/question.py +++ b/chatmastermind/commands/question.py @@ -106,7 +106,7 @@ def make_request(ai: AI, chat: ChatDB, message: Message, args: argparse.Namespac print(response.tokens) -def make_msg_args(msg: Message, args: argparse.Namespace) -> argparse.Namespace: +def create_msg_args(msg: Message, args: argparse.Namespace) -> argparse.Namespace: """ Takes an existing message and CLI arguments, and returns modified args based on the members of the given message. Used e.g. when repeating messages, where @@ -135,19 +135,20 @@ def repeat_messages(messages: list[Message], chat: ChatDB, args: argparse.Namesp """ ai: AI for msg in messages: - ai = create_ai(make_msg_args(msg, args), config) + msg_args = create_msg_args(msg, args) + ai = create_ai(msg_args, config) print(f"--------- Repeating message '{msg.msg_id()}': ---------") # overwrite the latest message if requested or empty # -> but not if it's in the DB! - if ((msg.answer is None or args.overwrite is True) + if ((msg.answer is None or msg_args.overwrite is True) and (not chat.msg_in_db(msg))): # noqa: W503 msg.clear_answer() - make_request(ai, chat, msg, args) + make_request(ai, chat, msg, msg_args) # otherwise create a new one else: - args.ask = [msg.question] - message = create_message(chat, args) - make_request(ai, chat, message, args) + msg_args.ask = [msg.question] + message = create_message(chat, msg_args) + make_request(ai, chat, message, msg_args) def invert_input_tag_args(args: argparse.Namespace) -> None: