ChatGPT/OpenAI/NewBing的使用以及AI工具推荐 | 您所在的位置:网站首页 › dreamtobe翻译 › ChatGPT/OpenAI/NewBing的使用以及AI工具推荐 |
import openai # Replace with your own API keyopenai.api_key = "YOUR_OPENAI_API_KEY" # Start a conversation with "Hello"prompt = "Hello" # Create a chatbot using ChatGPT engineresponse = openai.Completion.create( engine="text-davinci-003", prompt=prompt, max_tokens=50, temperature=0.9) # Print out the chatbot's replyprint("Chatbot:", response["choices"][0]["text"]) # Loop until the user types "quit"while True: # Get the user's input user_input = input("User: ") # Break the loop if the user types "quit" if user_input.lower() == "quit": break # Append the user's input to the prompt prompt += "\nUser: " + user_input # Create a new response using the updated prompt response = openai.Completion.create( engine="text-davinci-003", prompt=prompt, max_tokens=256, temperature=0.9 ) # Print out the chatbot's reply print(response["choices"][0]["text"]) # Append the chatbot's reply to the prompt prompt += "\nChatbot: " + response["choices"][0]["text"] |
CopyRight 2018-2019 实验室设备网 版权所有 |