fix: align ContentBlock media_type with SDK 0.2.87 literal union type
This commit is contained in:
@@ -73,7 +73,7 @@ interface SessionsIndex {
|
|||||||
|
|
||||||
type ContentBlock =
|
type ContentBlock =
|
||||||
| { type: 'text'; text: string }
|
| { type: 'text'; text: string }
|
||||||
| { type: 'image'; source: { type: 'base64'; media_type: string; data: string } };
|
| { type: 'image'; source: { type: 'base64'; media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'; data: string } };
|
||||||
|
|
||||||
interface SDKUserMessage {
|
interface SDKUserMessage {
|
||||||
type: 'user';
|
type: 'user';
|
||||||
@@ -140,7 +140,7 @@ function buildMultimodalContent(text: string): string | ContentBlock[] {
|
|||||||
}
|
}
|
||||||
const data = fs.readFileSync(imgPath).toString('base64');
|
const data = fs.readFileSync(imgPath).toString('base64');
|
||||||
const ext = path.extname(imgPath).toLowerCase();
|
const ext = path.extname(imgPath).toLowerCase();
|
||||||
const mediaType = MIME_TYPES[ext] || 'image/png';
|
const mediaType = (MIME_TYPES[ext] || 'image/png') as 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
||||||
blocks.push({ type: 'image', source: { type: 'base64', media_type: mediaType, data } });
|
blocks.push({ type: 'image', source: { type: 'base64', media_type: mediaType, data } });
|
||||||
log(`Added image block: ${imgPath} (${mediaType})`);
|
log(`Added image block: ${imgPath} (${mediaType})`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user