最近openai开发的ChatGPT可谓是吸睛全球,发布两个月注册用户过亿,各大互联网巨头宣布与之相关业务,下面介绍一下如何通过python来调用chatgpt的api
step 1:
pip install openai
step 2:
import openai
# Set your API key
openai.api_key = "your api key"
completion = openai.Completion.create(
# optional:text-davinci-003 text-davinci-002
engine="text-davinci-003",
prompt='使用python实现冒泡排序算法',
max_tokens=2048,
temperature=0.1
)
# get response
print(completion.choices[0].text)
)
另外可参考:http://user-chat.top/