File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 23
23
class UnitTests (absltest .TestCase ):
24
24
def test_text_gen_text_only_prompt (self ):
25
25
# [START text_gen_text_only_prompt]
26
+ import google .generativeai as genai
27
+ import os
28
+
29
+ genai .configure (api_key = os .environ ["API_KEY" ])
26
30
model = genai .GenerativeModel ("gemini-1.5-flash" )
27
- response = model .generate_content ("Write a story about a magic backpack. " )
31
+ response = model .generate_content ("Explain how AI works " )
28
32
print (response .text )
29
33
# [END text_gen_text_only_prompt]
30
34
31
35
def test_text_gen_text_only_prompt_streaming (self ):
32
36
# [START text_gen_text_only_prompt_streaming]
33
37
model = genai .GenerativeModel ("gemini-1.5-flash" )
34
- response = model .generate_content ("Write a story about a magic backpack. " , stream = True )
38
+ response = model .generate_content ("Explain how AI works " , stream = True )
35
39
for chunk in response :
36
40
print (chunk .text )
37
41
print ("_" * 80 )
You can’t perform that action at this time.
0 commit comments