yaph / chatgpt-export

A browser bookmarklet for exporting conversations with ChatGPT as markdown files.
https://geeksta.net/tools/chatgpt-to-markdown/
MIT License
61 stars 9 forks source link

Sweep: Only convert responses to markdown, not the prompts #3

Closed yaph closed 1 year ago

yaph commented 1 year ago
Checklist - [X] `gpt2md.js` > * Remove the lines of code that replace user profile images with 'PROMPT:' (lines 16-19). > • Modify the 'html' constant definition (line 27) to exclude elements with 'PROMPT:' from the 'body.getElementsByTagName('main').item(0).innerHTML'.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/yaph/chatgpt-export/pull/5.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/yaph/chatgpt-export/blob/13b02be4d73b7fd89f385c00221dc308c052955a/package.json#L1-L18 https://github.com/yaph/chatgpt-export/blob/13b02be4d73b7fd89f385c00221dc308c052955a/README.md#L1-L17 https://github.com/yaph/chatgpt-export/blob/13b02be4d73b7fd89f385c00221dc308c052955a/gpt2md.js#L1-L41 https://github.com/yaph/chatgpt-export/blob/13b02be4d73b7fd89f385c00221dc308c052955a/build.js#L1-L14 https://github.com/yaph/chatgpt-export/blob/13b02be4d73b7fd89f385c00221dc308c052955a/LICENSE#L1-L18

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
gpt2md.js Modify gpt2md.js with contents:
* Remove the lines of code that replace user profile images with 'PROMPT:' (lines 16-19).
• Modify the 'html' constant definition (line 27) to exclude elements with 'PROMPT:' from the 'body.getElementsByTagName('main').item(0).innerHTML'.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Exclude prompts from markdown conversion sweep/exclude-prompts

Description

This PR modifies the 'gpt2md.js' script to exclude prompts from the markdown conversion process. Currently, both prompts and responses are converted to markdown, but the requirement is to only convert the responses.

Summary of Changes

  • Removed the lines of code that replace user profile images with 'PROMPT:'
  • Modified the 'html' constant definition to exclude elements with 'PROMPT:' from the conversion to markdown

This change ensures that only the responses are converted to markdown, while the prompts are excluded.

Please review and merge this PR. Thank you!


Step 4: ⌨️ Coding

File Instructions Progress
gpt2md.js Modify gpt2md.js with contents:
* Remove the lines of code that replace user profile images with 'PROMPT:' (lines 16-19).
• Modify the 'html' constant definition (line 27) to exclude elements with 'PROMPT:' from the 'body.getElementsByTagName('main').item(0).innerHTML'.
✅ Commit b3f2174 I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/exclude-prompts.

Here is the 1st review

Thanks for your contribution. Here are a few suggestions to improve the code:

  • In gpt2md.js, the code responsible for replacing user profile images and ChatGPT profile images has been removed (lines 13-19). If these images were meant to be replaced for a specific reason, consider adding this functionality back.

  • There are three empty lines added (lines 20-22). While this doesn't affect the functionality, it's generally a good practice to avoid unnecessary empty lines for cleaner code.

  • The code that was responsible for getting the HTML content of the 'main' tag has been modified (line 23). Now it filters out any child elements that include 'PROMPT:' in their innerHTML. This could potentially remove important elements if they include 'PROMPT:' in their content. Please ensure this is the intended behavior.

Keep up the good work!

I finished incorporating these changes.


To recreate the pull request, or edit the issue title or description. Join Our Discord