将上面代码变成Python可复制代码
时间: 2023-07-31 15:14:06 浏览: 95
复制粘贴功能的Python程序
```python
import openai
openai.api_key = "YOUR_API_KEY"
def ask_gpt(prompt, model, length=50):
completions = openai.Completion.create(
engine=model,
prompt=prompt,
max_tokens=length
)
message = completions.choices[0].text.strip()
return message
```
阅读全文