fixed 'tag' and 'hist' commands
This commit is contained in:
parent
f90e7bcd47
commit
5a435c5f8f
@ -67,7 +67,7 @@ def tag_cmd(args: argparse.Namespace, config: dict) -> None:
|
||||
Handler for the 'tag' command.
|
||||
"""
|
||||
if args.list:
|
||||
print_tags_frequency(get_tags(config, None), args.dump)
|
||||
print_tags_frequency(get_tags(config, None))
|
||||
|
||||
|
||||
def model_cmd(args: argparse.Namespace, config: dict) -> None:
|
||||
@ -115,14 +115,14 @@ def print_cmd(args: argparse.Namespace, config: dict) -> None:
|
||||
"""
|
||||
Handler for the 'print' command.
|
||||
"""
|
||||
fname = pathlib.Path(args.print)
|
||||
fname = pathlib.Path(args.file)
|
||||
if fname.suffix == '.yaml':
|
||||
with open(args.print, 'r') as f:
|
||||
with open(args.file, 'r') as f:
|
||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
||||
elif fname.suffix == '.txt':
|
||||
data = read_file(fname)
|
||||
else:
|
||||
print(f"Unknown file type: {args.print}")
|
||||
print(f"Unknown file type: {args.file}")
|
||||
sys.exit(1)
|
||||
if args.only_source_code:
|
||||
display_source_code(data['answer'])
|
||||
|
||||
@ -78,9 +78,6 @@ def print_chat_hist(chat, dump=False, source_code=False) -> None:
|
||||
print(f"{message['role'].upper()}: {message['content']}")
|
||||
|
||||
|
||||
def print_tags_frequency(tags: List[str], dump=False) -> None:
|
||||
if dump:
|
||||
pp(tags)
|
||||
return
|
||||
def print_tags_frequency(tags: List[str]) -> None:
|
||||
for tag in sorted(set(tags)):
|
||||
print(f"- {tag}: {tags.count(tag)}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user