refactor: renamed (almost) all Chat/ChatDB functions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -11,7 +11,7 @@ def tags_cmd(args: argparse.Namespace, config: Config) -> None:
|
||||
chat = ChatDB.from_dir(cache_path=Path('.'),
|
||||
db_path=Path(config.db))
|
||||
if args.list:
|
||||
tags_freq = chat.tags_frequency(args.prefix, args.contain)
|
||||
tags_freq = chat.msg_tags_frequency(args.prefix, args.contain)
|
||||
for tag, freq in tags_freq.items():
|
||||
print(f"- {tag}: {freq}")
|
||||
# TODO: add renaming
|
||||
|
||||
Reference in New Issue
Block a user