@@ -37,20 +37,23 @@ async function createNonStreamingChat(
37
37
console . log ( `User: ${ chatInput1 } ` ) ;
38
38
39
39
const result1 = await chat . sendMessage ( chatInput1 ) ;
40
- const response1 = result1 . response . candidates [ 0 ] . content . parts [ 0 ] . text ;
41
- console . log ( 'Chat bot: ' , response1 ) ;
40
+ const response1 = await result1 . response ;
41
+ const text1 = response1 . candidates [ 0 ] . content . parts [ 0 ] . text ;
42
+ console . log ( 'Chat bot: ' , text1 ) ;
42
43
43
44
const chatInput2 = 'Can you tell me a scientific fun fact?' ;
44
45
console . log ( `User: ${ chatInput2 } ` ) ;
45
46
const result2 = await chat . sendMessage ( chatInput2 ) ;
46
- const response2 = result2 . response . candidates [ 0 ] . content . parts [ 0 ] . text ;
47
- console . log ( 'Chat bot: ' , response2 ) ;
47
+ const response2 = await result2 . response ;
48
+ const text2 = response2 . candidates [ 0 ] . content . parts [ 0 ] . text ;
49
+ console . log ( 'Chat bot: ' , text2 ) ;
48
50
49
51
const chatInput3 = 'How can I learn more about that?' ;
50
52
console . log ( `User: ${ chatInput3 } ` ) ;
51
53
const result3 = await chat . sendMessage ( chatInput3 ) ;
52
- const response3 = result3 . response . candidates [ 0 ] . content . parts [ 0 ] . text ;
53
- console . log ( 'Chat bot: ' , response3 ) ;
54
+ const response3 = await result3 . response ;
55
+ const text3 = response3 . candidates [ 0 ] . content . parts [ 0 ] . text ;
56
+ console . log ( 'Chat bot: ' , text3 ) ;
54
57
}
55
58
// [END aiplatform_gemini_multiturn_chat_nonstreaming]
56
59
0 commit comments