Python调用chatgpt

import openai

 

# 设置chatgpt的密钥

openai.api_key = "你的APT密钥"

 

# 设置模型

model_engine = "text-davinci-003"

prompt = "输入的问题:"

 

# 向服务器发送请求

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)

 

 

 

本文链接:https://my.lmcjl.com/post/6551.html

展开阅读全文

4 评论

留下您的评论.