mirror of
https://github.com/Hopiu/llm.git
synced 2026-05-04 20:04:44 +00:00
Fix newline issue in llm templates list, closes #42
This commit is contained in:
parent
b55f84a7c0
commit
19e6945dde
2 changed files with 5 additions and 1 deletions
|
|
@ -292,7 +292,7 @@ def templates_list():
|
|||
for file in path.glob("*.yaml"):
|
||||
name = file.stem
|
||||
template = load_template(name)
|
||||
pairs.append((name, template.prompt or ""))
|
||||
pairs.append((name, (template.prompt or "").replace("\n", " ")))
|
||||
max_name_len = max(len(p[0]) for p in pairs)
|
||||
fmt = "{name:<" + str(max_name_len) + "} : {prompt}"
|
||||
for name, prompt in sorted(pairs):
|
||||
|
|
|
|||
|
|
@ -36,10 +36,14 @@ def test_templates_list(templates_path):
|
|||
(templates_path / "three.yaml").write_text(
|
||||
"template three is very long " * 4, "utf-8"
|
||||
)
|
||||
(templates_path / "four.yaml").write_text(
|
||||
"'this one\n\nhas newlines in it'", "utf-8"
|
||||
)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["templates", "list"])
|
||||
assert result.exit_code == 0
|
||||
assert result.output == (
|
||||
"four : this one has newlines in it\n"
|
||||
"one : template one\n"
|
||||
"three : template three is very long template three is very long template thre...\n"
|
||||
"two : template two\n"
|
||||
|
|
|
|||
Loading…
Reference in a new issue