question_cmd: fixed msg specific argument creation
This commit is contained in:
@@ -106,7 +106,7 @@ def make_request(ai: AI, chat: ChatDB, message: Message, args: argparse.Namespac
|
|||||||
print(response.tokens)
|
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
|
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
|
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
|
ai: AI
|
||||||
for msg in messages:
|
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()}': ---------")
|
print(f"--------- Repeating message '{msg.msg_id()}': ---------")
|
||||||
# overwrite the latest message if requested or empty
|
# overwrite the latest message if requested or empty
|
||||||
# -> but not if it's in the DB!
|
# -> 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
|
and (not chat.msg_in_db(msg))): # noqa: W503
|
||||||
msg.clear_answer()
|
msg.clear_answer()
|
||||||
make_request(ai, chat, msg, args)
|
make_request(ai, chat, msg, msg_args)
|
||||||
# otherwise create a new one
|
# otherwise create a new one
|
||||||
else:
|
else:
|
||||||
args.ask = [msg.question]
|
msg_args.ask = [msg.question]
|
||||||
message = create_message(chat, args)
|
message = create_message(chat, msg_args)
|
||||||
make_request(ai, chat, message, args)
|
make_request(ai, chat, message, msg_args)
|
||||||
|
|
||||||
|
|
||||||
def invert_input_tag_args(args: argparse.Namespace) -> None:
|
def invert_input_tag_args(args: argparse.Namespace) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user