Skip to content

docs(py): upgrade plugin docstrings to landing-page hero style with inline return shapes - #5650

Merged
huangjeff5 merged 11 commits into
mainfrom
reorg/py-plugins-docstrings
Jul 24, 2026
Merged

docs(py): upgrade plugin docstrings to landing-page hero style with inline return shapes#5650
huangjeff5 merged 11 commits into
mainfrom
reorg/py-plugins-docstrings

Conversation

@huangjeff5

Copy link
Copy Markdown
Contributor

Description

As part of PR stack #3 (branched off PR #2 reorg/py-plugins), this pull request audits all Genkit Python plugin and core packages to replace verbose ELI5 explanations and ASCII data-flow diagrams with professional, product-oriented landing-page hero snippets.

Key highlights:

  • Calibrated Style Guide: Introduced genkit-docstring-style skill defining required code block formatting.
  • Numbered Action Steps: Code snippets use # 1. ..., # 2. ..., # 3. ... comments guiding developers through initialization and execution.
  • Inline Return Shapes (# =>): Illustrates expected response shapes directly inline without requiring execution.
  • Clean Multi-Line Formatting: Formatted multi-line outputs cleanly across indented # lines without escape codes like \n.
  • Strict Scope: Code examples are kept strictly on modules, classes, or functions that originally contained code examples.
  • Model Standard: Recommends googleai/gemini-flash-latest, googleai/gemini-pro-latest, or vertexai/... equivalents across generation snippets.

Base Branch

Branches off of and targets reorg/py-plugins (#5644).

@github-actions github-actions Bot added docs Improvements or additions to documentation python Python labels Jun 29, 2026

@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 introduces a new docstring style guide (SKILL.md) for Genkit Python packages, mandating the "Landing Page Hero Snippet" pattern. This pattern focuses on clean, product-oriented code examples with numbered steps and inline return shape annotations (# =>), while removing verbose ELI5 explanations and ASCII diagrams. Accordingly, docstrings across multiple packages (including genkit-anthropic, genkit-django, genkit-fastapi, genkit-flask, genkit-googleai, genkit-googlecloud, genkit-middleware, genkit-ollama, genkit-openai, and genkit-vertexai) have been refactored to align with this style. The review feedback correctly identifies several bugs in the newly introduced code examples, such as incorrect attribute access on evaluation results, long-running operations, and media parts, which would lead to AttributeErrors at runtime.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread py/packages/genkit-googleai/src/genkit_googleai/evaluators/__init__.py Outdated
Comment thread py/packages/genkit-googleai/src/genkit_googleai/models/veo.py Outdated
Comment thread py/packages/genkit-googleai/src/genkit_googleai/models/lyria.py Outdated
@huangjeff5

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 streamlines and simplifies the module-level docstrings across multiple Genkit Python packages by removing large ASCII diagrams, ELI5 explanations, and complex architecture overviews. These are replaced with concise descriptions, updated requirements, and cleaner, more practical code examples. The feedback points out a missing asyncio import in the veo.py example code block, which is necessary to make the snippet fully functional and copy-pasteable.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread py/packages/genkit-googleai/src/genkit_googleai/models/veo.py Outdated
@huangjeff5
huangjeff5 requested a review from a team as a code owner June 29, 2026 17:15
@huangjeff5
huangjeff5 force-pushed the reorg/py-plugins-docstrings branch 2 times, most recently from a7c93ba to 8580b26 Compare June 29, 2026 17:43
@huangjeff5
huangjeff5 changed the base branch from reorg/py-plugins to main July 17, 2026 16:50
@huangjeff5
huangjeff5 force-pushed the reorg/py-plugins-docstrings branch from 9496af6 to 71c998a Compare July 17, 2026 17:21

@hilariie hilariie 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.

The snippets read well, but some snippets still require implementation support. For example

  1. Flask: genkit_flask_handler(ai) returns a decorator; the current form passes the flow as context_provider and returns the decorator as the response. Real usage is the stacked @app.post(...) / @genkit_flask_handler(ai) / @ai.flow() form.

  2. Ollama does not accept string model definitions: models= is list[ModelDefinition]; strings hit AttributeError on .name. Either wrap in ModelDefinition(name=...) or (preferably) teach the plugin to accept strings so the snippet stays clean.

  3. Model Garden: models register under modelgarden/, not vertexai/, and only when passed via models=[...]. modelgarden/claude-3-5-sonnet-v2 with an explicit models list resolves; vertexai/... never will.

  4. Veo/Lyria route through the wrong path: Veo is a background model (start/check action pair), so ai.generate(...) isn't the invocation path. Lyria is Vertex-only predict-based audio with the same concern.

Since these are presented as runnable examples, could we either land the supporting changes first in an implementation PR, tracked by an issue, and rebase this PR onto it, or include the fixes here to avoid publishing these snippets before the behavior exists. If this is intended as follow-up work, could we link the tracking issue here and make the release ordering explicit?

Address review feedback on #5650: correct Flask decorator stacking,
Ollama lazy model resolve, and Model Garden namespace; drop Veo/Lyria
snippets that do not run on this branch yet.
@huangjeff5
huangjeff5 requested a review from hilariie July 23, 2026 22:52
@huangjeff5

Copy link
Copy Markdown
Contributor Author

Thanks for the review @hilariie! We've updated the docstring examples across this PR so that every snippet reflects APIs that run on this branch today, without relying on unmerged follow-up PRs:

  1. Flask (genkit-flask):

    • Switched the snippet to the stacked decorator pattern (@app.post(...) / @genkit_flask_handler(ai) / @ai.flow()) on a single async flow handler function.
  2. Ollama (genkit-ollama):

    • Updated the init snippet to plugins=[Ollama()] and pass model='ollama/llama3.2' directly in ai.generate(...). Lazy model resolution works on this branch today without passing string model lists at plugin initialization.
  3. Model Garden (genkit-vertexai):

    • Corrected the namespace and model reference to model='modelgarden/anthropic/claude-3-5-sonnet-v2@20241022', matching the modelgarden/ plugin registration and publisher qualification.
  4. Veo & Lyria (genkit-google-genai):

The fixes have been pushed to reorg/py-plugins-docstrings. Ready for another look!

@hilariie hilariie 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

@huangjeff5
huangjeff5 merged commit bc4c733 into main Jul 24, 2026
24 checks passed
@huangjeff5
huangjeff5 deleted the reorg/py-plugins-docstrings branch July 24, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config docs Improvements or additions to documentation python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants