# 原始文本ori_text = """Mikel Arteta has named an unchanged side for tonight’s game against Everton.The boss has stuck with the same starting line-up that beat Leicester City on Saturday, with Leandro Trossard expected to start up front once again after impressing against the Foxes.Jorginho makes his fourth successive start in midfield, with Thomas Partey still only fit enough for a spot on the bench.Sean Dyche meanwhile has made one change to his line-up from Saturday’s 1-0 loss against Aston Villa, with Michael Keane replacing Conor Coady in the heart of defence.The former Burnley defender has played just 22 minutes in the Premier League this season, and has been out recently with a knee injury but has been recalled by his former manager for this evening’s encounter at Emirates Stadium.Arsenal: Ramsdale, White, Saliba, Gabriel, Zinchenko, Xhaka, Jorginho, Odegaard, Saka, Martinelli, Trossard. Subs: Turner, Tierney, Tomiyasu, Holding, Kiwior, Partey, Vieira, Smith Rowe, Nketiah.Everton: Pickford, Coleman, Tarkowski, Keane, Mykolenko, Gueye, Onana, Doucoure, Iwobi, McNeil, Maupay. Subs: Begovic, Vinagre, Godfrey, Holgate, Coady, Mina, Davies, Gray, Simms."""models = ["gpt-3.5-turbo", "text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001"]
# 翻译参数,参考https://platform.openai.com/playground/p/default-translateprompt = "please translate this into Simplified Chinese"input_str = "\n\n".join([prompt, ori_text])temperature = 0.3max_len = 1024top_p = 1
# 结果存储res_ls = []
# Chat类接口t0 = time.time()result = openai.ChatCompletion.create(model=models[0], max_tokens=max_len, temperature=temperature, top_p=1,        messages=[{"role": "user", "content": input_str}])t1 = time.time()print(f"{models[0]}\t{t1-t0:.2f}", flush=True)res_ls.append(result)
# Completion类接口for model in models[1:]:    t0 = time.time()    result = openai.Completion.create(model=model, max_tokens=max_len, temperature=temperature, top_p=1, prompt=input_str)    t1 = time.time()    res_ls.append(result)    print(f"{model}\t{t1-t0:.2f}", flush=True)print(len(res_ls))
评论