mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 04:14:30 +00:00
fix(agent): resolve S3 MIME type detection and prompt parameter in image analysis
This commit is contained in:
@@ -106,11 +106,14 @@ export function createAnalyzeImageTool(
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
const { buffer, contentType } = await s3Service.getObject(bucket, keyToUse)
|
||||
|
||||
const mimeType =
|
||||
contentType && contentType !== 'application/octet-stream' ? contentType : 'image/webp'
|
||||
|
||||
const content: ImageContent[] = [
|
||||
{
|
||||
type: 'image',
|
||||
data: buffer.toString('base64'),
|
||||
mimeType: contentType || 'image/webp',
|
||||
mimeType,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -121,10 +121,12 @@ export function createReadPdfPagesTool(
|
||||
|
||||
for (const pageItem of pages) {
|
||||
const { buffer, contentType } = await s3Service.getObject(bucket, pageItem.key)
|
||||
const mimeType =
|
||||
contentType && contentType !== 'application/octet-stream' ? contentType : 'image/webp'
|
||||
content.push({
|
||||
type: 'image',
|
||||
data: buffer.toString('base64'),
|
||||
mimeType: contentType || 'image/webp',
|
||||
mimeType,
|
||||
})
|
||||
sourceKeys.push(pageItem.key)
|
||||
}
|
||||
|
||||
@@ -102,10 +102,12 @@ export function createScreenshotTool(
|
||||
|
||||
for (const shot of screenshots) {
|
||||
const { buffer, contentType } = await s3Service.getObject(bucket, shot.key)
|
||||
const mimeType =
|
||||
contentType && contentType !== 'application/octet-stream' ? contentType : 'image/webp'
|
||||
content.push({
|
||||
type: 'image',
|
||||
data: buffer.toString('base64'),
|
||||
mimeType: contentType || 'image/webp',
|
||||
mimeType,
|
||||
})
|
||||
sourceKeys.push(shot.key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user