File tree 3 files changed +29
-18
lines changed
templates/types/streaming
3 files changed +29
-18
lines changed Original file line number Diff line number Diff line change @@ -34,19 +34,21 @@ export const convertMessageContent = (
34
34
textMessage : string ,
35
35
additionalData ?: DataParserOptions ,
36
36
) : MessageContent => {
37
+ if ( ! additionalData ) return textMessage ;
38
+ const content : MessageContent = [
39
+ {
40
+ type : "text" ,
41
+ text : textMessage ,
42
+ }
43
+ ] ;
37
44
if ( additionalData ?. imageUrl ) {
38
- return [
39
- {
40
- type : "text" ,
41
- text : textMessage ,
42
- } ,
45
+ content . push (
43
46
{
44
47
type : "image_url" ,
45
48
image_url : {
46
49
url : additionalData ?. imageUrl ,
47
50
} ,
48
- } ,
49
- ] ;
51
+ } ) ;
50
52
}
51
53
52
54
if ( additionalData ?. uploadedCsv ) {
@@ -55,10 +57,13 @@ export const convertMessageContent = (
55
57
"```csv\n" +
56
58
additionalData . uploadedCsv . content +
57
59
"\n```" ;
58
- return `${ csvContent } \n\n${ textMessage } ` ;
60
+ content . push ( {
61
+ type : "text" ,
62
+ text : `${ csvContent } \n\n${ textMessage } `
63
+ } ) ;
59
64
}
60
65
61
- return textMessage ;
66
+ return content ;
62
67
} ;
63
68
64
69
function createParser (
Original file line number Diff line number Diff line change @@ -34,19 +34,21 @@ export const convertMessageContent = (
34
34
textMessage : string ,
35
35
additionalData ?: DataParserOptions ,
36
36
) : MessageContent => {
37
+ if ( ! additionalData ) return textMessage ;
38
+ const content : MessageContent = [
39
+ {
40
+ type : "text" ,
41
+ text : textMessage ,
42
+ }
43
+ ] ;
37
44
if ( additionalData ?. imageUrl ) {
38
- return [
39
- {
40
- type : "text" ,
41
- text : textMessage ,
42
- } ,
45
+ content . push (
43
46
{
44
47
type : "image_url" ,
45
48
image_url : {
46
49
url : additionalData ?. imageUrl ,
47
50
} ,
48
- } ,
49
- ] ;
51
+ } ) ;
50
52
}
51
53
52
54
if ( additionalData ?. uploadedCsv ) {
@@ -55,10 +57,13 @@ export const convertMessageContent = (
55
57
"```csv\n" +
56
58
additionalData . uploadedCsv . content +
57
59
"\n```" ;
58
- return `${ csvContent } \n\n${ textMessage } ` ;
60
+ content . push ( {
61
+ type : "text" ,
62
+ text : `${ csvContent } \n\n${ textMessage } `
63
+ } ) ;
59
64
}
60
65
61
- return textMessage ;
66
+ return content ;
62
67
} ;
63
68
64
69
function createParser (
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface ChatResourcesProps {
10
10
}
11
11
12
12
export default function ChatResources ( props : ChatResourcesProps ) {
13
+ if ( ! props . resources . length ) return null ;
13
14
return (
14
15
< div className = "flex gap-4 text-sm" >
15
16
{ props . resources . map ( ( data , index ) => {
You can’t perform that action at this time.
0 commit comments