Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added /export comment to export self-contained HTML file built from webui #235

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Oct 30, 2024

Replaces #105

Closes #32

Re-uses the web UI so that we maximize code reuse

In the future, we should also embed images/media from the conversation. Possibly by base64 encoding (downscaled?) versions into messages.


Important

Adds /export command to export chat logs as standalone HTML files, with updates to handle embedded data in JavaScript.

  • Feature:
    • Adds /export command in commands.py to export chat logs as standalone HTML files using export_chat_to_html().
    • New export.py module for exporting chat logs to HTML, embedding chat data and styles directly into the HTML.
  • JavaScript:
    • Updates main.js to check for window.CHAT_DATA and handle embedded chat data for exported HTML files.
    • Modifies mdToHtml() in main.js to unescape HTML entities before processing markdown.

This description was created by Ellipsis for cb9bea6. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to cb9bea6 in 40 seconds

More details
  • Looked at 223 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. gptme/export.py:8
  • Draft comment:
    The replace_or_fail function is a good practice to ensure that the HTML structure is as expected. However, ensure that the error message provides enough context for debugging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The replace_or_fail function is used to ensure that specific HTML elements are replaced in the template. However, if the template changes and the expected elements are not found, this will raise an error. This is a good practice to ensure that the HTML structure is as expected.
2. gptme/commands.py:152
  • Draft comment:
    Ensure that manager.undo(1, quiet=True) is necessary for the /export command. It might not be needed if the command itself doesn't alter the log in a way that needs undoing.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The handle_cmd function uses manager.undo(1, quiet=True) before executing commands. This is likely intended to undo the command itself from the log, but it might not be necessary for all commands.

Workflow ID: wflow_lhAvWB9cr5T3qCU2


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -244,6 +258,12 @@ new Vue({
},
mdToHtml(md) {
// TODO: Use DOMPurify.sanitize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using DOMPurify.sanitize to sanitize HTML content before rendering to prevent XSS vulnerabilities.

Suggested change
// TODO: Use DOMPurify.sanitize
return DOMPurify.sanitize(html);

gptme/export.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 21.42857% with 33 lines in your changes missing coverage. Please review.

Project coverage is 73.89%. Comparing base (16f8254) to head (cb9bea6).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/export.py 17.14% 29 Missing ⚠️
gptme/commands.py 42.85% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #235      +/-   ##
==========================================
- Coverage   74.54%   73.89%   -0.66%     
==========================================
  Files          58       59       +1     
  Lines        3677     3719      +42     
==========================================
+ Hits         2741     2748       +7     
- Misses        936      971      +35     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 72.86% <21.42%> (-0.59%) ⬇️
openai/gpt-4o-mini 72.73% <21.42%> (-0.59%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ErikBjare ErikBjare merged commit 0ca914f into master Oct 30, 2024
7 checks passed
@ErikBjare ErikBjare deleted the dev/html-export-reuse-frontend branch October 30, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to share conversations
2 participants