飞道的博客

使用Python调用ChatGPT

459人阅读  评论(0)

import openai

# Set up the OpenAI API client

openai.api_key = "你的KEY"

# Set up the model and prompt

model_engine = "ada"

prompt = input('请输入字符串:')

# Generate a response

completion = openai.Completion.create(

engine=model_engine,

prompt=prompt,

max_tokens=1024,

n=1,

stop=None,

temperature=0.5,

)

response = completion.choices[0].text

print(response)

ChatGPT国内体验网址 https://1bit.asia


转载:https://blog.csdn.net/liuhenghui5201/article/details/129019322
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场