Skip to content

Commit

Permalink
fix: set <title> in export and make sure /export command doesn't ge…
Browse files Browse the repository at this point in the history
…t saved to log
  • Loading branch information
ErikBjare committed Oct 30, 2024
1 parent 32db19d commit 2a5576a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions gptme/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def handle_cmd(
)
case "export":
manager.undo(1, quiet=True)
manager.write()
# Get output path from args or use default
output_path = (
Path(args[0]) if args else Path(f"{manager.logfile.parent.name}.html")
Expand Down
10 changes: 9 additions & 1 deletion gptme/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def export_chat_to_html(name: str, chat_data: Log, output_path: Path) -> None:

chat_data_json = json.dumps(chat_data_list, indent=2)

# Modify the template
# Embed script and conversation
standalone_html = replace_or_fail(
html_template,
'<script type="module" src="/static/main.js"></script>',
Expand All @@ -59,6 +59,14 @@ def export_chat_to_html(name: str, chat_data: Log, output_path: Path) -> None:
"main.js script tag",
)

# Set the title
standalone_html = replace_or_fail(
standalone_html,
"<title>gptme</title>",
f"<title>{name} - gptme</title>",
"title",
)

# Remove external resources
standalone_html = replace_or_fail(
standalone_html,
Expand Down

0 comments on commit 2a5576a

Please sign in to comment.