* Fix Gemini batch embedding for gemini-embedding-2* models The google-genai SDK treats embed_content(contents=[list_of_strings]) as a single multi-part document for gemini-embedding-2* models, silently returning exactly 1 embedding regardless of input count. This caused a zip(..., strict=True) ValueError in _process_batch. Wrap each text in genai_types.Content(parts=[genai_types.Part(text=...)]) so the SDK treats each string as a separate content item. This matches the workaround used by pydantic-ai (#4873) and graphiti (#1474). Upstream SDK issue: googleapis/python-genai#2523 Fixes plastic-labs/honcho#744 * test(embedding): live embedding coverage for every Gemini and OpenAI model Adds tests/live_llm/test_live_embeddings.py plus an env-driven embedding matrix alongside the existing LLM one. Covers single embed, batched embed, batch-vs-single alignment, chunk-to-id mapping, and the batch-split path. Only a live call catches the gemini-embedding-2* collapse: the SDK folds a list of bare strings into one document and returns a single embedding. Reverting the Content wrapping fails all four batch tests for gemini-embedding-2-preview and gemini-embedding-2 with the reported `zip() argument 2 is shorter than argument 1`, while gemini-embedding-001 and text-embedding-3-small stay green. Also makes the concatenation in the conclusions semantic-search validation message explicit, so the repo-wide basedpyright pre-push hook passes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(embedding): drop the preview twin from the default embedding matrix gemini-embedding-2 is the GA release of gemini-embedding-2-preview and behaves identically, so running both by default doubles the Gemini cost for no extra coverage. The preview stays reachable through LIVE_EMBEDDING_GEMINI_MODELS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Aakash Kattelu <aakash@plasticlabs.ai> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| README.md | ||
| __init__.py | ||
| conftest.py | ||
| embedding_matrix.py | ||
| model_matrix.py | ||
| test_live_anthropic.py | ||
| test_live_embeddings.py | ||
| test_live_gemini.py | ||
| test_live_openai.py | ||
| test_live_structured_output_unions.py | ||
| test_live_timeouts.py | ||
| test_live_tools_structured_output.py | ||
README.md
Live LLM Tests
These tests call real provider APIs and are disabled by default.
Run them with:
uv run pytest tests/live_llm -n 0 --live-llm --no-header -q
Required API key env vars:
LLM_ANTHROPIC_API_KEYLLM_OPENAI_API_KEYLLM_GEMINI_API_KEY
Model-family env vars:
LIVE_LLM_ANTHROPIC_45_PLUS_MODELSLIVE_LLM_OPENAI_GPT4_MODELSLIVE_LLM_OPENAI_GPT5_MODELSLIVE_LLM_OPENAI_OPENROUTER_NON_REASONING_MODELS(OpenAI-transport → OpenRouter-served non-reasoning models)LIVE_LLM_GEMINI_25_MODELSLIVE_LLM_GEMINI_30_MODELSLIVE_LLM_GEMINI_31_MODELS
Embedding-model env vars:
LIVE_EMBEDDING_GEMINI_MODELS(default:gemini-embedding-001,gemini-embedding-2; addgemini-embedding-2-previewto cover the preview twin)LIVE_EMBEDDING_OPENAI_MODELS(default:text-embedding-3-small)
Each model env var accepts a comma-separated list of bare model ids or provider-qualified ids.
Examples:
export LIVE_LLM_ANTHROPIC_45_PLUS_MODELS="claude-sonnet-4-5,claude-sonnet-4-6"
export LIVE_LLM_OPENAI_GPT4_MODELS="gpt-4.1"
export LIVE_LLM_OPENAI_GPT5_MODELS="gpt-5,gpt-5.4,gpt-5.4-mini"
export LIVE_LLM_OPENAI_OPENROUTER_NON_REASONING_MODELS="inception/mercury-2"
export LIVE_LLM_GEMINI_25_MODELS="gemini-2.5-flash,gemini-2.5-pro"
export LIVE_LLM_GEMINI_30_MODELS="gemini-3-flash-preview"
export LIVE_LLM_GEMINI_31_MODELS="gemini-3.1-pro-preview"
OpenRouter-routed models require additional env for the proxy endpoint:
export OPENROUTER_API_KEY="sk-or-v1-..."
# Per-feature config example:
# DERIVER_MODEL_CONFIG__TRANSPORT=openai
# DERIVER_MODEL_CONFIG__MODEL=inception/mercury-2
# DERIVER_MODEL_CONFIG__OVERRIDES__BASE_URL=https://openrouter.ai/api/v1
# DERIVER_MODEL_CONFIG__OVERRIDES__API_KEY_ENV=OPENROUTER_API_KEY
Coverage by provider:
- Anthropic: structured output path, prompt caching metrics, thinking blocks, multi-turn tool replay
- OpenAI GPT-4 class: structured outputs, prompt caching
- OpenAI GPT-5 class (incl. gpt-5.x point-releases): structured outputs, prompt caching,
reasoning_effort,max_completion_tokensrouting - OpenAI transport → OpenRouter non-reasoning models (e.g.
inception/mercury-2): non-chat / diffusion architectures must stay onmax_tokens, noreasoning_effort, tool-calling parameter-schema compatibility is the canary for exotic OR-served providers - Gemini 2.5/3.0 classes: structured outputs, cached-content reuse, thought signatures, multi-turn tool replay
- Gemini 3.1 class: thinking and tool replay coverage by default; structured-output/caching coverage should only be added once Google documents support for that path
- Embeddings (
test_live_embeddings.py): single embed, batched embed, batch-vs-single alignment, and chunk-to-id mapping for every configured embedding model.gemini-embedding-2*is the reason this exists — those models collapse a list of bare strings into one document (#745), and only a live call catches it