QChatGPT/tests/gpt3_test.py
2023-04-06 20:34:56 +08:00

14 lines
440 B
Python

import openai
openai.api_key = "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"
resp = openai.Completion.create(
prompt="user:你好,今天天气怎么样?\nbot:",
model="text-davinci-003",
temperature=0.9, # 数值越低得到的回答越理性,取值范围[0, 1]
top_p=1, # 生成的文本的文本与要求的符合度, 取值范围[0, 1]
frequency_penalty=0.2,
presence_penalty=1.0,
)
print(resp)