def test_get_tool_calls_from_response_actual_data(dashscope_llm):
    """Test get_tool_calls_from_response correctly extracts tool calls from a ChatResponse."""
    additional_kwargs = {
        "tool_calls": [
            {
                "index": 0,
                "id": "call_function_id",
                "type": "function",
                "function": {
                    "name": "get_current_weather",
                    "arguments": '{"location":"location"}',
                },
            }
        ]
    }

    chat_message = ChatMessage(
        role=MessageRole.ASSISTANT.value,
        content="",
        additional_kwargs=additional_kwargs,
    )

    chat_response = ChatResponse(message=chat_message, delta="", raw=None)

    tool_selections = dashscope_llm.get_tool_calls_from_response(chat_response)

    assert len(tool_selections) == 1

    selection = tool_selections[0]
    assert selection.tool_id == "call_function_id"
    assert selection.tool_name == "get_current_weather"
    assert selection.tool_kwargs == {"location": "location"}
Test get_tool_calls_from_response correctly extracts tool calls from a ChatResponse.
llama-index-integrations/llms/llama-index-llms-dashscope/tests/test_dashscope.py