官方例程的网址:https://platform.openai.com/examples

例如 chat 模块的demo代码:
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(
model="text-davinci-003",
prompt="The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.\n\nHuman: Hello, who are you?\nAI: I am an AI created by OpenAI. How can I help you today?\nHuman: I'd like to cancel my subscription.\nAI:",
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.6,
stop=[" Human:", " AI:"]
)
各个参数的含义:

文章展示了如何利用OpenAI的API创建一个聊天模块的示例代码,包括设置API密钥、调用Completion.create方法与AI进行对话,并详细解释了各参数如temperature、max_tokens等的含义。
2万+

被折叠的 条评论
为什么被折叠?



