Litellm dev 01 01 2025 p3 (#7503)

* fix(utils.py): add new validate tool choice helper function

Prevents https://github.com/BerriAI/litellm/issues/7483

* fix(main.py): add tool choice validation on .completion()

prevents user error like - https://github.com/BerriAI/litellm/issues/7483

* fix(utils.py): fix return val of tool choice validation logic
This commit is contained in:
Krish Dholakia 2025-01-01 22:12:15 -08:00 committed by GitHub
parent 98cba7ba3f
commit b3611ace41
3 changed files with 51 additions and 0 deletions

View file

@ -88,6 +88,7 @@ from litellm.utils import (
supports_httpx_timeout,
token_counter,
validate_chat_completion_messages,
validate_chat_completion_tool_choice,
)
from ._logging import verbose_logger
@ -847,6 +848,8 @@ def completion( # type: ignore # noqa: PLR0915
raise ValueError("model param not passed in.")
# validate messages
messages = validate_chat_completion_messages(messages=messages)
# validate tool_choice
tool_choice = validate_chat_completion_tool_choice(tool_choice=tool_choice)
######### unpacking kwargs #####################
args = locals()
api_base = kwargs.get("api_base", None)