question_cmd: fixed msg specific argument creation

This commit is contained in:
2023-09-22 22:05:05 +02:00
parent 3c932aa88e
commit b83b396c7b
+8 -7
View File
@@ -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: