Skip to content

Commit 439ca8e

Browse files
authored
Check video status. (#442)
1 parent ae5f1b2 commit 439ca8e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

samples/text_generation.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,21 @@ def test_text_gen_multimodal_audio(self):
9999

100100
def test_text_gen_multimodal_video_prompt(self):
101101
# [START text_gen_multimodal_video_prompt]
102+
import time
103+
104+
# Video clip (CC BY 3.0) from https://peach.blender.org/download/
105+
myfile = genai.upload_file(media / "Big_Buck_Bunny.mp4")
106+
print(f"{myfile=}")
107+
108+
# Videos need to be processed before you can use them.
109+
while myfile.state.name == "PROCESSING":
110+
print("processing video...")
111+
time.sleep(5)
112+
myfile = genai.get_file(myfile.name)
113+
102114
model = genai.GenerativeModel("gemini-1.5-flash")
103-
video = genai.upload_file(media / "Big_Buck_Bunny.mp4")
104-
response = model.generate_content(["Describe this video clip.", video])
105-
print(response.text)
115+
result = model.generate_content([myfile, "Describe this video clip"])
116+
print(f"{result.text=}")
106117
# [END text_gen_multimodal_video_prompt]
107118

108119
def test_text_gen_multimodal_video_prompt_streaming(self):

0 commit comments

Comments
 (0)