File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/default-providers/MistralAI Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,23 @@ export class CodestralCompleter extends BaseCompleter {
36
36
false
37
37
) ;
38
38
const items = response . choices . map ( choice => {
39
- const content = choice . message . content
40
- . replace ( CODE_BLOCK_START_REGEX , '' )
41
- . replace ( CODE_BLOCK_END_REGEX , '' ) ;
39
+ const messageContent = choice . message . content ;
40
+ let content = '' ;
41
+
42
+ if ( typeof messageContent === 'string' ) {
43
+ content = messageContent
44
+ . replace ( CODE_BLOCK_START_REGEX , '' )
45
+ . replace ( CODE_BLOCK_END_REGEX , '' ) ;
46
+ } else if ( Array . isArray ( messageContent ) ) {
47
+ // Handle ContentChunk[] case - extract text content
48
+ content = messageContent
49
+ . filter ( chunk => chunk . type === 'text' )
50
+ . map ( chunk => chunk . text || '' )
51
+ . join ( '' )
52
+ . replace ( CODE_BLOCK_START_REGEX , '' )
53
+ . replace ( CODE_BLOCK_END_REGEX , '' ) ;
54
+ }
55
+
42
56
return {
43
57
insertText : content
44
58
} ;
You can’t perform that action at this time.
0 commit comments