refactor: renamed (almost) all Chat/ChatDB functions

This commit is contained in:
2023-09-15 08:41:32 +02:00
parent f6109949c8
commit 98777295d6
5 changed files with 186 additions and 186 deletions
+6 -5
View File
@@ -51,7 +51,8 @@ def add_file_as_code(question_parts: list[str], file: str) -> None:
def create_message(chat: ChatDB, args: argparse.Namespace) -> Message:
"""
Creates (and writes) a new message from the given arguments.
Creates a new message from the given arguments and writes it
to the cache directory.
"""
question_parts = []
question_list = args.ask if args.ask is not None else []
@@ -72,7 +73,7 @@ def create_message(chat: ChatDB, args: argparse.Namespace) -> Message:
tags=args.output_tags, # FIXME
ai=args.AI,
model=args.model)
chat.add_to_cache([message])
chat.cache_add([message])
return message
@@ -101,8 +102,8 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
chat,
args.num_answers, # FIXME
args.output_tags) # FIXME
chat.update_messages([response.messages[0]])
chat.add_to_cache(response.messages[1:])
chat.msg_update([response.messages[0]])
chat.cache_add(response.messages[1:])
for idx, msg in enumerate(response.messages):
print(f"=== ANSWER {idx+1} ===")
print(msg.answer)
@@ -110,7 +111,7 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
print("===============")
print(response.tokens)
elif args.repeat is not None:
lmessage = chat.latest_message()
lmessage = chat.msg_latest()
assert lmessage
# TODO: repeat either the last question or the
# one(s) given in 'args.repeat' (overwrite