Skip to content

refactor(py/samples): standardize naming taxonomy, consolidate shared logic, and close feature coverage gaps#4488

Merged
yesudeep merged 1 commit intomainfrom
yesudeep/fix/necessary-cable
Feb 7, 2026
Merged

refactor(py/samples): standardize naming taxonomy, consolidate shared logic, and close feature coverage gaps#4488
yesudeep merged 1 commit intomainfrom
yesudeep/fix/necessary-cable

Conversation

@yesudeep
Copy link
Contributor

@yesudeep yesudeep commented Feb 7, 2026

Summary

Standardizes sample directory naming with a consistent taxonomy, extracts shared
flow logic and types into a common shared/ module, adds new framework feature
demos, and closes all feature coverage gaps in provider samples. Every sample now
follows a clear provider-*, framework-*, or web-* prefix convention.

Rationale

The samples directory had inconsistent naming (e.g., menu, flask-hello,
ollama-hello, short-n-long) making it hard to discover what a sample
demonstrates. Provider samples also had significant code duplication — the same
flow patterns (greeting, streaming, tools, vision, etc.) were reimplemented in
each sample. This PR:

  1. Establishes three naming categories:
    • provider-* — model provider and plugin-specific samples
    • framework-* — Genkit framework feature demos (context, tools, RAG, etc.)
    • web-* — web framework integration samples (Flask, ASGI, multi-server)
  2. Extracts shared types and flow logic into samples/shared/ so provider samples
    delegate to common implementations, reducing boilerplate
  3. Adds a setup_sample() utility for one-call Rich traceback + structlog setup
  4. Closes all ❌ cells in the feature coverage matrix

Changes

Sample renames (34 directories):

Old Name New Name
amazon-bedrock-hello provider-amazon-bedrock-hello
anthropic-hello provider-anthropic-hello
cloudflare-workers-ai-hello provider-cloudflare-workers-ai-hello
compat-oai-hello provider-compat-oai-hello
deepseek-hello provider-deepseek-hello
firestore-retreiver provider-firestore-retriever (typo fix!)
google-genai-code-execution provider-google-genai-code-execution
google-genai-context-caching provider-google-genai-context-caching
google-genai-hello provider-google-genai-hello
google-genai-vertexai-hello provider-google-genai-vertexai-hello
google-genai-image / media-models-demo provider-google-genai-media-models-demo
google-genai-vertexai-image provider-google-genai-vertexai-image
huggingface-hello provider-huggingface-hello
microsoft-foundry-hello provider-microsoft-foundry-hello
mistral-hello provider-mistral-hello
model-garden provider-vertex-ai-model-garden
observability-hello provider-observability-hello
ollama-hello provider-ollama-hello
vertex-ai-vector-search-bigquery provider-vertex-ai-vector-search-bigquery
vertex-ai-vector-search-firestore provider-vertex-ai-vector-search-firestore
vertexai-rerank-eval provider-vertex-ai-rerank-eval
xai-hello provider-xai-hello
evaluator-demo framework-evaluator-demo
format-demo framework-format-demo
menu framework-restaurant-demo
prompt-demo framework-prompt-demo
realtime-tracing-demo framework-realtime-tracing-demo
tool-interrupts framework-tool-interrupts
flask-hello web-flask-hello
multi-server web-multi-server
short-n-long web-short-n-long

New samples:

Sample Description
framework-context-demo Context propagation through flows, tools, and generate
framework-dynamic-tools-demo Dynamic tool registration at runtime
framework-middleware-demo Custom retry and logging middleware

Deleted samples:

Sample Reason
ollama-simple-embed Merged into provider-ollama-hello

Shared module consolidation (samples/shared/):

  • shared/types.py — centralized Pydantic input/output models used across all provider samples (GreetingInput, StreamInput, CharacterInput, CodeInput, WeatherInput, ImageDescribeInput, ReasoningInput, etc.)
  • shared/flows.py — reusable flow logic functions (generate_greeting_logic, generate_streaming_story_logic, describe_image_logic, solve_reasoning_problem_logic, etc.)
  • shared/logging.py (new) — setup_sample() utility that configures Rich tracebacks + colored structlog/stdlib logging in one call
  • shared/__init__.py — updated re-exports for all new types and functions

Provider sample enhancements:

  • provider-ollama-hello: added Moondream v2 model for object detection (detect_objects flow with bounding boxes), explicit model parameters for tool-calling flows
  • All provider samples refactored to use shared types and flow logic, removing duplicated boilerplate
  • Feature coverage matrix now 100% clean (0 ❌ cells)

Other changes:

  • Samples README rewritten with new taxonomy, architecture diagram, and feature coverage matrix
  • pyproject.toml package names updated to match new directory names
  • sample_parity_roadmap.md added, old sample_parity_analysis.md removed
  • uv.lock regenerated

Testing

  • bin/lint passes with 0 errors
  • All pyproject.toml names match directory names (consistency check passes)
  • All renames verified — no broken imports or missing files

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions bot added docs Improvements or additions to documentation python Python fix labels Feb 7, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 3 times, most recently from 366a6fa to 01647ae Compare February 7, 2026 07:28
@yesudeep yesudeep changed the title fix: test feat(py/samples): close sample coverage gaps with vision, reasoning, and structured output flows Feb 7, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 4 times, most recently from 0e45388 to 0d92fbf Compare February 7, 2026 07:56
@github-actions github-actions bot added the config label Feb 7, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 9 times, most recently from 32c4609 to d891f52 Compare February 7, 2026 09:16
@github-actions github-actions bot added the root label Feb 7, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 3 times, most recently from 3a28a20 to f9632d6 Compare February 7, 2026 10:46
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 5 times, most recently from 059de99 to a204107 Compare February 7, 2026 12:14
@yesudeep yesudeep requested a review from huangjeff5 February 7, 2026 12:14
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 2 times, most recently from a68e0d1 to 66509f9 Compare February 7, 2026 12:15
@yesudeep yesudeep changed the title feat(py/samples): close sample coverage gaps with vision, reasoning, and structured output flows refactor(py/samples): standardize naming taxonomy and close feature coverage gaps Feb 7, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch 3 times, most recently from d0cab85 to 410d293 Compare February 7, 2026 12:48
…vider samples

Expand samples/shared/ with common Pydantic models (SayHiInput,
SystemPromptInput, MultiTurnInput, CodeInput, StreamInput, CharacterInput,
StreamingToolInput, ImageDescribeInput, ConfigInput, ReasoningInput) and
flow logic functions (system_prompt_logic, multi_turn_chat_logic,
generate_code_logic, describe_image_logic, streaming_tool_flow_logic,
reasoning_logic). Slim down anthropic, deepseek, huggingface, and mistral
provider samples to import from shared and delegate to logic functions.
Slim down amazon-bedrock, cloudflare-workers-ai, microsoft-foundry,
xai, google-genai, google-genai-vertexai, compat-oai, and ollama
provider samples to import common types, tools, and flow logic from
samples/shared/. Provider-specific features remain inline.
@yesudeep yesudeep force-pushed the yesudeep/fix/necessary-cable branch from 410d293 to 113b234 Compare February 7, 2026 12:50
@yesudeep yesudeep enabled auto-merge (squash) February 7, 2026 12:50
@yesudeep yesudeep disabled auto-merge February 7, 2026 12:51
@yesudeep yesudeep changed the title refactor(py/samples): standardize naming taxonomy and close feature coverage gaps refactor(py/samples): standardize naming taxonomy, consolidate shared logic, and close feature coverage gaps Feb 7, 2026
@yesudeep yesudeep enabled auto-merge (squash) February 7, 2026 12:53
@yesudeep yesudeep disabled auto-merge February 7, 2026 12:55
@yesudeep yesudeep enabled auto-merge (squash) February 7, 2026 12:55
@yesudeep yesudeep merged commit 1996c7c into main Feb 7, 2026
18 checks passed
@yesudeep yesudeep deleted the yesudeep/fix/necessary-cable branch February 7, 2026 13:03
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 fix python Python root

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants