Skip to content

refactor(py/plugins/google-genai): trim dead Lyria helpers - #6783

Merged
cabljac merged 1 commit into
mainfrom
fix/py-google-genai-config-surfaces
Oct 13, 2026
Merged

cabljac merged 1 commit into
mainfrom
fix/py-google-genai-config-surfaces

Conversation

@hilariie

Copy link
Copy Markdown
Contributor

Fixes #6185

Summary

The issue's speech config items landed with #6328 and #6593, and the ImagenConfigSchema item with #6305, which retired Imagen. This closes the Lyria item.

_models/_lyria.py still carried a LyriaConfig, a KNOWN_LYRIA_MODELS set, model info, and request/response helpers for the predict API. Nothing imports them, and the package's LyriaConfig export comes from _interactions_lyria. The module now keeps only is_lyria_model, which routing uses.

@github-actions github-actions Bot added docs Improvements or additions to documentation python Python fix labels Oct 12, 2026
@hilariie
hilariie force-pushed the fix/py-google-genai-config-surfaces branch from 2446fb9 to 54a226e Compare October 12, 2026 11:23
@hilariie
hilariie requested a review from cabljac October 12, 2026 11:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the Vertex AI Virtual Try-On model (virtual-try-on-001) to the genkit-google-genai package, including configuration schemas, routing, and comprehensive tests. The review feedback suggests several important safety improvements to prevent runtime exceptions, such as using the internal StrEnum compatibility layer to avoid dependency issues on Python < 3.11, ensuring media URLs are not empty before processing, and guarding against a None context when retrieving client configurations.

I am having trouble creating individual review comments. Click here to see my feedback.

py/packages/genkit-google-genai/src/genkit_google_genai/models/virtual_try_on.py (35-42)

high

Using strenum directly can cause a ModuleNotFoundError on Python < 3.11 if the package is not installed. Since genkit already provides a compatible StrEnum implementation in genkit._core._compat, it is safer and more consistent to use that instead.

from collections.abc import Mapping
from typing import Any, Literal, TypeAlias

from genkit._core._compat import StrEnum

py/packages/genkit-google-genai/src/genkit_google_genai/models/virtual_try_on.py (232-237)

medium

If part.media.url is None or empty, appending it to urls can cause runtime errors (such as AttributeError when calling startswith on None) in _to_image. It is safer to check that part.media.url is present and non-empty before appending it.

    for part in request.messages[-1].content:
        if part.media is None or not part.media.url:
            continue
        metadata = part.metadata
        if isinstance(metadata, dict) and metadata.get('type') == part_type:
            urls.append(part.media.url)

py/packages/genkit-google-genai/src/genkit_google_genai/models/virtual_try_on.py (383-386)

medium

If ctx.context is None, calling context.get('config') will raise an AttributeError. Guarding against None by defaulting context to an empty dictionary ensures safety.

        context = ctx.context or {}
        api_key = context_api_key(context)
        context_config = context.get('config')
        context_config = context_config if isinstance(context_config, dict) else {}

@hilariie
hilariie marked this pull request as ready for review October 12, 2026 11:23

@cabljac cabljac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cabljac
cabljac merged commit 2adc222 into main Oct 13, 2026
26 checks passed
@cabljac
cabljac deleted the fix/py-google-genai-config-surfaces branch October 13, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation fix python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(py/plugins/google-genai): SpeechConfigSchema drops fields, ImagenConfigSchema is empty, Lyria is dead code but exported

2 participants