Skip to content

feat(python-sdk): add MediaRouter for prefix-based provider dispatch (#463)#474

Merged
santoshkumarradha merged 1 commit intodev/add-videofrom
feat/463-media-router
Apr 18, 2026
Merged

feat(python-sdk): add MediaRouter for prefix-based provider dispatch (#463)#474
santoshkumarradha merged 1 commit intodev/add-videofrom
feat/463-media-router

Conversation

@santoshkumarradha
Copy link
Copy Markdown
Member

Summary

  • New MediaRouter class in media_router.py — prefix-based provider dispatch, longest-match-first
  • Lazy _media_router property in AgentAI registers fal/openrouter/litellm providers
  • Refactored ai_with_vision(), ai_with_audio(), ai_generate_video() to use router instead of if/elif chains
  • Unit tests for router resolution logic

Architecture

router.register("fal-ai/", fal_provider)
router.register("openrouter/", openrouter_provider)  
router.register("", litellm_provider)  # catch-all

provider = router.resolve("openrouter/google/veo-3.1", "video")

Test plan

  • MediaRouter unit tests (prefix matching, fallback, unsupported raises)
  • Full test suite passes
  • Ruff clean

Closes #463

…463)

- New MediaRouter class in media_router.py with longest-prefix-first matching
- Lazy _media_router property in AgentAI with fal/openrouter/litellm providers
- Refactored ai_with_vision(), ai_with_audio(), ai_generate_video() to use router
- Updated tests for new routing pattern
@santoshkumarradha santoshkumarradha self-assigned this Apr 18, 2026
@santoshkumarradha santoshkumarradha requested review from a team and AbirAbbas as code owners April 18, 2026 09:30
@github-actions
Copy link
Copy Markdown
Contributor

Performance

SDK Memory Δ Latency Δ Tests Status
Python 7.9 KB -13% 0.33 µs -6%

✓ No regressions detected

@github-actions
Copy link
Copy Markdown
Contributor

📊 Coverage gate

Thresholds from .coverage-gate.toml: per-surface ≥ 86%, aggregate ≥ 88%, max per-surface regression ≤ 1.0 pp, max aggregate regression ≤ 0.50 pp.

Surface Current Baseline Δ
control-plane 87.30% 87.30% → +0.00 pp 🟡
sdk-go 90.70% 90.70% → +0.00 pp 🟢
sdk-python 93.63% 93.63% ↑ +0.00 pp 🟢
sdk-typescript 92.56% 92.56% → +0.00 pp 🟢
web-ui 90.02% 90.01% ↑ +0.01 pp 🟢
aggregate 89.02% 89.01% ↑ +0.01 pp 🟡

✅ Gate passed

No surface regressed past the allowed threshold and the aggregate stayed above the floor.

@github-actions
Copy link
Copy Markdown
Contributor

📐 Patch coverage gate

Threshold: 80% on lines this PR touches vs origin/main (from .coverage-gate.toml:thresholds.min_patch).

Surface Touched lines Patch coverage Status
control-plane 0 ➖ no changes
sdk-go 0 ➖ no changes
sdk-python 0 ➖ no changes
sdk-typescript 0 ➖ no changes
web-ui 0 ➖ no changes

✅ Patch gate passed

Every surface whose lines were touched by this PR has patch coverage at or above the threshold.

@santoshkumarradha santoshkumarradha merged commit 6060c5d into dev/add-video Apr 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant