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.
- package/README.md +2 -0
- package/index.js +35 -22
- 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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|