(textContent, imageUrls = [], imageEnabled = false)
| 361 | |
| 362 | // 构建消息内容(包含图片) |
| 363 | export const buildMessageContent = (textContent, imageUrls = [], imageEnabled = false) => { |
| 364 | if (!textContent && (!imageUrls || imageUrls.length === 0)) { |
| 365 | return ''; |
| 366 | } |
| 367 | |
| 368 | const validImageUrls = imageUrls.filter(url => url && url.trim() !== ''); |
| 369 | |
| 370 | if (imageEnabled && validImageUrls.length > 0) { |
| 371 | return [ |
| 372 | { type: 'text', text: textContent || '' }, |
| 373 | ...validImageUrls.map(url => ({ |
| 374 | type: 'image_url', |
| 375 | image_url: { url: url.trim() } |
| 376 | })) |
| 377 | ]; |
| 378 | } |
| 379 | |
| 380 | return textContent || ''; |
| 381 | }; |
| 382 | |
| 383 | // 创建新消息 |
| 384 | export const createMessage = (role, content, options = {}) => ({ |
no outgoing calls
no test coverage detected