def mock_litellm_completion(tools_mock):
    """Context manager to patch litellm.completion with a mock response."""
    mock_response = MagicMock()
    mock_response.choices[0].message.tool_calls = tools_mock
    with patch("litellm.completion", return_value=mock_response):
        yield mock_response
Context manager to patch litellm.completion with a mock response.
ai/integrations/litellm/tests/test_litellm_toolkit.py