def update_tool_calls(tool_calls: list, tool_calls_update: list):
    """
    Use the tool_calls_update objects received from stream chunks
    to update the running tool_calls object.
    """
    if tool_calls_update is None:
        return tool_calls

    tc_delta = tool_calls_update[0]

    if len(tool_calls) == 0:
        tool_calls.append(tc_delta)
    else:
        t = tool_calls[-1]
        if t["index"] != tc_delta["index"]:
            tool_calls.append(tc_delta)
        else:
            t["function"]["arguments"] += tc_delta["function"]["arguments"] or ""
            t["function"]["name"] += tc_delta["function"]["name"] or ""

    return tool_calls

    Use the tool_calls_update objects received from stream chunks
    to update the running tool_calls object.
    
llama-index-integrations/llms/llama-index-llms-ibm/llama_index/llms/ibm/utils.py