From aa6202891a2feb880ea5b0eaa8404d5c6932bb17 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Mon, 9 Nov 2026 17:32:45 -0600 Subject: [PATCH] chore: remove monorepo remnants, py/ paths, floor-shim, genkit-tools schema, and update release scripts --- .github/workflows/publish_python.yml | 16 +- .github/workflows/python.yml | 1 + .gitignore | 1 + bin/_common.sh | 2 +- bin/build_dists | 2 +- bin/bump_version | 4 +- bin/create_release | 26 +- bin/run_python_security_checks | 2 +- docs/migrating-from-0.12.md | 2 +- docs/release_playbook.md | 28 +- floor-shim/.gitignore | 2 - floor-shim/README.md | 78 - floor-shim/setup.py | 149 - genkit-tools/genkit-schema.json | 2514 ----------------- packages/genkit-amazon-bedrock/README.md | 2 +- packages/genkit-google-genai/README.md | 4 +- packages/genkit-ollama/README.md | 4 +- packages/genkit-otel/README.md | 2 +- packages/genkit/README.md | 2 +- .../tests/genkit/core/nested_dump_test.py | 35 +- .../genkit/tests/genkit/docs_exports_test.py | 2 +- .../typecheck/get_logger_contract_test.py | 2 +- pyproject.toml | 2 +- samples/agents/README.md | 2 +- samples/agents/testapp/README.md | 2 +- samples/mcp-hello/README.md | 2 +- scripts/check_consistency.py | 2 +- tests/conftest_test.py | 2 +- tests/floor_shim_guard_test.py | 112 - 29 files changed, 81 insertions(+), 2923 deletions(-) delete mode 100644 floor-shim/.gitignore delete mode 100644 floor-shim/README.md delete mode 100644 floor-shim/setup.py delete mode 100644 genkit-tools/genkit-schema.json delete mode 100644 tests/floor_shim_guard_test.py diff --git a/.github/workflows/publish_python.yml b/.github/workflows/publish_python.yml index 543792a7e..43db4547f 100644 --- a/.github/workflows/publish_python.yml +++ b/.github/workflows/publish_python.yml @@ -91,27 +91,13 @@ jobs: echo "::endgroup::" done - # Python-floor shim (genkit 0.3.0): gives Python <= 3.9 users a clear - # upgrade message instead of resolving an unrelated pre-transfer - # package. sdist ONLY - a wheel would install as an empty package on - # old Pythons. skip-existing makes this a no-op after first publish. - # See floor-shim/README.md. - echo "::group::floor-shim (sdist only)" - if uv build --sdist floor-shim --out-dir dist/; then - echo "Build succeeded: floor-shim" - else - echo "::error::Build failed: floor-shim" - FAILED+=("floor-shim") - fi - echo "::endgroup::" - if [ ${#FAILED[@]} -gt 0 ]; then echo "::error::Failed packages: ${FAILED[*]}" exit 1 fi - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 with: packages-dir: dist/ verbose: true diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 2b274a44f..b0efdb502 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -182,6 +182,7 @@ jobs: mkdir -p "$SPEC_DIR" curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/tests/specs/agent.yaml -o "$SPEC_DIR/agent.yaml" curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/tests/specs/generate.yaml -o "$SPEC_DIR/generate.yaml" + curl -sSfL https://raw.githubusercontent.com/genkit-ai/genkit/main/genkit-tools/genkit-schema.json -o "$SPEC_DIR/genkit-schema.json" echo "GENKIT_SPECS_DIR=$SPEC_DIR" >> "$GITHUB_ENV" - name: Run tests diff --git a/.gitignore b/.gitignore index ecf85fd48..35563166d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ wheels/ *.bak release-manifest.json +genkit-tools/ diff --git a/bin/_common.sh b/bin/_common.sh index 5403f7640..2da01a6de 100644 --- a/bin/_common.sh +++ b/bin/_common.sh @@ -15,7 +15,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# Shared helpers for py/bin scripts. Source with: . "$(dirname "$0")/_common.sh" +# Shared helpers for bin scripts. Source with: . "$(dirname "$0")/_common.sh" # Colors (CYAN exported for scripts that source this file) RED='\033[0;31m' diff --git a/bin/build_dists b/bin/build_dists index f07c247c8..50838d43a 100755 --- a/bin/build_dists +++ b/bin/build_dists @@ -31,7 +31,7 @@ PY_DIR="${TOP_DIR}" # This includes packages, plugins, samples, and tests PROJECT_DIRS=() while IFS= read -r -d '' pyproject; do - # Get the directory containing pyproject.toml, relative to py/ + # Get the directory containing pyproject.toml, relative to repo root project_dir=$(dirname "${pyproject}") project_dir="${project_dir#"${PY_DIR}"/}" PROJECT_DIRS+=("$project_dir") diff --git a/bin/bump_version b/bin/bump_version index 4b038364a..283691373 100755 --- a/bin/bump_version +++ b/bin/bump_version @@ -233,7 +233,7 @@ else echo -e " 1. Write the release notes in notes.md" echo -e " 2. Open the release PR:" echo -e " ${CYAN}git commit -am \"chore(py): release Python SDK v$NEW_VERSION\"${NC}" - echo -e " ${CYAN}gh pr create --base main --title \"chore(py): release Python SDK v$NEW_VERSION\" --body-file notes.md --label python${NC}" + echo -e " ${CYAN}gh pr create --base main --title \"chore: release v$NEW_VERSION\" --body-file notes.md${NC}" echo -e " 3. Once merged, release it (add --dry-run to check first):" - echo -e " ${CYAN}py/bin/create_release $NEW_VERSION ${NC}" + echo -e " ${CYAN}bin/create_release $NEW_VERSION ${NC}" fi diff --git a/bin/create_release b/bin/create_release index 35d173962..fbfd3fc96 100755 --- a/bin/create_release +++ b/bin/create_release @@ -18,23 +18,23 @@ # Tag and publish a stable Python SDK release from its merged release PR. # The PR's description is published as the release notes. # -# py/bin/create_release [--dry-run] +# bin/create_release [--dry-run] # -# Steps and checks: py/docs/release_playbook.md +# Steps and checks: docs/release_playbook.md # Exit codes: 0 ok, 1 usage/environment, 2 a check failed (nothing changed). set -euo pipefail -REPO="genkit-ai/genkit" +REPO="genkit-ai/genkit-python" usage() { cat < [--dry-run] +Usage: bin/create_release [--dry-run] Tags and publishes a Genkit Python SDK release from its merged release PR. - X.Y.Z, as set by py/bin/bump_version - Merged release PR titled "chore(py): release Python SDK v". + X.Y.Z, as set by bin/bump_version + Merged release PR titled "chore: release v" or "chore(py): release Python SDK v". Its description becomes the release notes. --dry-run Run the checks without tagging or publishing @@ -59,14 +59,14 @@ for arg in "$@"; do *) if [ -z "$VERSION" ]; then VERSION="$arg" elif [ -z "$PR_NUMBER" ]; then PR_NUMBER="$arg" - else die "unexpected argument '$arg'" "Usage: py/bin/create_release [--dry-run]" + else die "unexpected argument '$arg'" "Usage: bin/create_release [--dry-run]" fi ;; esac done [ -n "$VERSION" ] && [ -n "$PR_NUMBER" ] || - die "missing arguments" "Usage: py/bin/create_release [--dry-run]" + die "missing arguments" "Usage: bin/create_release [--dry-run]" [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || die "version must be X.Y.Z, got '$VERSION'" "For release candidates, use the \"Release Python RC\" workflow." [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] || @@ -74,9 +74,9 @@ done command -v gh >/dev/null 2>&1 || die "GitHub CLI not found" "Install it from https://cli.github.com" gh auth status >/dev/null 2>&1 || die "GitHub CLI is not authenticated" "Run: gh auth login" -cd "$(dirname "${BASH_SOURCE[0]}")/../.." +cd "$(dirname "${BASH_SOURCE[0]}")/.." -TAG="py/v${VERSION}" +TAG="v${VERSION}" TITLE="chore(py): release Python SDK v${VERSION}" PR_INFO=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json state,baseRefName,mergeCommit,url,title \ @@ -105,10 +105,10 @@ else pass "PR merged into main" fi -if [ "$PR_TITLE" = "$TITLE" ]; then +if [ "$PR_TITLE" = "$TITLE" ] || [ "$PR_TITLE" = "chore: release v${VERSION}" ] || [ "$PR_TITLE" = "chore: release Python SDK v${VERSION}" ]; then pass "Title matches" else - fail "Title is \"$PR_TITLE\"" "Expected \"$TITLE\". Pass the PR that bumped to $VERSION; rename only if this is it." + fail "Title is \"$PR_TITLE\"" "Expected \"$TITLE\" or \"chore: release v${VERSION}\". Pass the PR that bumped to $VERSION; rename only if this is it." fi if [ -n "$(printf '%s' "$NOTES" | tr -d '[:space:]')" ]; then @@ -124,7 +124,7 @@ if [ -n "$MERGE_SHA" ]; then FOUND="" TOTAL=0 NWRONG=0 - for toml in $(git ls-tree -r --name-only "$MERGE_SHA" -- py/packages | grep -E '^py/packages/[^/]+/pyproject\.toml$'); do + for toml in $(git ls-tree -r --name-only "$MERGE_SHA" -- packages | grep -E '^packages/[^/]+/pyproject\.toml$'); do v=$(git show "$MERGE_SHA:$toml" | sed -n 's/^version *= *"\(.*\)"/\1/p' | head -1) TOTAL=$((TOTAL + 1)) if [ "$v" != "$VERSION" ]; then diff --git a/bin/run_python_security_checks b/bin/run_python_security_checks index f82667bed..fd50300ea 100755 --- a/bin/run_python_security_checks +++ b/bin/run_python_security_checks @@ -24,7 +24,7 @@ PY_DIR="$(cd "${BIN_DIR}/.." && pwd)" echo "--- 🐍 Running Python Security Checks (PySentry) ---" # Run pysentry-rs via uv -# The --directory flag ensures we run in the context of the `py` directory. +# The --directory flag ensures we run in the context of the repository root. uv run --directory "${PY_DIR}" pysentry-rs . echo "--- ✅ Security Checks Passed ---" diff --git a/docs/migrating-from-0.12.md b/docs/migrating-from-0.12.md index b646ed13f..4b00e93f6 100644 --- a/docs/migrating-from-0.12.md +++ b/docs/migrating-from-0.12.md @@ -22,7 +22,7 @@ uv add 'genkit-vertexai[openai]' # Llama, Mistral and other OpenAI-compatib You can point a coding agent at this page: ```text -Migrate this project from Genkit Python 0.12 to 0.13 by following https://github.com/genkit-ai/genkit/blob/main/py/docs/migrating-from-0.12.md. +Migrate this project from Genkit Python 0.12 to 0.13 by following https://github.com/genkit-ai/genkit-python/blob/main/docs/migrating-from-0.12.md. Apply every section whose old code appears in this codebase, then run the type checker and tests and list anything you couldn't migrate. ``` diff --git a/docs/release_playbook.md b/docs/release_playbook.md index bc7e6d5d9..93e27caf4 100644 --- a/docs/release_playbook.md +++ b/docs/release_playbook.md @@ -11,44 +11,44 @@ Use the **Release Python RC** workflow in GitHub Actions: **What the workflow does:** -1. Creates branch `release/py/X.Y.Z-rc.1` (one branch per RC) +1. Creates branch `release/X.Y.Z-rc.1` (one branch per RC) 2. Bumps all `pyproject.toml` versions from current to the RC version 3. Commits and pushes to that branch -4. Creates tag `py/vX.Y.Z-rc.1` pointing at the release branch +4. Creates tag `vX.Y.Z-rc.1` pointing at the release branch 5. Tag push triggers **Publish Python**, which builds and publishes to PyPI No PR required. -**If you need to re-run publish** (e.g., it failed): Go to Actions → Publish Python → Run workflow → select the release branch (e.g., `release/py/X.Y.Z-rc.1`) from the branch dropdown → Run. +**If you need to re-run publish** (e.g., it failed): Go to Actions → Publish Python → Run workflow → select the release branch (e.g., `release/X.Y.Z-rc.1`) from the branch dropdown → Run. ## Stable release steps There is one path. `create_release` refuses to run unless every step below was followed. -1. `py/bin/bump_version X.Y.Z` on a branch from main. It bumps every `pyproject.toml` and `uv.lock`. -2. Open a PR to main titled exactly `chore(py): release Python SDK vX.Y.Z`. Its description is the release notes, published word for word. +1. `bin/bump_version X.Y.Z` on a branch from main. It bumps every `pyproject.toml` and `uv.lock`. +2. Open a PR to main titled `chore: release vX.Y.Z` or `chore(py): release Python SDK vX.Y.Z`. Its description is the release notes, published word for word. 3. Get it approved and merged. -4. `py/bin/create_release X.Y.Z --dry-run`, then without `--dry-run`. -5. Approve the publish at . The tag push already started it; don't run it by hand. +4. `bin/create_release X.Y.Z --dry-run`, then without `--dry-run`. +5. Approve the publish at . The tag push already started it; don't run it by hand. 6. `pip index versions genkit` shows X.Y.Z. `create_release` runs every check before it changes anything and prints a fix for each failure: - **Merged into main**: the PR is merged, and into main -- **Title**: exactly `chore(py): release Python SDK vX.Y.Z` +- **Title**: matches `chore: release vX.Y.Z` or `chore(py): release Python SDK vX.Y.Z` - **Release notes**: the description isn't empty -- **Versions**: every `py/packages/*/pyproject.toml` is at X.Y.Z in the merge commit -- **Tag**: `py/vX.Y.Z` doesn't exist yet +- **Versions**: every `packages/*/pyproject.toml` is at X.Y.Z in the merge commit +- **Tag**: `vX.Y.Z` doesn't exist yet It tags the PR's merge commit, not the tip of main, so anything merged later stays out of the release. Exit codes: `0` ok, `1` usage or environment, `2` a check failed and nothing changed. -To fix notes after release, edit the GitHub release: `gh release edit py/vX.Y.Z --notes-file notes.md`. The PR description isn't read again. +To fix notes after release, edit the GitHub release: `gh release edit vX.Y.Z --notes-file notes.md`. The PR description isn't read again. ## After 0.13.0: retire genkit-evaluators genkit 1.0 removes evaluators (#6947). genkit-evaluators 0.13.0 is the last release and requires `genkit>=0.13.0,<1`. `bump_version` writes that floor; the steps above need no hand edits. -Every earlier release (0.9.0 through 0.12.0) requires `genkit` with no upper bound. The cap alone isn't enough: when 0.13.0 conflicts with genkit 1.0, pip and uv backtrack to an older genkit-evaluators, and those accept genkit 1.0. So, once `py/v0.13.0` is on PyPI: +Every earlier release (0.9.0 through 0.12.0) requires `genkit` with no upper bound. The cap alone isn't enough: when 0.13.0 conflicts with genkit 1.0, pip and uv backtrack to an older genkit-evaluators, and those accept genkit 1.0. So, once `v0.13.0` is on PyPI: 1. Yank genkit-evaluators 0.9.0, 0.10.0, 0.11.0 and 0.12.0 on PyPI (Manage → Releases → Options → Yank). Reason: `unbounded genkit dependency; use 0.13.0`. 2. Verify in a fresh venv: @@ -67,7 +67,7 @@ Resolvers skip yanked versions unless pinned with `==`, so existing exact pins k ## Workflow: `publish_python.yml` -**Triggers:** Tag push (`py/v*`) or manual `workflow_dispatch`. When triggered by tag, it checks out the tag (which points at the release branch). When run manually, **select the release branch** (e.g., `release/py/X.Y.Z-rc.1`) from the "Use workflow from" dropdown — otherwise it will build from main. +**Triggers:** Tag push (`v*`) or manual `workflow_dispatch`. When triggered by tag, it checks out the tag (which points at the release branch). When run manually, **select the release branch** (e.g., `release/X.Y.Z-rc.1`) from the "Use workflow from" dropdown — otherwise it will build from main. **Two jobs:** publish → verify @@ -76,4 +76,4 @@ Resolvers skip yanked versions unless pinned with `==`, so existing exact pins k ## Auth -OIDC trusted publishing. No API tokens. PyPI is configured to trust: Owner `firebase`, Repository `genkit`, Workflow `publish_python.yml`, Environment `pypi_github_publishing`. Already set up. Don't rename the workflow file or this breaks. +OIDC trusted publishing. No API tokens. PyPI is configured to trust: Owner `genkit-ai`, Repository `genkit-python`, Workflow `publish_python.yml`, Environment `pypi_github_publishing`. Don't rename the workflow file or this breaks. diff --git a/floor-shim/.gitignore b/floor-shim/.gitignore deleted file mode 100644 index 17f52cc6d..000000000 --- a/floor-shim/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -genkit.egg-info/ -dist/ diff --git a/floor-shim/README.md b/floor-shim/README.md deleted file mode 100644 index d4bd751db..000000000 --- a/floor-shim/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# genkit Python-floor shim - -A one-time PyPI release (`genkit 0.3.0`, sdist only) that turns the -old-Python install experience from a silent wrong install into a clear -upgrade message. - -## Why it exists - -Genkit requires Python >= 3.10, but macOS ships Python 3.9 at -`/usr/bin/python3`. On that interpreter, `pip install genkit` used to -resolve `genkit 0.2.0` — an unrelated package from before the PyPI name -was transferred to this project ("random data like phone numbers") — -because those pre-transfer releases (0.1.0–0.2.0) declare -`Requires-Python: >=3.6` and pip silently falls back to them. - -## How it works - -- The shim declares `Requires-Python: <3.10`, so Python >= 3.10 can - never select it. Fresh installs on current Pythons keep getting the - real latest genkit. -- On Python <= 3.9, version 0.3.0 outranks the pre-transfer 0.2.0, pip - commits to it, and `setup.py` fails the **install phase** with a boxed - message: the 3.10 requirement plus uv / Homebrew / python.org - instructions. The failure must stay out of the metadata phase - (`egg_info`/`dist_info`/`sdist` succeed on purpose): old pip treats a - metadata failure as a discardable candidate and backtracks to the - pre-transfer 0.2.0 with exit 0 — the silent wrong install again. -- It is published as an **sdist only**. A wheel would install cleanly as - an empty package on old Pythons — exactly the silent failure this - prevents. Keep the `--sdist` flag in `publish_python.yml`. -- The boxed message is for `pip install genkit` and - `uv pip install genkit`. A second name on the same line - (`pip install genkit genkit-google-genai`) fails in the resolver on - that plugin's `Requires-Python: >=3.10` and never reaches this - `setup.py`. - -The version never changes: 0.3.0 was never published (the history goes -0.3.0.dev2 -> 0.3.1), and it sits above 0.2.0 (the last pre-transfer -release) and below 0.3.1 (the first real genkit release). -`skip-existing: true` in the publish workflow makes re-publishing it on -every release tag a no-op after the first upload. - -This directory is intentionally not a uv workspace member: it shares the -`genkit` project name with `packages/genkit`, and workspace project -names must be unique. - -## Verifying - -```bash -# Build (any Python >= 3.10): -uv build --sdist py/floor-shim --out-dir /tmp/shim-dist - -# Old Python shows the boxed message (expected: install fails with instructions): -/usr/bin/python3 -m venv /tmp/v39 && /tmp/v39/bin/pip install --no-index \ - --find-links /tmp/shim-dist genkit - -# The load-bearing case — a competing old release is visible (stands in for -# the pre-transfer 0.2.0). Expected: exit != 0, boxed message, and NOTHING -# installed. If genkit 0.2.0 gets installed instead, the shim is failing at -# the metadata phase and old pip is backtracking past it: -mkdir -p /tmp/sq && printf 'from setuptools import setup\nsetup(name="genkit", version="0.2.0", python_requires=">=3.6")\n' > /tmp/sq/setup.py -uv build --wheel /tmp/sq --out-dir /tmp/shim-dist -/usr/bin/python3 -m venv /tmp/v39b && /tmp/v39b/bin/pip install --no-index \ - --find-links /tmp/shim-dist genkit; /tmp/v39b/bin/pip show genkit - -# Current Python ignores the shim even when visible (expected: installs real genkit): -python3.13 -m venv /tmp/v313 && /tmp/v313/bin/pip install \ - --find-links /tmp/shim-dist genkit -``` - -## Required companion step: yank the pre-transfer releases - -Yank 0.1.0, 0.1.3, 0.1.4, and 0.2.0 on pypi.org **before or together -with** the first shim publish. This is a precondition, not optional -cleanup: those releases are the fallback candidates old pip reaches for -whenever it decides to skip the shim, and yanking is what makes the -wrong package unreachable for every resolver generation. After the -yank, pinned installs (`genkit==0.2.0`) are the only way to reach them. diff --git a/floor-shim/setup.py b/floor-shim/setup.py deleted file mode 100644 index 8597e181a..000000000 --- a/floor-shim/setup.py +++ /dev/null @@ -1,149 +0,0 @@ -# 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 -# -# http://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. -# -# SPDX-License-Identifier: Apache-2.0 - -"""Python-floor shim for the `genkit` package on PyPI. - -Real genkit releases require Python >= 3.10. On older interpreters -(like the Python 3.9 that macOS ships), pip either resolves nothing or -resolves an unrelated pre-transfer package that holds low version -numbers on PyPI. This sdist declares `Requires-Python: <3.10`, so -current interpreters can never select it, while old interpreters pick -it as their best candidate and get a clear how-to-upgrade message -instead of a resolver error. - -Publish as sdist ONLY (`uv build --sdist`). A wheel would install -"successfully" as an empty package on old Pythons, which is the silent -failure this shim exists to prevent. Version 0.3.0 was never published -(the history goes 0.3.0.dev2 -> 0.3.1), so the shim fills that hole: -above the pre-transfer squatter releases (<= 0.2.0), below every real -genkit release (>= 0.3.1). It never needs to change. -""" - -import sys - -MIN_PYTHON = (3, 10) - -# Fail at the build/install phase, not the metadata phase: old pip (e.g. the -# 21.2.4 bundled with macOS system Python) treats a metadata-build failure as -# a discardable candidate and backtracks to the pre-transfer 0.2.0 — the -# exact silent wrong-install this shim exists to prevent. An install-phase -# failure is fatal on every pip generation, so the user actually sees the -# message and nothing gets installed. -_METADATA_ONLY_COMMANDS = {'egg_info', 'dist_info', 'sdist'} - - -# Annotations here must stay plain builtin names: this function runs on -# whatever ancient interpreter the user has (the shim's whole audience), and -# subscripted generics like `tuple[int, ...]` evaluate at def time and raise -# TypeError before 3.9 — the user would get a traceback instead of the -# upgrade message. -def _format_error_message(min_ver: tuple, cur_ver: tuple) -> str: - min_str = '.'.join(map(str, min_ver)) - cur_str = '.'.join(map(str, cur_ver[:3])) - - if sys.platform == 'win32': - platform_hint = f'Windows requires Python {min_str}+ to run Genkit.' - recipes = ( - ' # Option 1 (Recommended): uv (manages Python versions automatically)\n' - ' powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"\n' - ' uv init && uv add genkit\n' - '\n' - f' # Option 2: Download Python (>= {min_str}) from https://www.python.org/downloads/\n' - ' python -m venv .venv && .venv\\Scripts\\pip install genkit' - ) - elif sys.platform == 'darwin': - platform_hint = ( - 'macOS ships an older Python at /usr/bin/python3.\n' - f'To use Genkit, install Python {min_str}+ using one of the options below:' - ) - recipes = ( - ' # Option 1 (Recommended): uv (manages Python for you)\n' - ' curl -LsSf https://astral.sh/uv/install.sh | sh\n' - ' uv init && uv add genkit\n' - '\n' - ' # Option 2: Homebrew\n' - ' brew install python\n' - ' python3 -m venv .venv && source .venv/bin/activate\n' - ' pip install genkit\n' - '\n' - ' # Option 3: Download installer from https://www.python.org/downloads/' - ) - else: - platform_hint = ( - f'Your system Python is older than the required Python {min_str}+.\n' - f'To use Genkit, install Python {min_str}+ using one of the options below:' - ) - recipes = ( - ' # Option 1 (Recommended): uv (standalone, no root required)\n' - ' curl -LsSf https://astral.sh/uv/install.sh | sh\n' - ' uv init && uv add genkit\n' - '\n' - ' # Option 2: System Package Manager\n' - ' sudo apt update && sudo apt install python3 python3-venv\n' - ' python3 -m venv .venv && source .venv/bin/activate\n' - ' pip install genkit\n' - '\n' - ' # Option 3: Download installer from https://www.python.org/downloads/' - ) - - return ( - '\n' - '========================================================================\n' - f'Genkit requires Python {min_str}+, but you are running Python {cur_str}.\n' - '\n' - f'{platform_hint}\n' - '\n' - f'{recipes}\n' - '\n' - 'Docs: https://genkit.dev/docs/python/get-started/\n' - '========================================================================\n' - ) - - -if sys.version_info < MIN_PYTHON and not _METADATA_ONLY_COMMANDS.intersection(sys.argv[1:]): - sys.exit(_format_error_message(MIN_PYTHON, sys.version_info)) - -# The shim must never ship as a wheel: wheels run no code at install time, -# so on an old Python a wheel would install "successfully" as an empty -# package — the exact silent failure this shim exists to prevent. Refusing -# here (after the version guard, so old interpreters still get the upgrade -# box) makes sdist-only self-enforcing instead of workflow-flag-dependent. -if 'bdist_wheel' in sys.argv[1:]: - sys.exit('The genkit floor shim is sdist-only; refusing to build a wheel. See floor-shim/README.md.') - -from setuptools import setup # noqa: E402 - -setup( - name='genkit', - version='0.3.0', - description=( - 'Genkit requires Python >= 3.10. This placeholder release exists only ' - 'to give older interpreters a clear upgrade message.' - ), - long_description=( - 'Genkit is an open-source framework for building AI-powered ' - 'applications, from Google. It requires Python 3.10 or newer. ' - 'This placeholder release exists only so that installs on older ' - 'Python versions fail with a clear message instead of a resolver ' - 'error. See https://genkit.dev/docs/python/get-started/' - ), - long_description_content_type='text/plain', - url='https://genkit.dev', - author='Google', - license='Apache-2.0', - python_requires='<3.10', - py_modules=[], -) diff --git a/genkit-tools/genkit-schema.json b/genkit-tools/genkit-schema.json deleted file mode 100644 index bc88ed311..000000000 --- a/genkit-tools/genkit-schema.json +++ /dev/null @@ -1,2514 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$defs": { - "AgentAbortRequest": { - "type": "object", - "properties": { - "snapshotId": { - "type": "string" - } - }, - "required": [ - "snapshotId" - ], - "additionalProperties": false - }, - "AgentAbortResponse": { - "type": "object", - "properties": { - "snapshotId": { - "type": "string" - }, - "status": { - "$ref": "#/$defs/SnapshotStatus" - } - }, - "required": [ - "snapshotId" - ], - "additionalProperties": false - }, - "AgentFinishReason": { - "type": "string", - "enum": [ - "stop", - "length", - "blocked", - "interrupted", - "other", - "unknown", - "aborted", - "detached", - "failed" - ] - }, - "AgentInit": { - "type": "object", - "properties": { - "sessionId": { - "type": "string" - }, - "snapshotId": { - "type": "string" - }, - "state": { - "$ref": "#/$defs/SessionState" - } - }, - "additionalProperties": false - }, - "AgentInput": { - "type": "object", - "properties": { - "detach": { - "type": "boolean" - }, - "message": { - "$ref": "#/$defs/Message" - }, - "resume": { - "type": "object", - "properties": { - "respond": { - "type": "array", - "items": { - "$ref": "#/$defs/ToolResponsePart" - } - }, - "restart": { - "type": "array", - "items": { - "$ref": "#/$defs/ToolRequestPart" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "AgentMetadata": { - "type": "object", - "properties": { - "stateManagement": { - "$ref": "#/$defs/AgentStateManagement" - }, - "abortable": { - "type": "boolean" - }, - "stateSchema": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "stateManagement", - "abortable" - ], - "additionalProperties": false - }, - "AgentOutput": { - "type": "object", - "properties": { - "sessionId": { - "type": "string" - }, - "snapshotId": { - "type": "string" - }, - "state": { - "$ref": "#/$defs/SessionState" - }, - "message": { - "$ref": "#/$defs/Message" - }, - "artifacts": { - "type": "array", - "items": { - "$ref": "#/$defs/Artifact" - } - }, - "finishReason": { - "$ref": "#/$defs/AgentFinishReason" - }, - "error": { - "$ref": "#/$defs/RuntimeError" - }, - "usage": { - "$ref": "#/$defs/GenerationUsage" - } - }, - "additionalProperties": false - }, - "AgentResult": { - "type": "object", - "properties": { - "message": { - "$ref": "#/$defs/Message" - }, - "artifacts": { - "type": "array", - "items": { - "$ref": "#/$defs/Artifact" - } - }, - "finishReason": { - "$ref": "#/$defs/AgentFinishReason" - } - }, - "additionalProperties": false - }, - "AgentStateManagement": { - "type": "string", - "enum": [ - "server", - "client" - ] - }, - "AgentStreamChunk": { - "type": "object", - "properties": { - "modelChunk": { - "$ref": "#/$defs/ModelResponseChunk" - }, - "customPatch": { - "$ref": "#/$defs/JsonPatch" - }, - "artifact": { - "$ref": "#/$defs/Artifact" - }, - "turnEnd": { - "$ref": "#/$defs/TurnEnd" - } - }, - "additionalProperties": false - }, - "Artifact": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "parts": { - "type": "array", - "items": { - "$ref": "#/$defs/Part" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "parts" - ], - "additionalProperties": false - }, - "GetSnapshotRequest": { - "type": "object", - "properties": { - "snapshotId": { - "type": "string" - }, - "sessionId": { - "type": "string" - }, - "metadataOnly": { - "type": "boolean" - } - }, - "additionalProperties": false - }, - "JsonPatchOp": { - "type": "string", - "enum": [ - "add", - "remove", - "replace", - "move", - "copy", - "test" - ] - }, - "JsonPatchOperation": { - "type": "object", - "properties": { - "op": { - "$ref": "#/$defs/JsonPatchOp" - }, - "path": { - "type": "string" - }, - "from": { - "type": "string" - }, - "value": {} - }, - "required": [ - "op", - "path" - ], - "additionalProperties": false - }, - "JsonPatch": { - "type": "array", - "items": { - "$ref": "#/$defs/JsonPatchOperation" - } - }, - "SessionSnapshot": { - "type": "object", - "properties": { - "snapshotId": { - "type": "string" - }, - "sessionId": { - "type": "string" - }, - "parentId": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "heartbeatAt": { - "type": "string" - }, - "status": { - "$ref": "#/$defs/SnapshotStatus" - }, - "finishReason": { - "$ref": "#/$defs/AgentFinishReason" - }, - "error": { - "$ref": "#/$defs/RuntimeError" - }, - "state": { - "$ref": "#/$defs/SessionState" - } - }, - "required": [ - "snapshotId", - "createdAt" - ], - "additionalProperties": false - }, - "SessionState": { - "type": "object", - "properties": { - "sessionId": { - "type": "string" - }, - "messages": { - "type": "array", - "items": { - "$ref": "#/$defs/Message" - } - }, - "custom": {}, - "artifacts": { - "type": "array", - "items": { - "$ref": "#/$defs/Artifact" - } - }, - "usage": { - "$ref": "#/$defs/GenerationUsage" - } - }, - "additionalProperties": false - }, - "SnapshotStatus": { - "type": "string", - "enum": [ - "pending", - "aborting", - "completed", - "aborted", - "failed", - "expired" - ] - }, - "TurnEnd": { - "type": "object", - "properties": { - "snapshotId": { - "type": "string" - }, - "finishReason": { - "$ref": "#/$defs/AgentFinishReason" - }, - "usage": { - "$ref": "#/$defs/GenerationUsage" - } - }, - "additionalProperties": false - }, - "DocumentData": { - "type": "object", - "properties": { - "content": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentPart" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "content" - ], - "additionalProperties": false - }, - "DocumentPart": { - "anyOf": [ - { - "$ref": "#/$defs/TextPart" - }, - { - "$ref": "#/$defs/MediaPart" - } - ] - }, - "EmbedRequest": { - "type": "object", - "properties": { - "input": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentData" - } - }, - "options": {} - }, - "required": [ - "input" - ], - "additionalProperties": false - }, - "EmbedResponse": { - "type": "object", - "properties": { - "embeddings": { - "type": "array", - "items": { - "$ref": "#/$defs/Embedding" - } - } - }, - "required": [ - "embeddings" - ], - "additionalProperties": false - }, - "Embedding": { - "type": "object", - "properties": { - "embedding": { - "type": "array", - "items": { - "type": "number" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "embedding" - ], - "additionalProperties": false - }, - "BaseDataPoint": { - "type": "object", - "properties": { - "input": {}, - "output": {}, - "context": { - "type": "array", - "items": {} - }, - "reference": {}, - "testCaseId": { - "type": "string" - }, - "traceIds": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "BaseEvalDataPoint": { - "type": "object", - "properties": { - "input": { - "$ref": "#/$defs/BaseDataPoint/properties/input" - }, - "output": { - "$ref": "#/$defs/BaseDataPoint/properties/output" - }, - "context": { - "$ref": "#/$defs/BaseDataPoint/properties/context" - }, - "reference": { - "$ref": "#/$defs/BaseDataPoint/properties/reference" - }, - "testCaseId": { - "type": "string" - }, - "traceIds": { - "$ref": "#/$defs/BaseDataPoint/properties/traceIds" - } - }, - "required": [ - "testCaseId" - ], - "additionalProperties": false - }, - "EvalFnResponse": { - "type": "object", - "properties": { - "sampleIndex": { - "type": "number" - }, - "testCaseId": { - "type": "string" - }, - "traceId": { - "type": "string" - }, - "spanId": { - "type": "string" - }, - "evaluation": { - "anyOf": [ - { - "$ref": "#/$defs/Score" - }, - { - "type": "array", - "items": { - "$ref": "#/$defs/Score" - } - } - ] - } - }, - "required": [ - "testCaseId", - "evaluation" - ], - "additionalProperties": false - }, - "EvalRequest": { - "type": "object", - "properties": { - "dataset": { - "type": "array", - "items": { - "$ref": "#/$defs/BaseDataPoint" - } - }, - "evalRunId": { - "type": "string" - }, - "options": {} - }, - "required": [ - "dataset", - "evalRunId" - ], - "additionalProperties": false - }, - "EvalResponse": { - "type": "array", - "items": { - "$ref": "#/$defs/EvalFnResponse" - } - }, - "EvalStatusEnum": { - "type": "string", - "enum": [ - "UNKNOWN", - "PASS", - "FAIL" - ] - }, - "Score": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "Optional ID to differentiate different scores" - }, - "score": { - "type": [ - "number", - "string", - "boolean" - ] - }, - "status": { - "$ref": "#/$defs/EvalStatusEnum" - }, - "error": { - "type": "string" - }, - "details": { - "type": "object", - "properties": { - "reasoning": { - "type": "string" - } - }, - "additionalProperties": true - } - }, - "additionalProperties": false - }, - "GenkitError": { - "type": "object", - "properties": { - "message": { - "type": "string" - }, - "stack": { - "type": "string" - }, - "details": {}, - "data": { - "type": "object", - "properties": { - "genkitErrorMessage": { - "type": "string" - }, - "genkitErrorDetails": { - "type": "object", - "properties": { - "stack": { - "type": "string" - }, - "traceId": { - "type": "string" - } - }, - "required": [ - "traceId" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - } - }, - "required": [ - "message" - ], - "additionalProperties": false - }, - "RuntimeError": { - "type": "object", - "properties": { - "status": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": {} - }, - "required": [ - "message" - ], - "additionalProperties": false - }, - "MiddlewareDesc": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "configSchema": { - "anyOf": [ - { - "type": "object", - "additionalProperties": {} - }, - { - "type": "null" - } - ] - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "MiddlewareRef": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "config": {} - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "CandidateError": { - "type": "object", - "properties": { - "index": { - "type": "number" - }, - "code": { - "type": "string", - "enum": [ - "blocked", - "other", - "unknown" - ] - }, - "message": { - "type": "string" - } - }, - "required": [ - "index", - "code" - ], - "additionalProperties": false - }, - "Candidate": { - "type": "object", - "properties": { - "index": { - "type": "number" - }, - "message": { - "$ref": "#/$defs/Message" - }, - "usage": { - "$ref": "#/$defs/GenerationUsage" - }, - "finishReason": { - "$ref": "#/$defs/FinishReason" - }, - "finishMessage": { - "type": "string" - }, - "custom": {} - }, - "required": [ - "index", - "message", - "finishReason" - ], - "additionalProperties": false - }, - "CustomPart": { - "type": "object", - "properties": { - "text": { - "not": {} - }, - "media": { - "not": {} - }, - "toolRequest": { - "not": {} - }, - "toolResponse": { - "not": {} - }, - "data": {}, - "metadata": { - "type": "object", - "additionalProperties": {} - }, - "custom": { - "type": "object", - "additionalProperties": {} - }, - "reasoning": { - "not": {} - }, - "resource": { - "not": {} - } - }, - "required": [ - "custom" - ], - "additionalProperties": false - }, - "DataPart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": {}, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "type": "object", - "additionalProperties": {} - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "additionalProperties": false - }, - "FinishReason": { - "type": "string", - "enum": [ - "stop", - "length", - "blocked", - "aborted", - "failed", - "interrupted", - "other", - "unknown" - ] - }, - "GenerateActionOptions": { - "type": "object", - "properties": { - "model": { - "type": "string" - }, - "docs": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentData" - } - }, - "messages": { - "type": "array", - "items": { - "$ref": "#/$defs/Message" - } - }, - "tools": { - "type": "array", - "items": { - "type": "string" - } - }, - "resources": { - "type": "array", - "items": { - "type": "string" - } - }, - "toolChoice": { - "type": "string", - "enum": [ - "auto", - "required", - "none" - ] - }, - "config": {}, - "output": { - "$ref": "#/$defs/GenerateActionOutputConfig" - }, - "resume": { - "type": "object", - "properties": { - "respond": { - "type": "array", - "items": { - "$ref": "#/$defs/ToolResponsePart" - } - }, - "restart": { - "type": "array", - "items": { - "$ref": "#/$defs/ToolRequestPart" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "additionalProperties": false - }, - "returnToolRequests": { - "type": "boolean" - }, - "maxTurns": { - "type": "number" - }, - "stepName": { - "type": "string" - }, - "use": { - "type": "array", - "items": { - "$ref": "#/$defs/MiddlewareRef" - } - } - }, - "required": [ - "messages" - ], - "additionalProperties": false - }, - "GenerateActionOutputConfig": { - "type": "object", - "properties": { - "format": { - "type": "string" - }, - "contentType": { - "type": "string" - }, - "instructions": { - "type": [ - "boolean", - "string" - ] - }, - "jsonSchema": {}, - "constrained": { - "type": "boolean" - } - }, - "additionalProperties": false - }, - "GenerateRequest": { - "type": "object", - "properties": { - "messages": { - "type": "array", - "items": { - "$ref": "#/$defs/Message" - } - }, - "config": {}, - "tools": { - "type": "array", - "items": { - "$ref": "#/$defs/ToolDefinition" - } - }, - "toolChoice": { - "type": "string", - "enum": [ - "auto", - "required", - "none" - ] - }, - "output": { - "$ref": "#/$defs/OutputConfig" - }, - "docs": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentData" - } - }, - "candidates": { - "type": "number" - } - }, - "required": [ - "messages" - ], - "additionalProperties": false - }, - "GenerateResponseChunk": { - "type": "object", - "properties": { - "role": { - "$ref": "#/$defs/Role" - }, - "index": { - "type": "number" - }, - "content": { - "type": "array", - "items": { - "$ref": "#/$defs/Part" - } - }, - "custom": {}, - "aggregated": { - "type": "boolean" - } - }, - "required": [ - "content" - ], - "additionalProperties": false - }, - "GenerateResponse": { - "type": "object", - "properties": { - "message": { - "$ref": "#/$defs/Message" - }, - "finishReason": { - "$ref": "#/$defs/FinishReason" - }, - "finishMessage": { - "type": "string" - }, - "error": { - "$ref": "#/$defs/RuntimeError" - }, - "latencyMs": { - "type": "number" - }, - "usage": { - "$ref": "#/$defs/GenerationUsage" - }, - "totalUsage": { - "$ref": "#/$defs/GenerationUsage" - }, - "custom": {}, - "raw": {}, - "request": { - "$ref": "#/$defs/GenerateRequest" - }, - "operation": { - "$ref": "#/$defs/Operation" - }, - "candidates": { - "type": "array", - "items": { - "$ref": "#/$defs/Candidate" - } - } - }, - "additionalProperties": false - }, - "GenerationCommonConfig": { - "type": "object", - "properties": { - "version": { - "type": "string", - "description": "A specific version of a model family, e.g. `gemini-2.5-flash` for the `googleai` family." - }, - "temperature": { - "type": "number", - "description": "Controls the degree of randomness in token selection. A lower value is good for a more predictable response. A higher value leads to more diverse or unexpected results." - }, - "maxOutputTokens": { - "type": "number", - "description": "The maximum number of tokens to include in the response." - }, - "topK": { - "type": "number", - "description": "The maximum number of tokens to consider when sampling." - }, - "topP": { - "type": "number", - "description": "Decides how many possible words to consider. A higher value means that the model looks at more possible words, even the less likely ones, which makes the generated text more diverse." - }, - "stopSequences": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Set of character sequences (up to 5) that will stop output generation." - }, - "apiKey": { - "type": "string", - "description": "API Key to use for the model call, overrides API key provided in plugin config." - } - }, - "additionalProperties": true - }, - "GenerationUsage": { - "type": "object", - "properties": { - "inputTokens": { - "type": "number" - }, - "outputTokens": { - "type": "number" - }, - "totalTokens": { - "type": "number" - }, - "inputCharacters": { - "type": "number" - }, - "outputCharacters": { - "type": "number" - }, - "inputImages": { - "type": "number" - }, - "outputImages": { - "type": "number" - }, - "inputVideos": { - "type": "number" - }, - "outputVideos": { - "type": "number" - }, - "inputAudioFiles": { - "type": "number" - }, - "outputAudioFiles": { - "type": "number" - }, - "custom": { - "type": "object", - "additionalProperties": { - "type": "number" - } - }, - "thoughtsTokens": { - "type": "number" - }, - "cachedContentTokens": { - "type": "number" - }, - "cacheWriteTokens": { - "type": "number" - } - }, - "additionalProperties": false - }, - "MediaPart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/Media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "required": [ - "media" - ], - "additionalProperties": false - }, - "Message": { - "type": "object", - "properties": { - "role": { - "$ref": "#/$defs/Role" - }, - "content": { - "type": "array", - "items": { - "$ref": "#/$defs/Part" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "role", - "content" - ], - "additionalProperties": false - }, - "ModelInfo": { - "type": "object", - "properties": { - "versions": { - "type": "array", - "items": { - "type": "string" - } - }, - "label": { - "type": "string" - }, - "configSchema": { - "type": "object", - "additionalProperties": {} - }, - "supports": { - "type": "object", - "properties": { - "multiturn": { - "type": "boolean" - }, - "media": { - "type": "boolean" - }, - "tools": { - "type": "boolean" - }, - "systemRole": { - "type": "boolean" - }, - "output": { - "type": "array", - "items": { - "type": "string" - } - }, - "contentType": { - "type": "array", - "items": { - "type": "string" - } - }, - "context": { - "type": "boolean" - }, - "constrained": { - "type": "string", - "enum": [ - "none", - "all", - "no-tools" - ] - }, - "toolChoice": { - "type": "boolean" - }, - "longRunning": { - "type": "boolean" - } - }, - "additionalProperties": false - }, - "stage": { - "type": "string", - "enum": [ - "featured", - "stable", - "unstable", - "legacy", - "deprecated" - ] - } - }, - "additionalProperties": false - }, - "ModelReference": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "config": {} - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "ModelRequest": { - "type": "object", - "properties": { - "messages": { - "$ref": "#/$defs/GenerateRequest/properties/messages" - }, - "config": { - "$ref": "#/$defs/GenerateRequest/properties/config" - }, - "tools": { - "$ref": "#/$defs/GenerateRequest/properties/tools" - }, - "toolChoice": { - "$ref": "#/$defs/GenerateRequest/properties/toolChoice" - }, - "output": { - "$ref": "#/$defs/GenerateRequest/properties/output" - }, - "docs": { - "$ref": "#/$defs/GenerateRequest/properties/docs" - } - }, - "required": [ - "messages" - ], - "additionalProperties": false - }, - "ModelResponseChunk": { - "type": "object", - "properties": { - "role": { - "$ref": "#/$defs/GenerateResponseChunk/properties/role" - }, - "index": { - "$ref": "#/$defs/GenerateResponseChunk/properties/index" - }, - "content": { - "$ref": "#/$defs/GenerateResponseChunk/properties/content" - }, - "custom": { - "$ref": "#/$defs/GenerateResponseChunk/properties/custom" - }, - "aggregated": { - "$ref": "#/$defs/GenerateResponseChunk/properties/aggregated" - } - }, - "required": [ - "content" - ], - "additionalProperties": false - }, - "ModelResponse": { - "type": "object", - "properties": { - "message": { - "$ref": "#/$defs/GenerateResponse/properties/message" - }, - "finishReason": { - "$ref": "#/$defs/FinishReason" - }, - "finishMessage": { - "$ref": "#/$defs/GenerateResponse/properties/finishMessage" - }, - "error": { - "$ref": "#/$defs/GenerateResponse/properties/error" - }, - "latencyMs": { - "$ref": "#/$defs/GenerateResponse/properties/latencyMs" - }, - "usage": { - "$ref": "#/$defs/GenerateResponse/properties/usage" - }, - "totalUsage": { - "$ref": "#/$defs/GenerateResponse/properties/totalUsage" - }, - "custom": { - "$ref": "#/$defs/GenerateResponse/properties/custom" - }, - "raw": { - "$ref": "#/$defs/GenerateResponse/properties/raw" - }, - "request": { - "$ref": "#/$defs/GenerateResponse/properties/request" - }, - "operation": { - "$ref": "#/$defs/GenerateResponse/properties/operation" - } - }, - "required": [ - "finishReason" - ], - "additionalProperties": false - }, - "MultipartToolResponse": { - "type": "object", - "properties": { - "output": {}, - "content": { - "type": "array", - "items": { - "$ref": "#/$defs/Part" - } - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "additionalProperties": false - }, - "Operation": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "id": { - "type": "string" - }, - "done": { - "type": "boolean" - }, - "output": {}, - "error": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "additionalProperties": true - }, - "metadata": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "id" - ], - "additionalProperties": false - }, - "OutputConfig": { - "type": "object", - "properties": { - "format": { - "type": "string" - }, - "schema": { - "type": "object", - "additionalProperties": {} - }, - "constrained": { - "type": "boolean" - }, - "contentType": { - "type": "string" - } - }, - "additionalProperties": false - }, - "Part": { - "anyOf": [ - { - "$ref": "#/$defs/TextPart" - }, - { - "$ref": "#/$defs/MediaPart" - }, - { - "$ref": "#/$defs/ToolRequestPart" - }, - { - "$ref": "#/$defs/ToolResponsePart" - }, - { - "$ref": "#/$defs/DataPart" - }, - { - "$ref": "#/$defs/CustomPart" - }, - { - "$ref": "#/$defs/ReasoningPart" - }, - { - "$ref": "#/$defs/ResourcePart" - } - ] - }, - "ReasoningPart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "type": "string" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "required": [ - "reasoning" - ], - "additionalProperties": false - }, - "ResourcePart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "type": "object", - "properties": { - "uri": { - "type": "string" - } - }, - "required": [ - "uri" - ], - "additionalProperties": false - } - }, - "required": [ - "resource" - ], - "additionalProperties": false - }, - "Role": { - "type": "string", - "enum": [ - "system", - "user", - "model", - "tool" - ] - }, - "TextPart": { - "type": "object", - "properties": { - "text": { - "type": "string" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "required": [ - "text" - ], - "additionalProperties": false - }, - "ToolDefinition": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "key": { - "type": "string" - }, - "description": { - "type": "string" - }, - "inputSchema": { - "anyOf": [ - { - "type": "object", - "additionalProperties": {}, - "description": "Valid JSON Schema representing the input of the tool." - }, - { - "type": "null" - } - ], - "description": "Valid JSON Schema representing the input of the tool." - }, - "outputSchema": { - "anyOf": [ - { - "type": "object", - "additionalProperties": {}, - "description": "Valid JSON Schema describing the output of the tool." - }, - { - "type": "null" - } - ], - "description": "Valid JSON Schema describing the output of the tool." - }, - "metadata": { - "type": "object", - "additionalProperties": {}, - "description": "additional metadata for this tool definition" - } - }, - "required": [ - "name", - "description" - ], - "additionalProperties": false - }, - "ToolRequestPart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/ToolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/CustomPart/properties/toolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "required": [ - "toolRequest" - ], - "additionalProperties": false - }, - "ToolResponsePart": { - "type": "object", - "properties": { - "text": { - "$ref": "#/$defs/CustomPart/properties/text" - }, - "media": { - "$ref": "#/$defs/CustomPart/properties/media" - }, - "toolRequest": { - "$ref": "#/$defs/CustomPart/properties/toolRequest" - }, - "toolResponse": { - "$ref": "#/$defs/ToolResponse" - }, - "data": { - "$ref": "#/$defs/CustomPart/properties/data" - }, - "metadata": { - "$ref": "#/$defs/CustomPart/properties/metadata" - }, - "custom": { - "$ref": "#/$defs/DataPart/properties/custom" - }, - "reasoning": { - "$ref": "#/$defs/CustomPart/properties/reasoning" - }, - "resource": { - "$ref": "#/$defs/CustomPart/properties/resource" - } - }, - "required": [ - "toolResponse" - ], - "additionalProperties": false - }, - "Media": { - "type": "object", - "properties": { - "contentType": { - "type": "string" - }, - "url": { - "type": "string" - } - }, - "required": [ - "url" - ], - "additionalProperties": false - }, - "ToolRequest": { - "type": "object", - "properties": { - "ref": { - "type": "string" - }, - "name": { - "type": "string" - }, - "input": {}, - "partial": { - "type": "boolean" - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "ToolResponse": { - "type": "object", - "properties": { - "ref": { - "type": "string" - }, - "name": { - "type": "string" - }, - "output": {}, - "content": { - "type": "array" - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "CommonRerankerOptions": { - "type": "object", - "properties": { - "k": { - "type": "number", - "description": "Number of documents to rerank" - } - }, - "additionalProperties": false - }, - "RankedDocumentData": { - "type": "object", - "properties": { - "content": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentPart" - } - }, - "metadata": { - "$ref": "#/$defs/RankedDocumentMetadata" - } - }, - "required": [ - "content", - "metadata" - ], - "additionalProperties": false - }, - "RankedDocumentMetadata": { - "type": "object", - "properties": { - "score": { - "type": "number" - } - }, - "required": [ - "score" - ], - "additionalProperties": true - }, - "RerankerRequest": { - "type": "object", - "properties": { - "query": { - "$ref": "#/$defs/DocumentData" - }, - "documents": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentData" - } - }, - "options": {} - }, - "required": [ - "query", - "documents" - ], - "additionalProperties": false - }, - "RerankerResponse": { - "type": "object", - "properties": { - "documents": { - "type": "array", - "items": { - "$ref": "#/$defs/RankedDocumentData" - } - } - }, - "required": [ - "documents" - ], - "additionalProperties": false - }, - "ActionMetadata": { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "actionType": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "inputSchema": {}, - "inputJsonSchema": { - "anyOf": [ - { - "type": "object", - "properties": {}, - "additionalProperties": false, - "description": "A JSON Schema Draft 7 (http://json-schema.org/draft-07/schema) object." - }, - { - "type": "null" - } - ], - "description": "A JSON Schema Draft 7 (http://json-schema.org/draft-07/schema) object." - }, - "outputSchema": {}, - "outputJsonSchema": { - "$ref": "#/$defs/ActionMetadata/properties/inputJsonSchema", - "description": "A JSON Schema Draft 7 (http://json-schema.org/draft-07/schema) object." - }, - "streamSchema": {}, - "metadata": { - "type": "object", - "additionalProperties": { - "anyOf": [ - { - "anyOf": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "integer", - "format": "int64" - }, - { - "type": "boolean" - }, - { - "type": "object", - "properties": {}, - "additionalProperties": true - } - ] - }, - { - "type": "array", - "items": { - "$ref": "#/$defs/ActionMetadata/properties/metadata/additionalProperties/anyOf/0" - } - } - ] - } - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "ReflectionCancelActionParams": { - "type": "object", - "properties": { - "traceId": { - "type": "string" - } - }, - "required": [ - "traceId" - ], - "additionalProperties": false - }, - "ReflectionCancelActionResponse": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "additionalProperties": false - }, - "ReflectionConfigureParams": { - "type": "object", - "properties": { - "telemetryServerUrl": { - "type": "string" - } - }, - "additionalProperties": false - }, - "ReflectionEndInputStreamParams": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - } - }, - "required": [ - "requestId" - ], - "additionalProperties": false - }, - "ReflectionListActionsResponse": { - "type": "object", - "properties": { - "actions": { - "type": "object", - "additionalProperties": { - "$ref": "#/$defs/ActionMetadata" - } - } - }, - "required": [ - "actions" - ], - "additionalProperties": false - }, - "ReflectionListValuesParams": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "required": [ - "type" - ], - "additionalProperties": false - }, - "ReflectionListValuesResponse": { - "type": "object", - "properties": { - "values": { - "type": "object", - "additionalProperties": {} - } - }, - "required": [ - "values" - ], - "additionalProperties": false - }, - "ReflectionRegisterParams": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "pid": { - "type": "number" - }, - "name": { - "type": "string" - }, - "genkitVersion": { - "type": "string" - }, - "reflectionApiSpecVersion": { - "type": "number" - }, - "envs": { - "type": "array", - "items": { - "type": "string" - } - }, - "secret": { - "type": "string" - } - }, - "required": [ - "id", - "pid" - ], - "additionalProperties": false - }, - "ReflectionRunActionParams": { - "type": "object", - "properties": { - "runtimeId": { - "type": "string", - "description": "ID of the Genkit runtime to run the action on. Typically $pid-$port." - }, - "key": { - "type": "string", - "description": "Action key that consists of the action type and ID." - }, - "input": { - "description": "An input with the type that this action expects." - }, - "init": { - "description": "Initialization parameters to establish long running session states." - }, - "context": { - "description": "Additional runtime context data (ex. auth context data)." - }, - "telemetryLabels": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Labels to be applied to telemetry data." - }, - "stream": { - "type": "boolean" - }, - "streamInput": { - "type": "boolean" - } - }, - "required": [ - "key" - ], - "additionalProperties": false - }, - "ReflectionRunActionStateParams": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - }, - "state": { - "type": "object", - "properties": { - "traceId": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "required": [ - "requestId" - ], - "additionalProperties": false - }, - "ReflectionSendInputStreamChunkParams": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - }, - "chunk": {} - }, - "required": [ - "requestId" - ], - "additionalProperties": false - }, - "ReflectionStreamChunkParams": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - }, - "chunk": {} - }, - "required": [ - "requestId" - ], - "additionalProperties": false - }, - "CommonRetrieverOptions": { - "type": "object", - "properties": { - "k": { - "type": "number", - "description": "Number of documents to retrieve" - } - }, - "additionalProperties": false - }, - "RetrieverRequest": { - "type": "object", - "properties": { - "query": { - "$ref": "#/$defs/DocumentData" - }, - "options": {} - }, - "required": [ - "query" - ], - "additionalProperties": false - }, - "RetrieverResponse": { - "type": "object", - "properties": { - "documents": { - "type": "array", - "items": { - "$ref": "#/$defs/DocumentData" - } - } - }, - "required": [ - "documents" - ], - "additionalProperties": false - }, - "InstrumentationLibrary": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "schemaUrl": { - "type": "string" - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "Link": { - "type": "object", - "properties": { - "context": { - "$ref": "#/$defs/SpanContext" - }, - "attributes": { - "type": "object", - "additionalProperties": {} - }, - "droppedAttributesCount": { - "type": "number" - } - }, - "additionalProperties": false - }, - "PathMetadata": { - "type": "object", - "properties": { - "path": { - "type": "string" - }, - "status": { - "type": "string" - }, - "error": { - "type": "string" - }, - "latency": { - "type": "number" - } - }, - "required": [ - "path", - "status", - "latency" - ], - "additionalProperties": false - }, - "SpanContext": { - "type": "object", - "properties": { - "traceId": { - "type": "string" - }, - "spanId": { - "type": "string" - }, - "isRemote": { - "type": "boolean" - }, - "traceFlags": { - "type": "number" - } - }, - "required": [ - "traceId", - "spanId", - "traceFlags" - ], - "additionalProperties": false - }, - "SpanData": { - "type": "object", - "properties": { - "spanId": { - "type": "string" - }, - "traceId": { - "type": "string" - }, - "parentSpanId": { - "type": "string" - }, - "startTime": { - "type": "number" - }, - "endTime": { - "type": "number" - }, - "attributes": { - "type": "object", - "additionalProperties": {} - }, - "displayName": { - "type": "string" - }, - "links": { - "type": "array", - "items": { - "$ref": "#/$defs/Link" - } - }, - "instrumentationLibrary": { - "$ref": "#/$defs/InstrumentationLibrary" - }, - "spanKind": { - "type": "string" - }, - "sameProcessAsParentSpan": { - "type": "object", - "properties": { - "value": { - "type": "boolean" - } - }, - "required": [ - "value" - ], - "additionalProperties": false - }, - "status": { - "$ref": "#/$defs/SpanStatus" - }, - "timeEvents": { - "type": "object", - "properties": { - "timeEvent": { - "type": "array", - "items": { - "$ref": "#/$defs/TimeEvent" - } - } - }, - "additionalProperties": false - }, - "truncated": { - "type": "boolean" - } - }, - "required": [ - "spanId", - "traceId", - "startTime", - "endTime", - "attributes", - "displayName", - "instrumentationLibrary", - "spanKind" - ], - "additionalProperties": false - }, - "SpanEndEvent": { - "type": "object", - "properties": { - "traceId": { - "type": "string" - }, - "span": { - "$ref": "#/$defs/SpanData" - }, - "type": { - "type": "string", - "const": "span_end" - } - }, - "required": [ - "traceId", - "span", - "type" - ], - "additionalProperties": false - }, - "SpanMetadata": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "state": { - "type": "string", - "enum": [ - "success", - "error" - ] - }, - "input": {}, - "output": {}, - "init": {}, - "isRoot": { - "type": "boolean" - }, - "metadata": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "path": { - "type": "string" - } - }, - "required": [ - "name" - ], - "additionalProperties": false - }, - "SpanStartEvent": { - "type": "object", - "properties": { - "traceId": { - "$ref": "#/$defs/SpanEndEvent/properties/traceId" - }, - "span": { - "$ref": "#/$defs/SpanData" - }, - "type": { - "type": "string", - "const": "span_start" - } - }, - "required": [ - "traceId", - "span", - "type" - ], - "additionalProperties": false - }, - "SpanStatus": { - "type": "object", - "properties": { - "code": { - "type": "number" - }, - "message": { - "type": "string" - } - }, - "required": [ - "code" - ], - "additionalProperties": false - }, - "SpantEventBase": { - "type": "object", - "properties": { - "traceId": { - "$ref": "#/$defs/SpanEndEvent/properties/traceId" - }, - "span": { - "$ref": "#/$defs/SpanData" - } - }, - "required": [ - "traceId", - "span" - ], - "additionalProperties": false - }, - "TimeEvent": { - "type": "object", - "properties": { - "time": { - "type": "number" - }, - "annotation": { - "type": "object", - "properties": { - "attributes": { - "type": "object", - "additionalProperties": {} - }, - "description": { - "type": "string" - } - }, - "required": [ - "attributes", - "description" - ], - "additionalProperties": false - } - }, - "required": [ - "time", - "annotation" - ], - "additionalProperties": false - }, - "TraceData": { - "type": "object", - "properties": { - "traceId": { - "type": "string" - }, - "displayName": { - "type": "string" - }, - "startTime": { - "type": "number", - "description": "trace start time in milliseconds since the epoch" - }, - "endTime": { - "type": "number", - "description": "end time in milliseconds since the epoch" - }, - "spans": { - "type": "object", - "additionalProperties": { - "$ref": "#/$defs/SpanData" - } - } - }, - "required": [ - "traceId", - "spans" - ], - "additionalProperties": false - }, - "TraceEvent": { - "anyOf": [ - { - "$ref": "#/$defs/SpanStartEvent" - }, - { - "$ref": "#/$defs/SpanEndEvent" - } - ] - }, - "TraceMetadata": { - "type": "object", - "properties": { - "featureName": { - "type": "string" - }, - "paths": { - "type": "array", - "uniqueItems": true, - "items": { - "$ref": "#/$defs/PathMetadata" - } - }, - "timestamp": { - "type": "number" - } - }, - "required": [ - "timestamp" - ], - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/packages/genkit-amazon-bedrock/README.md b/packages/genkit-amazon-bedrock/README.md index 7a6da5769..d408270e7 100644 --- a/packages/genkit-amazon-bedrock/README.md +++ b/packages/genkit-amazon-bedrock/README.md @@ -462,7 +462,7 @@ image bytes, so they are safe to leave on. ## Examples -See [`py/samples/amazon-bedrock-sample`](../../samples/amazon-bedrock-sample) +See [`samples/amazon-bedrock-sample`](../../samples/amazon-bedrock-sample) for a runnable `generate()` / `embed()` snippet. ## License diff --git a/packages/genkit-google-genai/README.md b/packages/genkit-google-genai/README.md index 93a38863b..04e78c1e6 100644 --- a/packages/genkit-google-genai/README.md +++ b/packages/genkit-google-genai/README.md @@ -348,7 +348,7 @@ print(operation.output.message.content[0].media.url) # => gs://my-bucket/videos/output.mp4 ``` -Runnable version: [google-genai-media](https://github.com/genkit-ai/genkit/tree/main/py/samples/google-genai-media). +Runnable version: [google-genai-media](https://github.com/genkit-ai/genkit-python/tree/main/samples/google-genai-media). ### Virtual Try-On (Vertex AI) @@ -384,4 +384,4 @@ for part in response.message.content: print(part.media.url) ``` -Runnable snippets are in [`py/samples`](../../samples). +Runnable snippets are in [`samples`](../../samples). diff --git a/packages/genkit-ollama/README.md b/packages/genkit-ollama/README.md index 6be969c54..085dfd9f8 100644 --- a/packages/genkit-ollama/README.md +++ b/packages/genkit-ollama/README.md @@ -55,7 +55,7 @@ print(len(embeddings[0].embedding)) These snippets assume an async context (`await` inside an `async def`); pasting them at module top level raises `SyntaxError: 'await' outside function`. See the -[runnable sample](https://github.com/genkit-ai/genkit/tree/main/py/samples/ollama-sample) +[runnable sample](https://github.com/genkit-ai/genkit-python/tree/main/samples/ollama-sample) for a complete `async def main()` plus `ai.run_main(...)` entry point. ### Streaming @@ -246,7 +246,7 @@ host. ## Sample -See [py/samples/ollama-sample](https://github.com/genkit-ai/genkit/tree/main/py/samples/ollama-sample) for a runnable sample covering +See [samples/ollama-sample](https://github.com/genkit-ai/genkit-python/tree/main/samples/ollama-sample) for a runnable sample covering chat, streaming, tool calling, and embeddings with a local Ollama server. ## Notes diff --git a/packages/genkit-otel/README.md b/packages/genkit-otel/README.md index 6b556c77c..1d6fe1cb4 100644 --- a/packages/genkit-otel/README.md +++ b/packages/genkit-otel/README.md @@ -1,6 +1,6 @@ # genkit-otel -OpenTelemetry instrumentation and backend for [Genkit](https://github.com/genkit-ai/genkit). +OpenTelemetry instrumentation and backend for [Genkit](https://github.com/genkit-ai/genkit-python). It provides `GenAiInstrumentation`: OpenTelemetry GenAI semantic-conventions instrumentation emitting `gen_ai.*` spans and metrics. diff --git a/packages/genkit/README.md b/packages/genkit/README.md index 7d8bd5d01..30c3631b6 100644 --- a/packages/genkit/README.md +++ b/packages/genkit/README.md @@ -1,6 +1,6 @@ # genkit -[![PyPI version](https://img.shields.io/pypi/v/genkit)](https://pypi.org/project/genkit/) [![Python versions](https://img.shields.io/pypi/pyversions/genkit)](https://pypi.org/project/genkit/) [![Downloads](https://img.shields.io/pypi/dm/genkit)](https://pypi.org/project/genkit/) [![License](https://img.shields.io/pypi/l/genkit)](https://github.com/genkit-ai/genkit/blob/main/LICENSE) +[![PyPI version](https://img.shields.io/pypi/v/genkit)](https://pypi.org/project/genkit/) [![Python versions](https://img.shields.io/pypi/pyversions/genkit)](https://pypi.org/project/genkit/) [![Downloads](https://img.shields.io/pypi/dm/genkit)](https://pypi.org/project/genkit/) [![License](https://img.shields.io/pypi/l/genkit)](https://github.com/genkit-ai/genkit-python/blob/main/LICENSE) Genkit is a Python SDK from Google. One API for generate, tools, structured output, and agents, plus a local Developer UI. diff --git a/packages/genkit/tests/genkit/core/nested_dump_test.py b/packages/genkit/tests/genkit/core/nested_dump_test.py index 0557080a9..e35e3aeba 100644 --- a/packages/genkit/tests/genkit/core/nested_dump_test.py +++ b/packages/genkit/tests/genkit/core/nested_dump_test.py @@ -19,6 +19,9 @@ from __future__ import annotations import json +import os +import tempfile +import urllib.request from pathlib import Path from typing import Any @@ -58,13 +61,35 @@ def _tool_request_message() -> Message: return Message(role='model', content=[Part.from_tool_request('lookup', {'q': 1}, ref='r1')]) -def _schema_def(name: str) -> dict[str, Any]: +def _find_schema() -> Path: + env_dir = os.environ.get('GENKIT_SPECS_DIR') + if env_dir: + cand = Path(env_dir) / 'genkit-schema.json' + if cand.is_file(): + return cand for parent in Path(__file__).resolve().parents: candidate = parent / 'genkit-tools' / 'genkit-schema.json' - if candidate.exists(): - schema = json.loads(candidate.read_text()) - return {**schema, '$ref': f'#/$defs/{name}'} - raise AssertionError('genkit-tools/genkit-schema.json not found') + if candidate.is_file(): + return candidate + sibling = parent.parent / 'genkit' / 'genkit-tools' / 'genkit-schema.json' + if sibling.is_file(): + return sibling + + cache_dir = Path(tempfile.gettempdir()) / 'genkit-specs' + cache_dir.mkdir(parents=True, exist_ok=True) + cached = cache_dir / 'genkit-schema.json' + if not cached.is_file(): + tmp_file = cache_dir / f'genkit-schema.{os.getpid()}.tmp' + url = 'https://raw.githubusercontent.com/genkit-ai/genkit/main/genkit-tools/genkit-schema.json' + urllib.request.urlretrieve(url, tmp_file) # noqa: S310 + os.replace(tmp_file, cached) + return cached + + +def _schema_def(name: str) -> dict[str, Any]: + schema_path = _find_schema() + schema = json.loads(schema_path.read_text(encoding='utf-8')) + return {**schema, '$ref': f'#/$defs/{name}'} def test_message_inside_user_model_dumps_same_as_top_level_message() -> None: diff --git a/packages/genkit/tests/genkit/docs_exports_test.py b/packages/genkit/tests/genkit/docs_exports_test.py index 5262af754..ca710228d 100644 --- a/packages/genkit/tests/genkit/docs_exports_test.py +++ b/packages/genkit/tests/genkit/docs_exports_test.py @@ -14,7 +14,7 @@ # # SPDX-License-Identifier: Apache-2.0 -"""Every export rendered by py/docs/index.md has a docstring griffe can see. +"""Every export rendered by docs/index.md has a docstring griffe can see. mkdocstrings skips members without a docstring (``show_if_no_docstring`` is off by default), so an undocumented export silently drops out of the API diff --git a/packages/genkit/tests/typecheck/get_logger_contract_test.py b/packages/genkit/tests/typecheck/get_logger_contract_test.py index 8c0c13761..96c65705f 100644 --- a/packages/genkit/tests/typecheck/get_logger_contract_test.py +++ b/packages/genkit/tests/typecheck/get_logger_contract_test.py @@ -22,7 +22,7 @@ suppressions. ``bind`` and structlog's async ``a*`` twins are outside the contract, so calling them must be a type error in all three. Each checker fails on an unneeded ignore here (pyright through the pragma above, pyrefly -and ty through py/pyproject.toml), so adding either to the protocol breaks CI. +and ty through pyproject.toml), so adding either to the protocol breaks CI. """ import logging diff --git a/pyproject.toml b/pyproject.toml index 02333159f..88700be78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -325,7 +325,7 @@ capitalize-enum-members = true disable-timestamp = true enable-version-header = true field-constraints = true -input = "../genkit-tools/genkit-schema.json" +input = "genkit-tools/genkit-schema.json" input-file-type = "jsonschema" output = "packages/genkit/src/genkit/_core/_typing.py" output-model-type = "pydantic_v2.BaseModel" diff --git a/samples/agents/README.md b/samples/agents/README.md index 7e15130d4..9c49e1df6 100644 --- a/samples/agents/README.md +++ b/samples/agents/README.md @@ -14,7 +14,7 @@ deploy, pass `FirestoreSessionStore()` from `genkit_google_cloud.exp` in the same slot. ```bash -cd py/samples/agents +cd samples/agents uv sync genkit start -- uv run basic/01_define_agent_with_store.py diff --git a/samples/agents/testapp/README.md b/samples/agents/testapp/README.md index f29e8e0b5..52092696e 100644 --- a/samples/agents/testapp/README.md +++ b/samples/agents/testapp/README.md @@ -6,7 +6,7 @@ Swap in `FirestoreSessionStore()` from `genkit_google_cloud.exp` when you deploy. ```bash -cd py/samples/agents +cd samples/agents uv sync genkit start -- uv run testapp/server.py ``` diff --git a/samples/mcp-hello/README.md b/samples/mcp-hello/README.md index f39a085d6..3bc13f88c 100644 --- a/samples/mcp-hello/README.md +++ b/samples/mcp-hello/README.md @@ -69,5 +69,5 @@ The tests drive the same wiring with a fake model, so they need no API key and no network, and they launch the real server: ```bash -uv run pytest samples/mcp-hello --no-cov # from py/ +uv run pytest samples/mcp-hello --no-cov ``` diff --git a/scripts/check_consistency.py b/scripts/check_consistency.py index 59eb409c8..2855dff4d 100755 --- a/scripts/check_consistency.py +++ b/scripts/check_consistency.py @@ -170,7 +170,7 @@ def _check_intra_repo_spec( def check_package(pkg_path: str, core_version: str) -> tuple[str, str, list[str]]: - """Validate a single publishable package directory under py/packages/*.""" + """Validate a single publishable package directory under packages/*.""" toml_path = os.path.join(pkg_path, 'pyproject.toml') data = load_pyproject(toml_path) project = cast(dict[str, object], data.get('project', {})) diff --git a/tests/conftest_test.py b/tests/conftest_test.py index f96f3a996..3a2444900 100644 --- a/tests/conftest_test.py +++ b/tests/conftest_test.py @@ -14,7 +14,7 @@ # # SPDX-License-Identifier: Apache-2.0 -"""Tests for workspace pytest hooks in py/conftest.py.""" +"""Tests for workspace pytest hooks in conftest.py.""" import argparse import bdb diff --git a/tests/floor_shim_guard_test.py b/tests/floor_shim_guard_test.py deleted file mode 100644 index 10512b907..000000000 --- a/tests/floor_shim_guard_test.py +++ /dev/null @@ -1,112 +0,0 @@ -# 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 -# -# http://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. -# -# SPDX-License-Identifier: Apache-2.0 - -"""Pins the floor shim's guards (py/floor-shim/setup.py). - -The shim's whole job happens inside two `sys.exit` guards. If either -disappears, nothing else in CI notices: on old pip the metadata phase -would fail instead of the install phase and pip backtracks to the -pre-transfer squatter package with exit 0, and a wheel build would -produce an artifact that installs silently as an empty package. These -tests execute the real setup.py with spoofed interpreter versions so -deleting or weakening a guard fails loudly here. -""" - -import ast -import sys -from pathlib import Path - -import pytest - -SHIM_SETUP = Path(__file__).resolve().parents[1] / 'floor-shim' / 'setup.py' - -OLD_PYTHON = (3, 9, 6, 'final', 0) -NEW_PYTHON = (3, 12, 0, 'final', 0) - - -def _run_shim_setup(monkeypatch, argv: list[str], version: tuple) -> list: - """Exec the real setup.py under a spoofed version/argv; return setup() calls.""" - calls: list = [] - monkeypatch.setattr(sys, 'argv', ['setup.py', *argv]) - monkeypatch.setattr(sys, 'version_info', version) - import setuptools - - monkeypatch.setattr(setuptools, 'setup', lambda **kwargs: calls.append(kwargs)) - exec(compile(SHIM_SETUP.read_text(), str(SHIM_SETUP), 'exec'), {'__name__': '__main__'}) # noqa: S102 - return calls - - -def test_old_python_install_exits_with_upgrade_message(monkeypatch) -> None: - with pytest.raises(SystemExit) as excinfo: - _run_shim_setup(monkeypatch, ['install'], OLD_PYTHON) - assert 'Genkit requires Python 3.10+' in str(excinfo.value) - - -def test_old_python_bdist_wheel_still_gets_upgrade_message(monkeypatch) -> None: - # Modern pip installs the sdist via build_wheel; the user must see the - # upgrade box, not the sdist-only refusal. - with pytest.raises(SystemExit) as excinfo: - _run_shim_setup(monkeypatch, ['bdist_wheel'], OLD_PYTHON) - assert 'Genkit requires Python 3.10+' in str(excinfo.value) - - -def test_old_python_metadata_commands_succeed(monkeypatch) -> None: - # Old pip backtracks past metadata failures to the pre-transfer squatter - # release, so egg_info must succeed and the failure must wait for the - # install phase. - for command in ('egg_info', 'dist_info', 'sdist'): - calls = _run_shim_setup(monkeypatch, [command], OLD_PYTHON) - assert len(calls) == 1, f'{command} must reach setup(), not exit' - - -def test_new_python_wheel_build_is_refused(monkeypatch) -> None: - # sdist-only is self-enforcing: even a plain `uv build` (no --sdist) on a - # current interpreter must not produce a wheel. - with pytest.raises(SystemExit) as excinfo: - _run_shim_setup(monkeypatch, ['bdist_wheel'], NEW_PYTHON) - assert 'sdist-only' in str(excinfo.value) - - -def test_new_python_sdist_build_succeeds(monkeypatch) -> None: - calls = _run_shim_setup(monkeypatch, ['sdist'], NEW_PYTHON) - assert len(calls) == 1 - assert calls[0]['version'] == '0.3.0' - assert calls[0]['python_requires'] == '<3.10' - - -def test_setup_py_annotations_stay_runtime_safe_on_old_pythons() -> None: - # setup.py executes on whatever ancient interpreter the user has — that - # is the shim's whole audience. Annotations evaluate at def time, and - # subscripted generics like `tuple[int, ...]` raise TypeError before 3.9, - # which would replace the upgrade message with a traceback. Plain builtin - # names (`tuple`, `str`) are fine everywhere. - tree = ast.parse(SHIM_SETUP.read_text()) - annotations: list[ast.expr] = [] - for node in ast.walk(tree): - if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): - args = node.args - for arg in (*args.posonlyargs, *args.args, *args.kwonlyargs): - if arg.annotation is not None: - annotations.append(arg.annotation) - if node.returns is not None: - annotations.append(node.returns) - elif isinstance(node, ast.AnnAssign): - annotations.append(node.annotation) - for annotation in annotations: - assert isinstance(annotation, ast.Name), ( - f'annotation {ast.unparse(annotation)!r} is not a plain name; ' - 'it would evaluate at def time and can crash Python < 3.9' - )