Skip to content

Commit

Permalink
Improved log Markdown, closes #783
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 27, 2025
1 parent f5c2cfb commit 3d4871f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions llm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,14 +1125,14 @@ def logs_list(
# In conversation log mode only show it for the first one
if conversation_id:
should_show_conversation = False
click.echo("## Prompt:\n\n{}".format(row["prompt"]))
click.echo("## Prompt\n\n{}".format(row["prompt"] or "- none -"))
if row["system"] != current_system:
if row["system"] is not None:
click.echo("\n## System:\n\n{}".format(row["system"]))
click.echo("\n## System\n\n{}".format(row["system"]))
current_system = row["system"]
if row["schema_json"]:
click.echo(
"\n## Schema:\n\n```json\n{}\n```".format(
"\n## Schema\n\n```json\n{}\n```".format(
json.dumps(row["schema_json"], indent=2)
)
)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ def logs_list(
response = "```json\n{}\n```".format(json.dumps(parsed, indent=2))
except ValueError:
pass
click.echo("\n## Response:\n\n{}\n".format(response))
click.echo("\n## Response\n\n{}\n".format(response))
if usage:
token_usage = token_usage_string(
row["input_tokens"],
Expand Down
14 changes: 7 additions & 7 deletions tests/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,29 @@ def test_logs_text(log_path, usage):
(
"# YYYY-MM-DDTHH:MM:SS conversation: abc123\n\n"
"Model: **davinci**\n\n"
"## Prompt:\n\n"
"## Prompt\n\n"
"prompt\n\n"
"## System:\n\n"
"## System\n\n"
"system\n\n"
"## Response:\n\n"
"## Response\n\n"
'response\n```python\nprint("hello word")\n```\n\n'
)
+ ("## Token usage:\n\n2 input, 5 output\n\n" if usage else "")
+ (
"# YYYY-MM-DDTHH:MM:SS conversation: abc123\n\n"
"Model: **davinci**\n\n"
"## Prompt:\n\n"
"## Prompt\n\n"
"prompt\n\n"
"## Response:\n\n"
"## Response\n\n"
'response\n```python\nprint("hello word")\n```\n\n'
)
+ ("## Token usage:\n\n2 input, 5 output\n\n" if usage else "")
+ (
"# YYYY-MM-DDTHH:MM:SS conversation: abc123\n\n"
"Model: **davinci**\n\n"
"## Prompt:\n\n"
"## Prompt\n\n"
"prompt\n\n"
"## Response:\n\n"
"## Response\n\n"
'response\n```python\nprint("hello word")\n```\n\n'
)
+ ("## Token usage:\n\n2 input, 5 output\n\n" if usage else "")
Expand Down

0 comments on commit 3d4871f

Please sign in to comment.