Skip to content

Commit b0779ad

Browse files
Update text_generation.py
1 parent 4f42118 commit b0779ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

samples/text_generation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@
2323
class UnitTests(absltest.TestCase):
2424
def test_text_gen_text_only_prompt(self):
2525
# [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"])
2630
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")
2832
print(response.text)
2933
# [END text_gen_text_only_prompt]
3034

3135
def test_text_gen_text_only_prompt_streaming(self):
3236
# [START text_gen_text_only_prompt_streaming]
3337
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)
3539
for chunk in response:
3640
print(chunk.text)
3741
print("_" * 80)

0 commit comments

Comments
 (0)