Skip to content

Commit dadfa8e

Browse files
committed
feat: add multimodal video embedding example and update test configuration to use global location
1 parent 2eac113 commit dadfa8e

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START googlegenaisdk_multimodal_embedding_video]
16+
from google import genai
17+
from google.genai import types
18+
19+
20+
def embed_content() -> types.EmbedContentResponse:
21+
client = genai.Client()
22+
23+
part = types.Part.from_uri(
24+
file_uri="gs://cloud-samples-data/vertex-ai-vision/highway_vehicles.mp4",
25+
mime_type="video/mp4",
26+
)
27+
part.video_metadata = types.VideoMetadata(end_offset="1s")
28+
29+
content = types.Content(parts=[part])
30+
31+
response = client.models.embed_content(
32+
model="gemini-embedding-2",
33+
contents=[content],
34+
)
35+
print(response)
36+
# Example response:
37+
# embeddings=[ContentEmbedding(values=[-0.0123147098, 0.0727171078, ...])]
38+
return response
39+
40+
41+
# [END googlegenaisdk_multimodal_embedding_video]

‎genai/embeddings/test_embeddings_examples.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
import code_retrieval_example
2222
import embeddings_docretrieval_with_txt
2323
import model_tuning_example
24+
import multimodal_embedding_video
2425

2526
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
26-
os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1"
27+
os.environ["GOOGLE_CLOUD_LOCATION"] = "global"
2728
# The project name is included in the CICD pipeline
2829
# os.environ['GOOGLE_CLOUD_PROJECT'] = "add-your-project-name"
2930

@@ -40,3 +41,8 @@ def test_code_retrieval_example() -> None:
4041
def test_model_tuning_example() -> None:
4142
response = model_tuning_example.tune_embedding_model()
4243
assert response
44+
45+
46+
def test_multimodal_embedding_video() -> None:
47+
response = multimodal_embedding_video.embed_content()
48+
assert response

0 commit comments

Comments
 (0)