def test_prepare_chat_with_tools_tool_required():
    """Test that tool_required is correctly passed to the API request when True."""
    llm = LiteLLM(model="gpt-3.5-turbo")

    # Test with tool_required=True
    result = llm._prepare_chat_with_tools(tools=[search_tool], tool_required=True)

    assert result["tool_choice"] == "required"
    assert len(result["tools"]) == 1
    assert result["tools"][0]["function"]["name"] == "search_tool"
Test that tool_required is correctly passed to the API request when True.
llama-index-integrations/llms/llama-index-llms-litellm/tests/test_llms_litellm.py