mirror of
https://github.com/pionxzh/chatgpt-exporter.git
synced 2026-07-23 09:00:51 -05:00
fix: avoid hang when exporting voice chat (#262)
* work on #261: avoid hang See #261 for the situation. This commit avoids errors caused by multimodal parts we don't understand. It does NOT add any functionality that understands advanced voice mode parts. Perhaps that should be broken out of #261 into a separate enhancement request. * address es-lint complaint eslint error: error '&&' should be placed at the beginning of the line solution: move a trailing `&&` to the front of the next line
This commit is contained in:
10
src/api.ts
10
src/api.ts
@@ -315,15 +315,19 @@ async function fetchImageFromPointer(uri: string) {
|
||||
}
|
||||
|
||||
/** replaces `file-service://` pointers with data uris containing the image */
|
||||
/** avoid errors in parsing multimodal parts we don't understand */
|
||||
async function replaceImageAssets(conversation: ApiConversation): Promise<void> {
|
||||
const isMultiModalInputImage = (part: string | MultiModalInputImage): part is MultiModalInputImage => {
|
||||
return typeof part !== 'string' && part.asset_pointer.startsWith('file-service://')
|
||||
const isMultiModalInputImage = (part: any): part is MultiModalInputImage => {
|
||||
return typeof part === 'object' && part !== null && 'asset_pointer' in part
|
||||
&& typeof part.asset_pointer === 'string' && part.asset_pointer.startsWith('file-service://')
|
||||
}
|
||||
|
||||
const imageAssets = Object.values(conversation.mapping).flatMap((node) => {
|
||||
if (!node.message) return []
|
||||
if (node.message.content.content_type !== 'multimodal_text') return []
|
||||
|
||||
return node.message.content.parts.filter(isMultiModalInputImage)
|
||||
return (Array.isArray(node.message.content.parts) ? node.message.content.parts : [])
|
||||
.filter(isMultiModalInputImage)
|
||||
})
|
||||
|
||||
const executionOutputs = Object.values(conversation.mapping).flatMap((node) => {
|
||||
|
||||
Reference in New Issue
Block a user