chatgpt-to-markdown 1.5.1 → 1.5.2
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 +1 -0
- package/index.js +33 -22
- package/package.json +1 -1
package/README.md
CHANGED
@@ -97,6 +97,7 @@ git push --follow-tags
|
|
97
97
|
|
98
98
|
## Release notes
|
99
99
|
|
100
|
+
- 1.5.2: 05 Aug 2024. Show tether_browsing_display summary
|
100
101
|
- 1.5.1: 22 Mar 2024. Handle unicode filenames
|
101
102
|
- 1.5.0: 28 Nov 2023. Handle `tether_browsing_display`, `tether_quote` and `system_error`
|
102
103
|
- 1.4.0: 29 Oct 2023. Handle multi-modal text from Dall-E
|
package/index.js
CHANGED
@@ -82,28 +82,39 @@ 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
|
+
part.content_type === "image_asset_pointer"
|
100
|
+
? `Image (${part.width}x${part.height}): ${part?.metadata?.dalle?.prompt ?? ""}\n\n`
|
101
|
+
: `${part.content_type}\n\n`,
|
102
|
+
)
|
103
|
+
.join("");
|
104
|
+
break;
|
105
|
+
case "tether_browsing_display":
|
106
|
+
body = "```\n" + (content.summary ? `${content.summary}\n` : "") + content.result + "\n```";
|
107
|
+
break;
|
108
|
+
case "tether_quote":
|
109
|
+
body = "```\n" + `${content.title} (${content.url})\n\n${content.text}` + "\n```";
|
110
|
+
break;
|
111
|
+
case "system_error":
|
112
|
+
body = `${content.name}\n\n${content.text}\n\n`;
|
113
|
+
break;
|
114
|
+
default:
|
115
|
+
body = content;
|
116
|
+
break;
|
117
|
+
}
|
107
118
|
// Ignore empty content
|
108
119
|
if (!body.trim()) return "";
|
109
120
|
// Indent user / tool messages. The sometimes contain code and whitespaces are relevant
|