File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -799,8 +799,30 @@ export class Cline {
799799 }
800800 }
801801
802- // Convert to Anthropic.MessageParam by spreading only the API-required properties
803- const cleanConversationHistory = this . apiConversationHistory . map ( ( { role, content } ) => ( { role, content } ) )
802+ // Clean conversation history by:
803+ // 1. Converting to Anthropic.MessageParam by spreading only the API-required properties
804+ // 2. Converting image blocks to text descriptions if model doesn't support images
805+ const cleanConversationHistory = this . apiConversationHistory . map ( ( { role, content } ) => {
806+ // Handle array content (could contain image blocks)
807+ if ( Array . isArray ( content ) ) {
808+ if ( ! this . api . getModel ( ) . info . supportsImages ) {
809+ // Convert image blocks to text descriptions
810+ content = content . map ( block => {
811+ if ( block . type === 'image' ) {
812+ // Convert image blocks to text descriptions
813+ // Note: We can't access the actual image content/url due to API limitations,
814+ // but we can indicate that an image was present in the conversation
815+ return {
816+ type : 'text' ,
817+ text : '[Referenced image in conversation]'
818+ } ;
819+ }
820+ return block ;
821+ } ) ;
822+ }
823+ }
824+ return { role, content }
825+ } )
804826 const stream = this . api . createMessage ( systemPrompt , cleanConversationHistory )
805827 const iterator = stream [ Symbol . asyncIterator ] ( )
806828
You can’t perform that action at this time.
0 commit comments