File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,31 @@ const ai = new GoogleGenAI({
88} ) ;
99
1010async function main ( ) {
11- const response = await ai . models . generateContent ( {
11+ const chat = ai . chats . create ( {
1212 model : "gemini-2.5-flash" ,
13- contents : "Explica cómo funciona la IA en pocas palabras" ,
13+ history : [ ] ,
1414 } ) ;
1515
16- console . log ( response . text ) ;
16+ const message1 = "Hola, mi nombre es Diego" ;
17+
18+ console . log ( "User: " , message1 ) ;
19+
20+ const response1 = await chat . sendMessageStream ( {
21+ message : message1 ,
22+ } ) ;
23+ for await ( const chunk of response1 ) {
24+ console . log ( chunk . text ) ;
25+ }
26+
27+ const message2 = "Sabes cuál es mi nombre?" ;
28+ console . log ( "User: " , message2 ) ;
29+
30+ const response2 = await chat . sendMessageStream ( {
31+ message : message2 ,
32+ } ) ;
33+ for await ( const chunk of response2 ) {
34+ console . log ( chunk . text ) ;
35+ }
1736}
1837
1938await main ( ) ;
You can’t perform that action at this time.
0 commit comments