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>
|
||
|---|---|---|
| .. | ||
| azure_client_usage_test.py | ||
| ban_constant_numbers.py | ||
| ban_copy_deepcopy_kwargs.py | ||
| bedrock_pricing.py | ||
| callback_manager_test.py | ||
| check_data_replace_usage.py | ||
| check_e2e_no_raw_requests.py | ||
| check_endpoint_coverage.py | ||
| check_fastuuid_usage.py | ||
| check_get_model_cost_key_performance.py | ||
| check_guardrail_apply_decorator.py | ||
| check_licenses.py | ||
| check_migrations_lock_timeout.py | ||
| check_migrations_no_data_rewrites.py | ||
| check_no_none_string_error_fields.py | ||
| check_no_publicly_known_master_key.py | ||
| check_prisma_binary_cache.py | ||
| check_provider_folders_documented.py | ||
| check_py310_typing_imports.py | ||
| check_spanattributes_value_usage.py | ||
| check_telemetry_imports.py | ||
| check_unbounded_in_lists.py | ||
| check_unsafe_enterprise_import.py | ||
| check_workflow_job_name_collisions.py | ||
| check_workflow_startup_safety.py | ||
| code_qa_check_tests.py | ||
| dependency_license_cache.json | ||
| enforce_llms_folder_style.py | ||
| ensure_async_clients_test.py | ||
| info_log_check.py | ||
| liccheck.ini | ||
| license_cache.json | ||
| litellm_logging_code_coverage.py | ||
| log.txt | ||
| memory_test.py | ||
| prevent_key_leaks_in_exceptions.py | ||
| recursive_detector.py | ||
| router_code_coverage.py | ||
| router_enforce_line_length.py | ||
| router_litellm_globals_check.py | ||
| router_surface_allowlist.json | ||
| router_surface_check.py | ||
| test_aio_http_image_conversion.py | ||
| test_ban_set_verbose.py | ||
| test_chat_completion_imports.py | ||
| test_check_no_none_string_error_fields.py | ||
| test_check_no_publicly_known_master_key.py | ||
| test_e2e_idp_stack.py | ||
| test_e2e_junit_report.py | ||
| test_e2e_metadata.py | ||
| test_generate_provider_endpoints_support.py | ||
| test_merge_smoke.py | ||
| test_no_hardcoded_secrets.py | ||
| test_provider_cache.py | ||
| test_provider_replay_harness.py | ||
| test_proxy_types_import.py | ||
| test_router_strategy_async.py | ||
| test_unit_passed_gate.py | ||
| test_workflow_job_name_collisions.py | ||
| unbounded_in_baseline.txt | ||