An Italian senator has surprised his colleagues by reading out in parliament a speech drafted by a chatbot, saying afterwards that he pulled the stunt to stir "a serious debate" on risks and opportunities posed by artificial intelligence.

"How many of us today are able to distinguish between a text produced by human intelligence and a stream of thoughts ... produced by an artificial intelligence algorithm?" centrist senator Marco Lombardo asked colleagues.

His speech, on the subject of various bilateral deals with Switzerland, was produced by Microsoft Corp-backed OpenAI's GPT-4 chatbot, the senator told Reuters on Thursday.

He said his staff "took a couple of hours" to feed the necessary information into the software, which then produced the speech "instantaneously".

The leader of Lombardo's Azione party, Carlo Calenda, said on Twitter that what the senator said in the chamber was "impeccable", but added: "It is not yet clear to me whether we are looking at progress or at a step back."

Lombardo said he had been impressed by recent developments in AI, but called for a better understanding of the technology in order to strike the correct balance between regulation and innovation.

Italy has taken centre stage in recent months in worldwide regulation efforts on AI, with the country's data protection authority temporarily banning ChatGPT and starting a probe over the application's suspected breach of privacy rules.

On Wednesday, European Union tech chief Margrethe Vestager said she believed a draft voluntary code of conduct for generative AI could be drawn up "within the next weeks", with a final proposal for industry to sign up "very, very soon". (Reporting by Federico Maccioni; Editing by Alvise Armellini and David Holmes)