feat(translation): prepare requests for routed targets - #455
Conversation
9524bbc to
7f74985
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe translation crate exposes request preparation for target models and optional prompts. It patches preserved OpenAI Chat, OpenAI Responses, and Anthropic bodies, handles custom formats, restores preservation metadata, and adds cross-format and safety tests. ChangesRequest preparation
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The translation change is localized and preserves provider request fields while applying routed target metadata and prompts. No actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
7f74985 to
55d2a22
Compare
|
Tracking issue: #496 |
Signed-off-by: Alex Fournier <afournier@nvidia.com>
55d2a22 to
3e63c46
Compare
Summary
Adds one translation-layer helper for preparing a normalized request for a routed target.
This is part 1 of 3 for #496 / SWITCH-1253. It adds the provider-aware operation used by libsy in #463; it does not change router behavior or TOML configuration by itself.
Problem
A decoded request can contain both:
Changing only the normalized
modelis unsafe: exact replay can still send the route alias instead of the selected upstream model.Behavior
modelin preserved OpenAI Chat, OpenAI Responses, and Anthropic Messages bodies, retaining their provider-only fields.The prompt path intentionally re-encodes from the normalized request; it does not retain or patch a second provider-body copy.
API impact
This PR adds the public Rust function
switchyard_translation::prepare_request_for_target(...). It does not change Python APIs, server APIs, router construction, or the TOML schema.Suggested review
Unique change: one signed commit,
3e63c460(3 files, +123/-5).Validation
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceuv run ruff check .uv run mypy switchyarduv run pytest tests/ -v -m "not integration"(113 passed)Stack
targets.*.system_prompt, compatibility, and integration coverage