If the AI has made the decision to attack you, nothing can revert that decision. I tested this once in a game where I saw units coming my way like 5 turns in advance and indeed was attacked 5 turns later as expected. After the game, I used a .sav I had made a few turns before the DoW and tested various measures: gifting hard goods, gifting or trading resources, luxuries, gpt, signing RoP or MMP, and even signing a military alliance against a third party... All to no avail: inevitably, 5 turns later the sneak attack came, even when they were "gracious" towards me due to our successful joint war against a third party...