chatgpt-to-markdown 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +35 -22
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -97,6 +97,8 @@ git push --follow-tags
97
97
 
98
98
  ## Release notes
99
99
 
100
+ - 1.5.3: 05 Aug 2024. Show text from multimodal prompts
101
+ - 1.5.2: 05 Aug 2024. Show tether_browsing_display summary
100
102
  - 1.5.1: 22 Mar 2024. Handle unicode filenames
101
103
  - 1.5.0: 28 Nov 2023. Handle `tether_browsing_display`, `tether_quote` and `system_error`
102
104
  - 1.4.0: 29 Oct 2023. Handle multi-modal text from Dall-E
package/index.js CHANGED
@@ -82,28 +82,41 @@ async function chatgptToMarkdown(json, sourceDir, { dateFormat } = { dateFormat:
82
82
  let content = node.message?.content;
83
83
  if (!content) return "";
84
84
  // Format the body based on the content type
85
- let body =
86
- content.content_type == "text"
87
- ? content.parts.join("\n")
88
- : content.content_type == "code"
89
- ? "```" + content.language.replace("unknown", "") + "\n" + content.text + "\n```"
90
- : content.content_type == "execution_output"
91
- ? "```\n" + content.text + "\n```"
92
- : content.content_type == "multimodal_text"
93
- ? content.parts
94
- .map((part) =>
95
- part.content_type === "image_asset_pointer"
96
- ? `Image (${part.width}x${part.height}): ${part?.metadata?.dalle?.prompt}\n\n`
97
- : `${part.content_type}\n\n`,
98
- )
99
- .join("")
100
- : content.content_type == "tether_browsing_display"
101
- ? "```\n" + content.result + "\n```"
102
- : content.content_type == "tether_quote"
103
- ? "```\n" + `${content.title} (${content.url})\n\n${content.text}` + "\n```"
104
- : content.content_type == "system_error"
105
- ? `${content.name}\n\n${content.text}\n\n`
106
- : content;
85
+ let body;
86
+ switch (content.content_type) {
87
+ case "text":
88
+ body = content.parts.join("\n");
89
+ break;
90
+ case "code":
91
+ body = "```" + content.language.replace("unknown", "") + "\n" + content.text + "\n```";
92
+ break;
93
+ case "execution_output":
94
+ body = "```\n" + content.text + "\n```";
95
+ break;
96
+ case "multimodal_text":
97
+ body = content.parts
98
+ .map((part) =>
99
+ typeof part == "string"
100
+ ? `${part}\n\n`
101
+ : part.content_type === "image_asset_pointer"
102
+ ? `Image (${part.width}x${part.height}): ${part?.metadata?.dalle?.prompt ?? ""}\n\n`
103
+ : `${part.content_type}\n\n`,
104
+ )
105
+ .join("");
106
+ break;
107
+ case "tether_browsing_display":
108
+ body = "```\n" + (content.summary ? `${content.summary}\n` : "") + content.result + "\n```";
109
+ break;
110
+ case "tether_quote":
111
+ body = "```\n" + `${content.title} (${content.url})\n\n${content.text}` + "\n```";
112
+ break;
113
+ case "system_error":
114
+ body = `${content.name}\n\n${content.text}\n\n`;
115
+ break;
116
+ default:
117
+ body = content;
118
+ break;
119
+ }
107
120
  // Ignore empty content
108
121
  if (!body.trim()) return "";
109
122
  // Indent user / tool messages. The sometimes contain code and whitespaces are relevant
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatgpt-to-markdown",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Convert ChatGPT exported conversations.json to Markdown",
5
5
  "main": "index.js",
6
6
  "type": "module",