You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
603 B

import openai
# 替换为您的API密钥
openai.api_key = "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"
# 设置GPT-3 API参数
prompt = "输入您的提示文字"
model = "text-davinci-003" # 选择您想使用的模型,例如:"text-davinci-003",这是GPT-3的Davinci模型
temperature = 0.8
max_tokens = 100
# 调用GPT-3 API
response = openai.Completion.create(
engine=model,
prompt=prompt,
temperature=temperature,
max_tokens=max_tokens,
n=1,
stop=None,
echo=False
)
# 输出结果
generated_text = response.choices[0].text.strip()
print(generated_text)