赞
踩
import openai_secret_manager
assert "openai" in openai_secret_manager.get_services()
secrets = openai_secret_manager.get_secret("openai")
import openai
openai.api_key = secrets["api_key"]
def ask_gpt(prompt):
completions = openai.Completion.create(
engine="davinci",
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
message = completions.choices[0].text.strip()
return message
prompt = "什么是人工智能?"
answer = ask_gpt(prompt)
print(answer)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。