question_cmd: fixed AI and model arguments when repeating messages
This commit is contained in:
parent
ba16e325d1
commit
0ee5645853
@ -105,11 +105,21 @@ def make_request(ai: AI, chat: ChatDB, message: Message, args: argparse.Namespac
|
|||||||
print(response.tokens)
|
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.
|
Repeat the given messages using the given arguments.
|
||||||
"""
|
"""
|
||||||
|
ai: AI
|
||||||
for msg in messages:
|
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()}': ---------")
|
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!
|
||||||
@ -139,11 +149,10 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
|
|||||||
message = create_message(chat, args)
|
message = create_message(chat, args)
|
||||||
if args.create:
|
if args.create:
|
||||||
return
|
return
|
||||||
# create the correct AI instance
|
|
||||||
ai: AI = create_ai(args, config)
|
|
||||||
|
|
||||||
# === ASK ===
|
# === ASK ===
|
||||||
if args.ask:
|
if args.ask:
|
||||||
|
ai: AI = create_ai(args, config)
|
||||||
make_request(ai, chat, message, args)
|
make_request(ai, chat, message, args)
|
||||||
# === REPEAT ===
|
# === REPEAT ===
|
||||||
elif args.repeat is not None:
|
elif args.repeat is not None:
|
||||||
@ -158,7 +167,7 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
|
|||||||
# repeat given message(s)
|
# repeat given message(s)
|
||||||
else:
|
else:
|
||||||
repeat_msgs = chat.msg_find(args.repeat, loc='disk')
|
repeat_msgs = chat.msg_find(args.repeat, loc='disk')
|
||||||
repeat_messages(repeat_msgs, ai, chat, args)
|
repeat_messages(repeat_msgs, chat, args, config)
|
||||||
# === PROCESS ===
|
# === PROCESS ===
|
||||||
elif args.process is not None:
|
elif args.process is not None:
|
||||||
# TODO: process either all questions without an
|
# TODO: process either all questions without an
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user