mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-24 22:09:56 +00:00
* fix(embeddings): keep prompt-management params out of embedding provider requests A deployment whose litellm_params carry cache_control_injection_points, knowledge_bases or vector_store_ids fails every embedding call against a strict provider, because embedding() forwarded those keys as provider params. Bedrock Titan rejects them with "extraneous key ... is not permitted" (#30314). Embeddings never run prompt-management hooks, so nothing consumes these params there. They are now excluded where embedding() builds provider params, and an explicit extra_body is still passed through Refs #30301 Co-authored-by: tsushanth <78000697+tsushanth@users.noreply.github.com> * fix(mcp): own the MCP handler keys and read fake_stream as a control completion() and embedding() already keep owned kwargs out of provider params, but skip_mcp_handler, mcp_handler_context and fake_stream were in no registry, so a caller that passed them sent them to the provider. Some OpenAI-compatible providers crashed with a TypeError before sending, others forwarded the field and failed on strict APIs The MCP keys now live in McpHandlerState. filter_internal_params builds its set from the same declaration instead of a separate hand-written list, and stays MCP-only because fallback callers pass the remaining kwargs back into acompletion fake_stream is a ControlOptions field next to stream_chunk_size. A value from a caller or a deployment is validated, carried in litellm_params and read by the HTTP and Converse handlers alongside the flag provider configs set internally, so it turns on fake streaming and never reaches the provider body Refs #30301 #30371 Co-authored-by: Chenglun Hu <chenglunhu@gmail.com> * test(providers): walk every chat and embedding route with internal params seeded The wire test covered six providers. This walks every chat and embedding route that can reach a local wire server, including each Bedrock route, Invoke family and Bedrock embedding family. Each call carries every LiteLLM-owned name a plain call can take, and the test fails if one of them, a prompt-management param on embeddings, any other owned name at the top level, or any top-level underscore key reaches the request body The seeds follow the registry. Every owned name is seeded or listed with the reason it can't be, so a new field fails until someone decides A provider without a route must either have a stated reason it can't reach the wire and send nothing to it, or raise LiteLLMUnknownProvider without sending. A provider that gains a handler fails until it is walked Routes the walk shows sending or rejecting max_retries are pytest.skip with a BUG reason, per tests/integration/AGENTS.md Closes #30301 * fix(bedrock): filter LiteLLM-internal params from invoke request bodies Carried over from #30398 by kimnamu and applied to current main, where the test file now lives under tests/unit Fixes #30371 * refactor(bedrock): check invoke params against the owned MCP names in one pass The invoke filter now reads MCP_HANDLER_KWARG_NAMES from the registry inside the existing comprehension, so it adds no rebind and no import of the untyped helper. Behavior and the regression test from #30398 are unchanged * test(providers): walk the providers and owned names that landed on main Main added the opencode_go, coralbricks, openinfer, databricks_agent and inferenceapis chat providers and the aws_bedrock_control_plane_endpoint, kubernetes_pod_discovery and _encrypted_content_affinity_pinned owned names, so the wire walk now covers them too * test(providers): walk the providers and owned names that landed on main Main added the bigmodel, aiand, abliteration, empiriolabs, kyma, refuseless, hostinger_router, clf_ai_gateway, zerogpu, streamlake and wally chat providers, the empiriolabs and hostinger_router embedding routes, and the rpd, tpd, daily_reset_time, switchyard_router_config and thought_signature_in_tool_call_id owned names. chatgpt now sends with a plain api_key, so the walk covers it as a chat route instead of keeping it off the wire * style(tests): match main's formatting in the Bedrock Converse handler tests The file now differs from main only by the caller fake_stream test and its imports * fix(main): bound a caller or deployment fake_stream by the request timeout completion() picks the faked-stream timeout by asking _completion_fakes_stream, which only looked at optional_params. A caller's or deployment's fake_stream lives in the stored control options instead, so a faked stream was bounded by the short stream_timeout alone and a slow non-streamed answer timed out. The check now also reads control_options.fake_stream, which covers the first attempt and the Bedrock native output retry * fix: drop only the invalid control option under drop_params A bad stream_chunk_size under drop_params reset every control option, so a valid fake_stream was lost and the stream went upstream for real. Keep each option that validates on its own instead. Also annotate the new Bedrock locals and tests with Final and return types. * fix: replay fake_stream as a stream on every chat route completion() now makes one plain provider call when a caller or deployment sets fake_stream and replays the answer as a stream, so OpenAI, Anthropic and every other chat handler honor it instead of streaming live with the faked stream timeout. The replayed chunks keep the answer's own model name fake_stream accepts only true or false, as a bool or a string, so values like "yes", 1 or 1.0 get the invalid control option 400 instead of turning it on filter_internal_params takes a typed Mapping and the Converse handler reads stream as a bool * fix: keep token logprobs on a replayed fake stream The replayed chunk now carries each choice's logprobs from the plain answer, so a fake_stream request with logprobs gets the same token probabilities a live stream returned * fix: keep provider headers, service tier and fingerprint on a replayed fake stream The replayed stream now carries the plain answer's provider response headers, so the proxy still returns llm_provider-* and x-ratelimit-* headers with fake_stream Replayed chunks keep the answer's service_tier and system_fingerprint Image generation and image edit drop deployment prompt-management params like cache_control_injection_points, which Bedrock rejected as an invalid field * fix: replay a text completion answer when fake_stream is set text_completion, atext_completion and the Codestral completion route returned a raw TextCompletionResponse from the plain call, so the replay crashed with "'coroutine' object is not iterable" or an async-for error after the provider answered. The replay now turns that answer into a chat answer first and streams it like the other routes * fix: keep every answer when a text completion stream holds several choices A text completion stream converted only the first choice of each chunk, so a fake_stream replay with n=2 lost the second answer. Each chunk now converts every choice it carries --------- Co-authored-by: tsushanth <78000697+tsushanth@users.noreply.github.com> Co-authored-by: Chenglun Hu <chenglunhu@gmail.com> Co-authored-by: kimnamu <jihoon.lucas.kim@gmail.com> Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| request_payloads | ||
| __init__.py | ||
| test_image_edit.py | ||
| test_image_edit_extra_params.py | ||
| test_image_edit_utils.py | ||
| test_image_generation_extra_headers.py | ||
| test_main.py | ||