mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
3.2 KiB
3.2 KiB
- Target invariants, not completion claims
- Keep this crate the legacy
@clientwrapper as the native call sees it, and nothing else: theLoggingcontract (function_setup, the deployment hooks,pre_call/post_call, the sync and async success and failure fan-out, the deferred proxy release, the argument sharing those callbacks rely on) plus the kwargs rewrites the wrapper makes on the way in (credential-name inheritance, the budget and retry-count limits)- The driver in
litellm-host-python, the routes and core see onePythonLifecycle; they never learn which Python objects consume a call
- The driver in
- Rust drives the call; every litellm Python internal it still borrows is a variant of
LegacyPython, grouped by subsystem (Wrapper,Logging,DeploymentHooks)- The enum only shrinks: when Rust owns a subsystem, delete its group rather than adding a Rust path beside it
- Calling a user's own callback directly is permanent Python surface and gets its own type outside
LegacyPython PublicCallis the caller's call asLoggingsees it: the positional arguments, the keyword view as the legacy path rewrites it (setup, deployment hook, prepare) and the bound request object whose attributes back keywords the caller omitted; routes hand it over throughrun_legacy_calland keep no copy
setupreuses aLoggingthe caller passed aslitellm_logging_obj(the proxy and Router are the live cases) and otherwise builds one throughfunction_setup, as@clientdoes- Either way every phase calls the same
Loggingmethod the Python path calls; which callbacks run isLogging's decision, never this crate's
- Either way every phase calls the same
- Callbacks receive the caller's own objects and may mutate them; this crate alone carries that obligation
- Retain complete boundary arguments, opaque unknown values, aliases, omitted/default distinctions and deliberate copies; preserve the established deployment-hook kwargs view
- Before
pre_call, re-alias every body key whose value equals the caller's argument to the caller's own object; this crate compares the two itself, and the argument is resolved bylitellm_host_python::lookup - Retain independently captured body/header roots from
pre_calltopost_call; in-place mutation reaches the wire, envelope field replacement is visible to later callbacks only - A later kind of callback host (WASM, in-process Rust) has none of these obligations, so they stay out of
litellm-host,litellm-host-pythonand the bridge; the only fact that crosses from the route is the prepared keyword view
- Success and failure handlers receive the exact selected public response or exception; logging projections, redaction and snapshots keep their own copy contracts
- Ordinary failure-handler errors cannot suppress the other eligible family or replace the mapped provider error; a cancellation ends the call with no further dispatch
- Dispatch errors never replay provider work or trigger the opposite outcome; the proxy's acceptance or rejection releases deferred success at most once
- Delivery follows the registry, not the callable's type: direct, awaited, executor-submitted, logging-worker and deferred paths stay distinct
- Traverse every retained Python edge;
closeis idempotent and restores the correlation context once