feat(switchyard-llm-client): add HTTP LLM client crate#79
Conversation
fcf75d3 to
de9ddbe
Compare
f524f3e to
30d8979
Compare
de9ddbe to
bb40d0f
Compare
|
@sir-merge-a-lot groom |
Previous updates (collapsed)🤖 sir-merge-a-lot Resolving conflicts🔄 sir-merge-a-lot is resolving conflicts on this MR. Detected 3 conflicting file(s) (REGENERATE). I'll update this comment with the result. This can take a couple of minutes. 🤖 sir-merge-a-lot Coding agent working🤖 sir-merge-a-lot handed a large conflict to its sandboxed coding agent. The LLM tier could not resolve 🤖 sir-merge-a-lot Coding agent could not resolve the conflict
Resolution ladder trace
|
30d8979 to
a3c4498
Compare
WalkthroughAdds the ChangesLLM Client Crate
Estimated code review effort: 4 (Complex) | ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/libsy-llm-client/README.md`:
- Around line 8-15: Rewrite all README examples to use the crate’s actual API:
import ModelConfig and TranslatingLlmClient from switchyard_llm_client,
construct the client with TranslatingLlmClient::new, and invoke
call_rewrite_model instead of the unsupported LlmModelClient, libsy_llm_client,
nested backend maps, call, formats_for, or aggregate interfaces. Remove the
unused LlmModelClient link definition while preserving the examples’ intended
behavior.
In `@crates/libsy-llm-client/src/backend.rs`:
- Around line 33-41: Replace the derived Debug implementation on
HttpBackendConfig with a manual implementation that preserves base_url and
extra_headers while rendering any present api_key as “[REDACTED]” rather than
its value. Keep Debug available for containing types such as Backend and
ModelConfig without exposing credentials.
In `@crates/libsy-llm-client/src/client.rs`:
- Around line 491-495: Replace the `.expect("buffered response")` calls in the
aggregate-response handling at crates/libsy-llm-client/src/client.rs lines
491-495 and 683-687 with explicit matching, asserting or handling the success
and failure cases directly in each test while preserving the existing successful
aggregate behavior.
- Around line 25-38: Update the header-filtering logic using RESERVED_HEADERS so
credential-bearing headers such as cookie and proxy-authorization are never
forwarded from caller metadata. Prefer an explicit allowlist for headers
eligible for forwarding; otherwise expand the denylist to cover all browser,
proxy, and authentication credential headers, and add tests covering the
forwarding policy.
In `@crates/libsy-llm-client/src/lib.rs`:
- Around line 14-19: Update the module-level documentation near the
dependency-boundary explanation to remove the speculative
future-refactor/project-management statement, while retaining the explanation of
the vendored context-overflow detection and crate dependencies.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5051dedb-431a-4206-b555-88a8b1b832ea
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (8)
Cargo.tomlcrates/libsy-llm-client/Cargo.tomlcrates/libsy-llm-client/README.mdcrates/libsy-llm-client/src/backend.rscrates/libsy-llm-client/src/client.rscrates/libsy-llm-client/src/error.rscrates/libsy-llm-client/src/lib.rscrates/libsy-llm-client/src/raw.rs
315e045 to
df5c8f2
Compare
Codex FindingsChecked all 6 findings, none were relevant here, although I can see why Codex thought they were. |
…eutral IR Signed-off-by: Greg Clark <grclark@nvidia.com>
- Update README to match new API - Make tests return Error instead of `unwrap` to match project rules. - Redact API key from Debug output Thanks Code Rabbit Assisted-by: Codex:GPT 5.6 Sol medium Signed-off-by: Graham King <grahamk@nvidia.com>
Move one dep to dev-dependencies, remove another. Signed-off-by: Graham King <grahamk@nvidia.com>
ae15075 to
4ec1acf
Compare
Summary
Adds
switchyard-llm-client— an HTTP LLM client that speaks Switchyard's neutral IRend-to-end, built on the protocol traits and translation helpers from the base branches. Main class is
TranslatingLlmClient, which implementsRoutedLlmClient(libsy).Backend(OpenAiChat / OpenAiResponses / Anthropic).switchyard-translation.reqwest::Client.switchyard_protocol::Response— buffered (LlmResponse::Agg) or streamed (LlmResponse::Stream) based on request.llm_request.stream.Changes
crates/libsy-llm-client/(packageswitchyard-llm-client):TranslatingLlmClient— maps a model API name (e.g. "openai/gpt-oss-20b", not "strong") + wire format to a per-modelBackend(built from a list ofModelConfigs), encodes the request, makes the HTTP call (auth + caller-header forwarding), and decodes the response — buffered JSON or SSE — back to the IR.RoutedLlmClient, so it can back alibsyLlmTargetdirectly.call_rewrite_model_raw(ctx, raw_http_request, http_headers, model, wire_format)— thewhole decode → call → encode path in one call, returning a buffered JSON body or an
unframed stream of wire events (
RawResponse); SSE framing stays a transport concern, sothe crate has no HTTP-server dependency.
Example usage
(thanks Claude!)
Summary by CodeRabbit