in python/text_generation.py [0:0]
def test_text_gen_multimodal_video_prompt_streaming(self):
# [START text_gen_multimodal_video_prompt_streaming]
from google import genai
import time
client = genai.Client()
# Video clip (CC BY 3.0) from https://peach.blender.org/download/
myfile = client.files.upload(file=media / "Big_Buck_Bunny.mp4")
print(f"{myfile=}")
# Poll until the video file is completely processed (state becomes ACTIVE).
while not myfile.state or myfile.state.name != "ACTIVE":
print("Processing video...")
print("File state:", myfile.state)
time.sleep(5)
myfile = client.files.get(name=myfile.name)
response = client.models.generate_content_stream(
model="gemini-2.0-flash", contents=[myfile, "Describe this video clip"]
)
for chunk in response:
print(chunk.text)
print("_" * 80)