ChatGPT/OpenAI/NewBing的使用以及AI工具推荐 您所在的位置:网站首页 dreamtobe翻译 ChatGPT/OpenAI/NewBing的使用以及AI工具推荐

ChatGPT/OpenAI/NewBing的使用以及AI工具推荐

2023-05-11 12:29| 来源: 网络整理| 查看: 265

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 实验室设备网 版权所有