mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(cohere): map tool_choice, reasoning_effort and json_schema response_format on the v2 chat route
get_optional_params pinned cohere and cohere_chat to the v1 param mapper, so the v2 mapper never ran. The v2 mapper now maps tool_choice none/required, reasoning_effort to thinking, and json_schema response_format to Cohere's json_object with the schema. Values Cohere cannot take drop under drop_params and answer 400 otherwise. The cost map no longer claims command-a-plus-05-2026 supports tool_choice.
* fix(cohere): keep the schema on Cohere's native json_object response_format
A {"type": "json_object", "json_schema": ...} request is Cohere's own structured output shape, so the mapping now forwards its json_schema instead of keeping only the type
* fix(cohere): drop response_format beside tools under drop_params and mark 08-2024 Command R without tool_choice
Cohere documents response_format with tools or documents as unsupported, and command-r-08-2024 and command-r-plus-08-2024 answer 422 to it, so drop_params now drops it there. Those two models also accept tool_choice but ignore it, so the cost map marks them supports_tool_choice false
* fix(cohere): gate JSON output per model, cap thinking at max_tokens, and list every served Cohere chat model
* fix(cohere): honor allowed_openai_params and deployment model_info, and force a named sole tool
The drop-or-400 checks for tool_choice, reasoning_effort and response_format now run when the request is built, so a param in allowed_openai_params goes to Cohere as sent and a deployment's model_info or base_model unlocks it on both cohere_chat/<model> and cohere_chat/v2/<model>. A named function that is the only tool maps to REQUIRED. response_format beside tools or documents is checked per model, only the two 08-2024 Command R models rejecting it
* fix(cohere): warn when drop_params drops a param and send a mapped reasoning_effort as thinking only
Each tool_choice, reasoning_effort or response_format value that drop_params drops now logs a warning naming the param, model and reason. A reasoning_effort LiteLLM translates to Cohere thinking is no longer also sent raw when allowed_openai_params lists it, since Cohere rejects that field
* fix(cohere): list response_format only for Cohere models with JSON mode
The v2 config listed response_format for every Cohere model, so router
pre-call checks kept Aya, tiny-aya and North deployments as candidates for
JSON requests, and /model_group/info said they took it. It is now listed only
where the cost map marks supports_response_schema, the same way
reasoning_effort is gated, and model_info or base_model can still turn it on.
* fix(cohere): keep response_format contents out of the drop warning and the 400
A dropped response_format now logs only its type, and the 400 for an unknown type or a model without JSON mode no longer repeats the value, since a schema can hold the caller's data
* fix(cohere): leave out tool_choice without tools, check json_schema keywords Cohere rejects, use Cohere's context lengths
A tool_choice sent with no tools is left out again, as it was before this PR, instead of answering 400
A json_schema using a keyword or pattern Cohere rejects (minimum, allOf, minItems, an anchored pattern, and others) drops under drop_params, else answers 400 naming it
tool_choice support now follows a model registered after the first request, and error messages shorten long values
The new and touched Cohere cost-map rows take max_input_tokens from Cohere's models API context_length, so pre-call checks no longer refuse prompts Cohere accepts
An unreachable response_format branch is removed, since get_supported_openai_params already leaves response_format out for those models
* fix(cohere): read model_info on cohere/ deployments and stop the schema keyword check 64 levels deep
A cohere/ deployment of a model the cost map does not list ignored its model_info supports_tool_choice,
since the capability lookup only asked for the cohere_chat provider. A json_schema nested about 300 levels
deep hit the recursion limit and answered 500. Deeper levels now go to Cohere unchecked.
* fix(cohere): drop or reject a json_schema nested past the 64-level check
A schema deeper than the keyword check now drops under drop_params and
otherwise answers 400, as every schema did before this PR, so a keyword
past level 64 no longer reaches Cohere and fails under drop_params
* fix(cohere): read a string allowed_openai_params with the shared helper
* test(cohere): compare the whole request body Cohere gets in the v2 param tests
* fix(cohere): check only the schema parts Cohere validates and refuse list-form items
Cohere validates properties, anyOf and a single items schema, but not prefixItems or additionalProperties, so a keyword there no longer turns into a 400. A list in items, which Cohere refuses, now drops under drop_params or answers 400
---------
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| chat | ||
| embed | ||
| rerank | ||
| __init__.py | ||
| test_cohere_common_utils.py | ||