ok I generally only gift in OCC.Not because I am a nice guy or am concerned about my neighbors or anything.I do it to avoid a science penalty or to gain back the penalty.Pure selfishness
Cues?..well its never set in stone they will gift but you want them enthusiastic in attitude..at least.Usually need it for map trades also.Tech trades will occur in neutral and up.I have had some rare exceptions but a good general set of rules.
Alliances are a liitle tougher.Anywhere from receptive>worshipful.Alot of times,alliances are very one sided.The AI gifts nothing.Reason-who knows

.Other times the AI are incredibly generous.I've seen them completely empty their treasuries for me.
This varies abit between MGE and 2.42 but its basically the same.
In MGE they always get attitudes reset.So the idea is to have enough techs to gift to bring them from hostile to enthusiatic or better.3 or 4 techs is usually enough.Then ask for maps,alliances or gifts.Another thing that is important in MGE is when you contact,try to have as little gold as possible.Especially when you are at war.If not they always demand gold for a ceasefire.You want them to demand tech.
So don't deliver a caravan and then contact.Contact first or spend the money prior to contacting.
Your best bet for gifts is fairly early.Once you get rolling they are a little less generous.Not always though

..I've gotten some of my biggest gifts late game.
Marco's-
Lets say you have Trade.You check your embassys and see 3 others researching Trade.If you gift Trade to those civs, they pick a new advance to research but do not loose accumilated beakers.
Now you check your embassys again next turn and see what new tech they have chosen.If you have it,you can gift it.It is possible to get each AI researching a different tech that you don't have for you.
You can "leapfrog" in effect.Amazing what can be done in multiplay using this idea.
Conversely if you see an AI is closing in a tech that maybe you want to be first to,you can "tech bomb" them with gifts raising their research cost adding many turns to their science rate.One idea in OCC is to gift everything to everybody ASAP.The AIs science rates can literally go 100s of turns to complete a tech or just add enough to get you there first.
Or-you often get spots when you are not offered a tech that you should be.If you know AIs have other techs,you can select one of them and then immediately trade for it.This saves lots of turns.Next turn you will be offered the tech you originally wanted
You must be careful in OCC though.In gotm 19 I got rooked by tech choices but knew an AI had Communism.I selected it with the idea of trading.BUT,the ai wanted Advanced Flight.This was just too risky as the AI in question was on my landmass and would certainly send bombers over.Bombers are a real nightmare in OCC.So I had to bit the bullet and waste the turns researching Commie on my own.Had the AI been farther away or something I may taken the gamble.