Compare commits

...

1 Commits

View File

@ -105,11 +105,21 @@ def make_request(ai: AI, chat: ChatDB, message: Message, args: argparse.Namespac
print(response.tokens)
def repeat_messages(messages: list[Message], ai: AI, chat: ChatDB, args: argparse.Namespace) -> None:
def repeat_messages(messages: list[Message], chat: ChatDB, args: argparse.Namespace, config: Config) -> None:
"""
Repeat the given messages using the given arguments.
"""
ai: AI
for msg in messages:
ai_args = args
# if AI or model have not been specified, use those from the original message
if args.AI is None or args.model is None:
ai_args = args.copy()
if args.AI is None and msg.ai is not None:
ai_args.AI = msg.ai
if args.model is None and msg.model is not None:
ai_args.model = msg.model
ai = create_ai(ai_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!
@ -139,11 +149,10 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
message = create_message(chat, args)
if args.create:
return
# create the correct AI instance
ai: AI = create_ai(args, config)
# === ASK ===
if args.ask:
ai: AI = create_ai(args, config)
make_request(ai, chat, message, args)
# === REPEAT ===
elif args.repeat is not None:
@ -158,7 +167,7 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
# repeat given message(s)
else:
repeat_msgs = chat.msg_find(args.repeat, loc='disk')
repeat_messages(repeat_msgs, ai, chat, args)
repeat_messages(repeat_msgs, chat, args, config)
# === PROCESS ===
elif args.process is not None:
# TODO: process either all questions without an