Skip to content

Commit

Permalink
fix: 确保在 Buffer 未定义时处理图像数据以避免潜在错误
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Dec 23, 2024
1 parent e1e1e77 commit 9ff6f48
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions packages/lib/core/src/agent/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export function extractImageContent(imageData: DataItemContent | URL): ImageReal
return { base64: imageData };
}
}
if (imageData instanceof Uint8Array) {
return { base64: Buffer.from(imageData).toString('base64') };
}
if (Buffer.isBuffer(imageData)) {
return { base64: Buffer.from(imageData).toString('base64') };
if (typeof Buffer !== 'undefined') {
if (imageData instanceof Uint8Array) {
return { base64: Buffer.from(imageData).toString('base64') };
}
if (Buffer.isBuffer(imageData)) {
return { base64: Buffer.from(imageData).toString('base64') };
}
}
return {};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/core/src/config/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const BUILD_TIMESTAMP = 1734938667;
export const BUILD_VERSION = 'ba81a00';
export const BUILD_TIMESTAMP = 1734941281;
export const BUILD_VERSION = 'e1e1e77';

0 comments on commit 9ff6f48

Please sign in to comment.