( message: string | ContentBlock[], attachments?: ImageAttachment[], textAttachments?: TextAttachment[], fileAttachments?: FileAttachment[], )
| 10 | const MAX_HISTORY_SIZE = 1000 |
| 11 | |
| 12 | export function getUserMessage( |
| 13 | message: string | ContentBlock[], |
| 14 | attachments?: ImageAttachment[], |
| 15 | textAttachments?: TextAttachment[], |
| 16 | fileAttachments?: FileAttachment[], |
| 17 | ): ChatMessage { |
| 18 | return { |
| 19 | id: `user-${Date.now()}`, |
| 20 | variant: 'user', |
| 21 | ...(typeof message === 'string' |
| 22 | ? { |
| 23 | content: message, |
| 24 | } |
| 25 | : { |
| 26 | content: '', |
| 27 | blocks: message, |
| 28 | }), |
| 29 | timestamp: formatTimestamp(), |
| 30 | ...(attachments && attachments.length > 0 ? { attachments } : {}), |
| 31 | ...(textAttachments && textAttachments.length > 0 ? { textAttachments } : {}), |
| 32 | ...(fileAttachments && fileAttachments.length > 0 ? { fileAttachments } : {}), |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export function getSystemMessage( |
| 37 | content: string | ContentBlock[], |
no test coverage detected