FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[pull] main from GoogleCloudPlatform:main by pull[bot] · Pull Request #292 · Reality2byte/python-docs-samples · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
43 changes: 43 additions & 0 deletions genai/embeddings/multimodal_embedding_video.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START aiplatform_genai_multimodal_embedding_video]
from google import genai
from google.genai import types


def embed_content() -> types.EmbedContentResponse:
client = genai.Client()

part = types.Part(
file_data=types.FileData(
file_uri="gs://cloud-samples-data/vertex-ai-vision/highway_vehicles.mp4",
mime_type="video/mp4",
),
video_metadata=types.VideoMetadata(end_offset="1s"),
)

content = types.Content(parts=[part])

response = client.models.embed_content(
model="gemini-embedding-2",
contents=[content],
)
print(response)
# Example response:
# embeddings=[ContentEmbedding(values=[-0.0123147098, 0.0727171078, ...])]
return response


# [END aiplatform_genai_multimodal_embedding_video]
8 changes: 7 additions & 1 deletion genai/embeddings/test_embeddings_examples.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import code_retrieval_example
import embeddings_docretrieval_with_txt
import model_tuning_example
import multimodal_embedding_video

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

Expand All @@ -40,3 +41,8 @@ def test_code_retrieval_example() -> None:
def test_model_tuning_example() -> None:
response = model_tuning_example.tune_embedding_model()
assert response


def test_multimodal_embedding_video() -> None:
response = multimodal_embedding_video.embed_content()
assert response
Loading

Back | FazBrowse Home | New Git URL