赞
踩
import openai import os import os from openai import OpenAI def openai_reply(content, apikey): client = OpenAI( # This is the default and can be omitted api_key=apikey, ) chat_completion = client.chat.completions.create( messages=[ { "role": "user", "content": content, } ], model="gpt-4-1106-preview", ) # print(chat_completion) return chat_completion.choices[0].message.content if __name__ == '__main__': while True: content = input("人类:") apikey='your Key' text1=openai_reply(content, apikey) print("AI:"+text1)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。